]> 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>
Fri, 14 Apr 2023 09:45:47 +0000 (11:45 +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.

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 efa2d0daa5248b0c6eb2cd12183db1d8915c5cd3..6b7dbfd4a231baec24e740ffe0ce0b0bf7a1de6b 100644 (file)
@@ -5595,8 +5595,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,