1;; For various ops lift a splat outside of the op to try to open up
2;; optimization opportunities with scalars.
3;;
4;; NB: for int-to-float conversion op this simplification is also
5;; required for correctness at this time due to #6562
6(rule (simplify (fcvt_from_uint float_vector_ty (splat _ x)))
7      (splat float_vector_ty (fcvt_from_uint (lane_type float_vector_ty) x)))
8(rule (simplify (fcvt_from_sint float_vector_ty (splat _ x)))
9      (splat float_vector_ty (fcvt_from_sint (lane_type float_vector_ty) x)))
10
11(rule (simplify (band ty (splat ty x) (splat ty y)))
12      (splat ty (band (lane_type ty) x y)))
13
14(rule (simplify (bor ty (splat ty x) (splat ty y)))
15      (splat ty (bor (lane_type ty) x y)))
16
17(rule (simplify (bxor ty (splat ty x) (splat ty y)))
18      (splat ty (bxor (lane_type ty) x y)))
19
20(rule (simplify (bnot ty (splat ty x)))
21      (splat ty (bnot (lane_type ty) x)))
22
23(rule (simplify (iadd ty (splat ty x) (splat ty y)))
24      (splat ty (iadd (lane_type ty) x y)))
25
26(rule (simplify (isub ty (splat ty x) (splat ty y)))
27      (splat ty (isub (lane_type ty) x y)))
28
29(rule (simplify (imul ty (splat ty x) (splat ty y)))
30      (splat ty (imul (lane_type ty) x y)))
31
32(rule (simplify (smulhi ty (splat ty x) (splat ty y)))
33      (splat ty (smulhi (lane_type ty) x y)))
34
35(rule (simplify (umulhi ty (splat ty x) (splat ty y)))
36      (splat ty (umulhi (lane_type ty) x y)))
37
38(rule (simplify (ineg ty (splat ty x)))
39      (splat ty (ineg (lane_type ty) x)))
40
41(rule (simplify (iabs ty (splat ty x)))
42      (splat ty (iabs (lane_type ty) x)))
43
44(rule (simplify (popcnt ty (splat ty x)))
45      (splat ty (popcnt (lane_type ty) x)))
46
47(rule (simplify (smin ty (splat ty x) (splat ty y)))
48      (splat ty (smin (lane_type ty) x y)))
49
50(rule (simplify (umin ty (splat ty x) (splat ty y)))
51      (splat ty (umin (lane_type ty) x y)))
52
53(rule (simplify (smax ty (splat ty x) (splat ty y)))
54      (splat ty (smax (lane_type ty) x y)))
55
56(rule (simplify (umax ty (splat ty x) (splat ty y)))
57      (splat ty (umax (lane_type ty) x y)))
58
59;; The second operand of shift and rotate ops is
60;; scalar so splat opt applies only to the first
61(rule (simplify (rotl ty (splat ty x) y))
62      (splat ty (rotl (lane_type ty) x y)))
63
64(rule (simplify (rotr ty (splat ty x) y))
65      (splat ty (rotr (lane_type ty) x y)))
66
67(rule (simplify (ishl ty (splat ty x) y))
68      (splat ty (ishl (lane_type ty) x y)))
69
70(rule (simplify (ushr ty (splat ty x) y))
71      (splat ty (ushr (lane_type ty) x y)))
72
73(rule (simplify (sshr ty (splat ty x) y))
74      (splat ty (sshr (lane_type ty) x y)))