]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/109502 - vector conversion between mask and non-mask
authorRichard Biener <rguenther@suse.de>
Fri, 14 Apr 2023 07:55:27 +0000 (09:55 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 17 Apr 2023 09:13:17 +0000 (11:13 +0200)
The following fixes a check that should have rejected vectorizing
a conversion between a mask and non-mask type.  Those should be
done via pattern statements.

PR tree-optimization/109502
* tree-vect-stmts.cc (vectorizable_assignment): Fix
check for conversion between mask and non-mask types.

* gcc.dg/vect/pr109502.c: New testcase.

(cherry picked from commit bf24f2db2841b97bc5e86bf9294d61eef32f83b3)

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

diff --git a/gcc/testsuite/gcc.dg/vect/pr109502.c b/gcc/testsuite/gcc.dg/vect/pr109502.c
new file mode 100644 (file)
index 0000000..970c63e
--- /dev/null
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-additional-options "-O" } */
+
+unsigned g;
+
+unsigned
+foo (void)
+{
+  unsigned a = !g;
+  a += !(a % 6);
+  return a;
+}
+
+int
+main ()
+{
+  unsigned x = foo ();
+  if (x != 1)
+    __builtin_abort ();
+  return 0;
+}
index 72a558f2916b4f1d2b7bd93588ab5c591e921d26..34920041116bba750efaffcf5ee839db99bdd6ae 100644 (file)
@@ -5469,8 +5469,7 @@ vectorizable_assignment (vec_info *vinfo,
                       GET_MODE_SIZE (TYPE_MODE (vectype_in)))))
     return false;
 
-  if (VECTOR_BOOLEAN_TYPE_P (vectype)
-      && !VECTOR_BOOLEAN_TYPE_P (vectype_in))
+  if (VECTOR_BOOLEAN_TYPE_P (vectype) != VECTOR_BOOLEAN_TYPE_P (vectype_in))
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,