]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/102572 - fix gathers with invariant mask
authorRichard Biener <rguenther@suse.de>
Tue, 12 Oct 2021 11:42:08 +0000 (13:42 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 12 Oct 2021 12:49:44 +0000 (14:49 +0200)
This fixes the vector def gathering for invariant masks which
failed to pass in the desired vector type resulting in a non-mask
type to be generate.

2021-10-12  Richard Biener  <rguenther@suse.de>

PR tree-optimization/102572
* tree-vect-stmts.c (vect_build_gather_load_calls): When
gathering the vectorized defs for the mask pass in the
desired mask vector type so invariants will be handled
correctly.

* g++.dg/vect/pr102572.cc: New testcase.

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

diff --git a/gcc/testsuite/g++.dg/vect/pr102572.cc b/gcc/testsuite/g++.dg/vect/pr102572.cc
new file mode 100644 (file)
index 0000000..0a71308
--- /dev/null
@@ -0,0 +1,14 @@
+// { dg-do compile }
+// { dg-additional-options "-O3" }
+// { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } }
+
+int a, b, c, f;
+void g(bool h, int d[][5])
+{
+  for (short i = f; i; i += 1)
+    {
+      a = h && d[0][i];
+      for (int j = 0; j < 4; j += c)
+       b = 0;
+    }
+}
index a9c9e3d7c3737330957abea48f1dcbe929638417..f5e1941f8ad358903deda54a521a6b4ba8f84b37 100644 (file)
@@ -2791,7 +2791,7 @@ vect_build_gather_load_calls (vec_info *vinfo, stmt_vec_info stmt_info,
   if (mask)
     vect_get_vec_defs_for_operand (vinfo, stmt_info,
                                   modifier == NARROW ? ncopies / 2 : ncopies,
-                                  mask, &vec_masks);
+                                  mask, &vec_masks, masktype);
   for (int j = 0; j < ncopies; ++j)
     {
       tree op, var;