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.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

        * 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 |  6 +++---
 gcc/tree-vect-stmts.cc                    | 21 +++++----------------
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/vect-gather-1.c 
b/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
index 5f6640d9ab6..6497ab4cb3f 100644
--- a/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
+++ b/gcc/testsuite/gcc.dg/vect/vect-gather-1.c
@@ -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])
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 00d7542804c..1ccd38b91af 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -1484,23 +1484,12 @@ check_load_store_for_partial_vectors (loop_vec_info 
loop_vinfo, tree vectype,
 
   if (memory_access_type == VMAT_GATHER_SCATTER)
     {
-      internal_fn ifn = (is_load
-                        ? IFN_MASK_GATHER_LOAD
-                        : IFN_MASK_SCATTER_STORE);
-      internal_fn len_ifn = (is_load
-                            ? IFN_MASK_LEN_GATHER_LOAD
-                            : IFN_MASK_LEN_SCATTER_STORE);
-      if (internal_gather_scatter_fn_supported_p (len_ifn, vectype,
-                                                 gs_info->memory_type,
-                                                 gs_info->offset_vectype,
-                                                 gs_info->scale,
-                                                 elsvals))
+      if (gs_info->ifn == IFN_MASK_LEN_GATHER_LOAD
+         || gs_info->ifn == IFN_MASK_LEN_SCATTER_STORE)
        vect_record_loop_len (loop_vinfo, lens, nvectors, vectype, 1);
-      else if (internal_gather_scatter_fn_supported_p (ifn, vectype,
-                                                      gs_info->memory_type,
-                                                      gs_info->offset_vectype,
-                                                      gs_info->scale,
-                                                      elsvals))
+      else if (gs_info->ifn == IFN_MASK_GATHER_LOAD
+              || gs_info->ifn == IFN_MASK_SCATTER_STORE
+              || gs_info->decl != NULL_TREE)
        vect_record_loop_mask (loop_vinfo, masks, nvectors, vectype,
                               scalar_mask);
       else
-- 
2.43.0

Reply via email to