]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Don't pass booleans as mask types to simd clones [PR92710]
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 29 Nov 2019 13:04:56 +0000 (13:04 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 18 Feb 2020 08:52:00 +0000 (08:52 +0000)
In this PR we assigned a vector mask type to the result of a comparison
and then tried to pass that mask type to a simd clone, which expected
a normal (non-mask) type instead.

This patch simply punts on call arguments that have a mask type.
A better fix would be to pattern-match the comparison to a COND_EXPR,
like we would if the comparison was stored to memory, but doing that
isn't gcc 9 or 10 material.

Note that this doesn't affect x86_64-linux-gnu because the ABI promotes
bool arguments to ints.

2020-02-18  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
Backport from mainline
2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>

PR tree-optimization/92710
* tree-vect-stmts.c (vectorizable_simd_clone_call): Reject
vector mask arguments.

gcc/testsuite/
PR tree-optimization/92710
* gcc.dg/vect/pr92710.c: New test.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr92710.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index 8de0814872990a65fd9dd07c6b14e06d5b57a632..91a64fff8f4b66169d0e2683ed7d063ff254fc15 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-18  Richard Sandiford  <richard.sandiford@arm.com>
+
+       Backport from mainline
+       2019-11-29  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/92710
+       * tree-vect-stmts.c (vectorizable_simd_clone_call): Reject
+       vector mask arguments.
+
 2020-02-18  Richard Sandiford  <richard.sandiford@arm.com>
 
        Backport from mainline
index 3ec4cf5addb12c463d7f6ef3c39da1c5d26f0513..fe9b6013e8f74bbb24e14e0890e3e93c58b305b4 100644 (file)
@@ -1,3 +1,8 @@
+2020-02-18  Richard Sandiford  <richard.sandiford@arm.com>
+
+       PR tree-optimization/92710
+       * gcc.dg/vect/pr92710.c: New test.
+
 2020-02-18  Richard Sandiford  <richard.sandiford@arm.com>
 
        PR tree-optimization/92420
diff --git a/gcc/testsuite/gcc.dg/vect/pr92710.c b/gcc/testsuite/gcc.dg/vect/pr92710.c
new file mode 100644 (file)
index 0000000..2986d4c
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fopenmp-simd" } */
+
+#pragma omp declare simd
+_Bool foo (_Bool) __attribute__((const));
+
+void
+f (_Bool *restrict x, char *restrict y, char *restrict z)
+{
+  for (int i = 0; i < 128; ++i)
+    x[i] = foo (y[i] == z[i]);
+}
index 8fd7af198175884cc58178ca69f1cc5f34a70a59..507f81b0a0e8c3408b98a3fad83a08fe7d584cee 100644 (file)
@@ -3915,7 +3915,16 @@ vectorizable_simd_clone_call (stmt_vec_info stmt_info,
          || thisarginfo.dt == vect_external_def)
        gcc_assert (thisarginfo.vectype == NULL_TREE);
       else
-       gcc_assert (thisarginfo.vectype != NULL_TREE);
+       {
+         gcc_assert (thisarginfo.vectype != NULL_TREE);
+         if (VECTOR_BOOLEAN_TYPE_P (thisarginfo.vectype))
+           {
+             if (dump_enabled_p ())
+               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                "vector mask arguments are not supported\n");
+             return false;
+           }
+       }
 
       /* For linear arguments, the analyze phase should have saved
         the base and step in STMT_VINFO_SIMD_CLONE_INFO.  */