slp: check that the operation we're combing is a boolean operation [PR103741]
authorTamar Christina <tamar.christina@arm.com>
Fri, 17 Dec 2021 10:59:25 +0000 (10:59 +0000)
committerTamar Christina <tamar.christina@arm.com>
Fri, 17 Dec 2021 10:59:33 +0000 (10:59 +0000)
It seems I forgot to check that the operation we're combing when masking the
predicated together are actually predicates types.

Without it we end up accidentally trying to combine a value and a mask.

gcc/ChangeLog:

PR tree-optimization/103741
* tree-vect-stmts.c (vectorizable_operation): Check for boolean.

gcc/testsuite/ChangeLog:

PR tree-optimization/103741
* gcc.target/aarch64/pr103741.c: New test.

gcc/testsuite/gcc.target/aarch64/pr103741.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

diff --git a/gcc/testsuite/gcc.target/aarch64/pr103741.c b/gcc/testsuite/gcc.target/aarch64/pr103741.c
new file mode 100644 (file)
index 0000000..ef3ae66
--- /dev/null
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-march=armv8-a+sve -O1" } */
+
+long int m, n;
+
+int
+qux (int z)
+{
+  return 4 >> z ? z : 0;
+}
+
+int
+bar (long int y)
+{
+  return y ? 3 : 2;
+}
+
+__attribute__ ((simd)) int
+foo (int x)
+{
+  long int a = x & m;
+  int b = bar (x) / n;
+
+  return qux (b) == a;
+}
+
index 8c42717..ad90cdb 100644 (file)
@@ -6361,7 +6361,9 @@ vectorizable_operation (vec_info *vinfo,
          /* When combining two masks check if either of them is elsewhere
             combined with a loop mask, if that's the case we can mark that the
             new combined mask doesn't need to be combined with a loop mask.  */
-         if (masked_loop_p && code == BIT_AND_EXPR)
+         if (masked_loop_p
+             && code == BIT_AND_EXPR
+             && VECTOR_BOOLEAN_TYPE_P (vectype))
            {
              if (loop_vinfo->scalar_cond_masked_set.contains ({ op0,
                                                                 ncopies}))