tree-optimization/95487 - use a truth type for scatter masks
authorRichard Biener <rguenther@suse.de>
Wed, 3 Jun 2020 13:51:29 +0000 (15:51 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 3 Jun 2020 16:59:13 +0000 (18:59 +0200)
This makes sure to get a truth type for scatter masks even when they
are invariant.

2020-06-03  Richard Biener  <rguenther@suse.de>

PR tree-optimization/95487
* tree-vect-stmts.c (vectorizable_store): Use a truth type
for the scatter mask.

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

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

diff --git a/gcc/testsuite/g++.dg/vect/pr95487.cc b/gcc/testsuite/g++.dg/vect/pr95487.cc
new file mode 100644 (file)
index 0000000..34023d2
--- /dev/null
@@ -0,0 +1,20 @@
+// { dg-do compile }
+// { dg-additional-options "-O3" }
+// { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } }
+
+int a;
+bool d;
+char e;
+extern short f[];
+extern int g[];
+short j;
+void h() {
+  for (short b = j; b < 0; b += 2) {
+    f[b] = 0;
+    if (d) {
+      for (char c = 0; c < a; c += 3)
+        e = 0;
+      g[b] = 0;
+    }
+  }
+}
index a6c7f333fc7df5b0ca1a404ff2f8d2fac42267a9..5548f0d987f430afeefc4650750631ff07e1268c 100644 (file)
@@ -7676,8 +7676,12 @@ vectorizable_store (vec_info *vinfo,
                                                              gs_info.offset,
                                                              stmt_info);
              if (mask)
-               mask_op = vec_mask = vect_get_vec_def_for_operand (vinfo, mask,
-                                                                  stmt_info);
+               {
+                 tree mask_vectype = truth_type_for (vectype);
+                 mask_op = vec_mask
+                   = vect_get_vec_def_for_operand (vinfo, mask,
+                                                   stmt_info, mask_vectype);
+               }
            }
          else if (modifier != NONE && (j & 1))
            {