]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/119534 - reject bogus emulated vectorized gather
authorRichard Biener <rguenther@suse.de>
Tue, 1 Apr 2025 12:13:03 +0000 (14:13 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 1 Apr 2025 13:23:27 +0000 (15:23 +0200)
The following makes sure to reject the attempts to emulate a vector
gather when the discovered index vector type is a vector mask.

PR tree-optimization/119534
* tree-vect-stmts.cc (get_load_store_type): Reject
VECTOR_BOOLEAN_TYPE_P offset vector type for emulated gathers.

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

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

diff --git a/gcc/testsuite/gcc.dg/vect/pr119534.c b/gcc/testsuite/gcc.dg/vect/pr119534.c
new file mode 100644 (file)
index 0000000..0b4130b
--- /dev/null
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mavx512bw" { target { x86_64-*-* i?86-*-* } } } */
+
+void f(int w, int *out, double *d)
+{
+  for (int j = 0; j < w; j++)
+    {
+      const int i = (j >= w / 2);
+      out[j] += d[i];
+    }
+}
index 813b2b77951158462800a3db6399f07842d0febc..8bd5ea96667d71292b2ca3613065ba07e3ac858d 100644 (file)
@@ -2522,6 +2522,7 @@ get_load_store_type (vec_info  *vinfo, stmt_vec_info stmt_info,
        {
          if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant ()
              || !TYPE_VECTOR_SUBPARTS (gs_info->offset_vectype).is_constant ()
+             || VECTOR_BOOLEAN_TYPE_P (gs_info->offset_vectype)
              || !constant_multiple_p (TYPE_VECTOR_SUBPARTS
                                         (gs_info->offset_vectype),
                                       TYPE_VECTOR_SUBPARTS (vectype)))