This pattern does not work for vector types as written. To make it work we need to
create a vec_duplicate of the `bool` value. I am not sure that is better so for
right now this just enables the pattern only for INTEGRAL_TYPE_P types (which means
non-vectors).
Pushed as obvious after a bootstrap/test on x86_64-linux-gnu.
PR tree-optimization/125139
gcc/ChangeLog:
* match.pd (`(A>>bool) EQ 0 -> (unsigned)A LE bool`): Enable
only for INTEGRAL_TYPE_P types.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr125139-1.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
icmp (le gt)
(simplify
(cmp (rshift@2 @0 zero_one_valued_p@1) integer_zerop)
- (if (single_use (@2))
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) && single_use (@2))
(with { tree utype = unsigned_type_for (TREE_TYPE (@0)); }
(icmp (convert:utype @0) (convert:utype @1))))))
#endif
--- /dev/null
+/* { dg-do compile } */
+
+typedef __attribute__((vector_size(4*sizeof(int)))) int v4int;
+
+void f(v4int *v, int a)
+{
+ a &= 1;
+ *v = *v >> a;
+ *v = *v == 0;
+}