]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow fully masked loops with legacy gather/scatter
authorRichard Biener <rguenther@suse.de>
Tue, 5 Aug 2025 12:55:18 +0000 (14:55 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 6 Aug 2025 13:17:04 +0000 (15:17 +0200)
The following removes the redundant check on supported gather/scatter
IFN in check_load_store_for_partial_vectors which is already done
and adjusts those to check the recorded ifn, also allowing legacy
gather/scatter which all handle masking.

* tree-vect-stmts.cc (check_load_store_for_partial_vectors):
Remove redundant gather/scatter target support check, instead
check the recorded ifns.  Also allow legacy gather/scatter
with loop masking.

* gcc.dg/vect/vect-gather-1.c: Adjust to hide N.

gcc/testsuite/gcc.dg/vect/vect-gather-1.c
gcc/tree-vect-stmts.cc

index 5f6640d9ab65a4b126e989e784d0d7a95745b732..6497ab4cb3fee2598261e7311872f813ce8546f1 100644 (file)
@@ -3,9 +3,9 @@
 #define N 16
 
 void __attribute__((noipa))
-f (int *restrict y, int *restrict x, int *restrict indices)
+f (int *restrict y, int *restrict x, int *restrict indices, int n)
 {
-  for (int i = 0; i < N; ++i)
+  for (int i = 0; i < n; ++i)
     {
       y[i * 2] = x[indices[i * 2]] + 1;
       y[i * 2 + 1] = x[indices[i * 2 + 1]] + 2;
@@ -49,7 +49,7 @@ main (void)
 {
   check_vect ();
 
-  f (y, x, indices);
+  f (y, x, indices, N);
 #pragma GCC novector
   for (int i = 0; i < 32; ++i)
     if (y[i] != expected[i])
index f7a052b6660e19fd80ac4e410822569df13ea9ec..f3af31015612de5746ae13e9d3ebe4d9bcac3874 100644 (file)
@@ -1497,7 +1497,8 @@ check_load_store_for_partial_vectors (loop_vec_info loop_vinfo, tree vectype,
                                                       gs_info->memory_type,
                                                       gs_info->offset_vectype,
                                                       gs_info->scale,
-                                                      elsvals))
+                                                      elsvals)
+              || gs_info->decl != NULL_TREE)
        vect_record_loop_mask (loop_vinfo, masks, nvectors, vectype,
                               scalar_mask);
       else