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.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK for trunk
and gcc-9-branch?

Richard


2019-11-30  Richard Sandiford  <richard.sandif...@arm.com>

gcc/
        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.

Index: gcc/tree-vect-stmts.c
===================================================================
--- gcc/tree-vect-stmts.c       2019-11-22 09:57:59.194224976 +0000
+++ gcc/tree-vect-stmts.c       2019-11-29 08:28:12.015121876 +0000
@@ -3925,7 +3925,16 @@ vectorizable_simd_clone_call (stmt_vec_i
          || 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.  */
Index: gcc/testsuite/gcc.dg/vect/pr92710.c
===================================================================
--- /dev/null   2019-09-17 11:41:18.176664108 +0100
+++ gcc/testsuite/gcc.dg/vect/pr92710.c 2019-11-29 08:28:12.011121905 +0000
@@ -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]);
+}

Reply via email to