16650378aSGurinder Singh;; For various ops lift a splat outside of the op to try to open up 2a986ce96SAlex Crichton;; optimization opportunities with scalars. 3*8a2d9bc7SAlex Crichton 46650378aSGurinder Singh;; NB: for int-to-float conversion op this simplification is also 5*8a2d9bc7SAlex Crichton;; required for the x64 backend because it doesn't fully implement int-to-float 6*8a2d9bc7SAlex Crichton;; conversions for 64x2 vectors, for more information see #6562 7a986ce96SAlex Crichton(rule (simplify (fcvt_from_uint float_vector_ty (splat _ x))) 8a986ce96SAlex Crichton (splat float_vector_ty (fcvt_from_uint (lane_type float_vector_ty) x))) 9a986ce96SAlex Crichton(rule (simplify (fcvt_from_sint float_vector_ty (splat _ x))) 10a986ce96SAlex Crichton (splat float_vector_ty (fcvt_from_sint (lane_type float_vector_ty) x))) 116650378aSGurinder Singh 121e8b4592SAfonso Bordado;; Scalar bitwise ops are usually not implemented in the backends for floats, so 131e8b4592SAfonso Bordado;; disable this transform. 141e8b4592SAfonso Bordado 156650378aSGurinder Singh(rule (simplify (band ty (splat ty x) (splat ty y))) 161e8b4592SAfonso Bordado (if (ty_vector_not_float ty)) 176650378aSGurinder Singh (splat ty (band (lane_type ty) x y))) 186650378aSGurinder Singh 196650378aSGurinder Singh(rule (simplify (bor ty (splat ty x) (splat ty y))) 201e8b4592SAfonso Bordado (if (ty_vector_not_float ty)) 216650378aSGurinder Singh (splat ty (bor (lane_type ty) x y))) 226650378aSGurinder Singh 236650378aSGurinder Singh(rule (simplify (bxor ty (splat ty x) (splat ty y))) 241e8b4592SAfonso Bordado (if (ty_vector_not_float ty)) 256650378aSGurinder Singh (splat ty (bxor (lane_type ty) x y))) 266650378aSGurinder Singh 276650378aSGurinder Singh(rule (simplify (bnot ty (splat ty x))) 281e8b4592SAfonso Bordado (if (ty_vector_not_float ty)) 296650378aSGurinder Singh (splat ty (bnot (lane_type ty) x))) 306650378aSGurinder Singh 316650378aSGurinder Singh(rule (simplify (iadd ty (splat ty x) (splat ty y))) 326650378aSGurinder Singh (splat ty (iadd (lane_type ty) x y))) 336650378aSGurinder Singh 346650378aSGurinder Singh(rule (simplify (isub ty (splat ty x) (splat ty y))) 356650378aSGurinder Singh (splat ty (isub (lane_type ty) x y))) 366650378aSGurinder Singh 376650378aSGurinder Singh(rule (simplify (imul ty (splat ty x) (splat ty y))) 386650378aSGurinder Singh (splat ty (imul (lane_type ty) x y))) 396650378aSGurinder Singh 406650378aSGurinder Singh(rule (simplify (smulhi ty (splat ty x) (splat ty y))) 416650378aSGurinder Singh (splat ty (smulhi (lane_type ty) x y))) 426650378aSGurinder Singh 436650378aSGurinder Singh(rule (simplify (umulhi ty (splat ty x) (splat ty y))) 446650378aSGurinder Singh (splat ty (umulhi (lane_type ty) x y))) 456650378aSGurinder Singh 466650378aSGurinder Singh(rule (simplify (ineg ty (splat ty x))) 476650378aSGurinder Singh (splat ty (ineg (lane_type ty) x))) 486650378aSGurinder Singh 496650378aSGurinder Singh(rule (simplify (iabs ty (splat ty x))) 506650378aSGurinder Singh (splat ty (iabs (lane_type ty) x))) 516650378aSGurinder Singh 526650378aSGurinder Singh(rule (simplify (popcnt ty (splat ty x))) 536650378aSGurinder Singh (splat ty (popcnt (lane_type ty) x))) 546650378aSGurinder Singh 556650378aSGurinder Singh(rule (simplify (smin ty (splat ty x) (splat ty y))) 566650378aSGurinder Singh (splat ty (smin (lane_type ty) x y))) 576650378aSGurinder Singh 586650378aSGurinder Singh(rule (simplify (umin ty (splat ty x) (splat ty y))) 596650378aSGurinder Singh (splat ty (umin (lane_type ty) x y))) 606650378aSGurinder Singh 616650378aSGurinder Singh(rule (simplify (smax ty (splat ty x) (splat ty y))) 626650378aSGurinder Singh (splat ty (smax (lane_type ty) x y))) 636650378aSGurinder Singh 646650378aSGurinder Singh(rule (simplify (umax ty (splat ty x) (splat ty y))) 656650378aSGurinder Singh (splat ty (umax (lane_type ty) x y))) 666650378aSGurinder Singh 676650378aSGurinder Singh;; The second operand of shift and rotate ops is 686650378aSGurinder Singh;; scalar so splat opt applies only to the first 696650378aSGurinder Singh(rule (simplify (rotl ty (splat ty x) y)) 706650378aSGurinder Singh (splat ty (rotl (lane_type ty) x y))) 716650378aSGurinder Singh 726650378aSGurinder Singh(rule (simplify (rotr ty (splat ty x) y)) 736650378aSGurinder Singh (splat ty (rotr (lane_type ty) x y))) 746650378aSGurinder Singh 756650378aSGurinder Singh(rule (simplify (ishl ty (splat ty x) y)) 766650378aSGurinder Singh (splat ty (ishl (lane_type ty) x y))) 776650378aSGurinder Singh 786650378aSGurinder Singh(rule (simplify (ushr ty (splat ty x) y)) 796650378aSGurinder Singh (splat ty (ushr (lane_type ty) x y))) 806650378aSGurinder Singh 816650378aSGurinder Singh(rule (simplify (sshr ty (splat ty x) y)) 826650378aSGurinder Singh (splat ty (sshr (lane_type ty) x y))) 831e8b4592SAfonso Bordado 841e8b4592SAfonso Bordado;; {u,s}widen_{low,high}+splat is the same as splat+{u,s}extend 851e8b4592SAfonso Bordado(rule (simplify (swiden_high wide (splat _ x))) (splat wide (sextend (lane_type wide) x))) 861e8b4592SAfonso Bordado(rule (simplify (swiden_low wide (splat _ x))) (splat wide (sextend (lane_type wide) x))) 871e8b4592SAfonso Bordado 881e8b4592SAfonso Bordado(rule (simplify (uwiden_high wide (splat _ x))) (splat wide (uextend (lane_type wide) x))) 891e8b4592SAfonso Bordado(rule (simplify (uwiden_low wide (splat _ x))) (splat wide (uextend (lane_type wide) x))) 90