]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Support -m[no-]gather -m[no-]scatter to enable/disable vectorization for all gather...
authorliuhongt <hongtao.liu@intel.com>
Thu, 10 Aug 2023 08:26:13 +0000 (16:26 +0800)
committerliuhongt <hongtao.liu@intel.com>
Wed, 16 Aug 2023 02:12:02 +0000 (10:12 +0800)
Rename original use_gather to use_gather_8parts, Support
-mtune-ctrl={,^}use_gather to set/clear tune features
use_gather_{2parts, 4parts, 8parts}. Support the new option -mgather
as alias of -mtune-ctrl=, use_gather, ^use_gather.

Similar for use_scatter.

gcc/ChangeLog:

* config/i386/i386-builtins.cc
(ix86_vectorize_builtin_gather): Adjust for use_gather_8parts.
* config/i386/i386-options.cc (parse_mtune_ctrl_str):
Set/Clear tune features use_{gather,scatter}_{2parts, 4parts,
8parts} for -mtune-crtl={,^}{use_gather,use_scatter}.
* config/i386/i386.cc (ix86_vectorize_builtin_scatter): Adjust
for use_scatter_8parts
* config/i386/i386.h (TARGET_USE_GATHER): Rename to ..
(TARGET_USE_GATHER_8PARTS): .. this.
(TARGET_USE_SCATTER): Rename to ..
(TARGET_USE_SCATTER_8PARTS): .. this.
* config/i386/x86-tune.def (X86_TUNE_USE_GATHER): Rename to
(X86_TUNE_USE_GATHER_8PARTS): .. this.
(X86_TUNE_USE_SCATTER): Rename to
(X86_TUNE_USE_SCATTER_8PARTS): .. this.
* config/i386/i386.opt: Add new options mgather, mscatter.

gcc/config/i386/i386-builtins.cc
gcc/config/i386/i386-options.cc
gcc/config/i386/i386.cc
gcc/config/i386/i386.h
gcc/config/i386/i386.opt
gcc/config/i386/x86-tune.def

index 356b6dfd5fb90f0e9e97a2da6bd85261333bf2e8..8a0b8dfe0735c7f843c7cbf2b7848c55ef22c892 100644 (file)
@@ -1657,7 +1657,7 @@ ix86_vectorize_builtin_gather (const_tree mem_vectype,
          ? !TARGET_USE_GATHER_2PARTS
          : (known_eq (TYPE_VECTOR_SUBPARTS (mem_vectype), 4u)
             ? !TARGET_USE_GATHER_4PARTS
-            : !TARGET_USE_GATHER)))
+            : !TARGET_USE_GATHER_8PARTS)))
     return NULL_TREE;
 
   if ((TREE_CODE (index_type) != INTEGER_TYPE
index e6ba33c370dc9de35e20c2e105256d099009eff6..c8b56b86fd03f657692448bce9ddd61f15aa3eb3 100644 (file)
@@ -1736,20 +1736,46 @@ parse_mtune_ctrl_str (struct gcc_options *opts, bool dump)
           curr_feature_string++;
           clear = true;
         }
-      for (i = 0; i < X86_TUNE_LAST; i++)
-        {
-          if (!strcmp (curr_feature_string, ix86_tune_feature_names[i]))
-            {
-              ix86_tune_features[i] = !clear;
-              if (dump)
-                fprintf (stderr, "Explicitly %s feature %s\n",
-                         clear ? "clear" : "set", ix86_tune_feature_names[i]);
-              break;
-            }
-        }
-      if (i == X86_TUNE_LAST)
-       error ("unknown parameter to option %<-mtune-ctrl%>: %s",
-              clear ? curr_feature_string - 1 : curr_feature_string);
+
+      if (!strcmp (curr_feature_string, "use_gather"))
+       {
+         ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = !clear;
+         ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = !clear;
+         ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = !clear;
+         if (dump)
+           fprintf (stderr, "Explicitly %s features use_gather_2parts,"
+                    " use_gather_4parts, use_gather_8parts\n",
+                    clear ? "clear" : "set");
+
+       }
+      else if (!strcmp (curr_feature_string, "use_scatter"))
+       {
+         ix86_tune_features[X86_TUNE_USE_SCATTER_2PARTS] = !clear;
+         ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS] = !clear;
+         ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS] = !clear;
+         if (dump)
+           fprintf (stderr, "Explicitly %s features use_scatter_2parts,"
+                    " use_scatter_4parts, use_scatter_8parts\n",
+                    clear ? "clear" : "set");
+       }
+      else
+       {
+         for (i = 0; i < X86_TUNE_LAST; i++)
+           {
+             if (!strcmp (curr_feature_string, ix86_tune_feature_names[i]))
+               {
+                 ix86_tune_features[i] = !clear;
+                 if (dump)
+                   fprintf (stderr, "Explicitly %s feature %s\n",
+                            clear ? "clear" : "set", ix86_tune_feature_names[i]);
+                 break;
+               }
+           }
+
+         if (i == X86_TUNE_LAST)
+           error ("unknown parameter to option %<-mtune-ctrl%>: %s",
+                  clear ? curr_feature_string - 1 : curr_feature_string);
+       }
       curr_feature_string = next_feature_string;
     }
   while (curr_feature_string);
index d592ece700a60fad1f253ec85b6de75db6639282..cd49fb9e47a27973b30da93f84e1c192fd3f3106 100644 (file)
@@ -19193,7 +19193,7 @@ ix86_vectorize_builtin_scatter (const_tree vectype,
       ? !TARGET_USE_SCATTER_2PARTS
       : (known_eq (TYPE_VECTOR_SUBPARTS (vectype), 4u)
         ? !TARGET_USE_SCATTER_4PARTS
-        : !TARGET_USE_SCATTER))
+        : !TARGET_USE_SCATTER_8PARTS))
     return NULL_TREE;
 
   if ((TREE_CODE (index_type) != INTEGER_TYPE
index ef342fcee9b3289204129500d8a6934491731a67..f7330e818e7971d822c8075d611cfda4400b0cda 100644 (file)
@@ -403,10 +403,10 @@ extern unsigned char ix86_tune_features[X86_TUNE_LAST];
        ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS]
 #define TARGET_USE_SCATTER_4PARTS \
        ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS]
-#define TARGET_USE_GATHER \
-       ix86_tune_features[X86_TUNE_USE_GATHER]
-#define TARGET_USE_SCATTER \
-       ix86_tune_features[X86_TUNE_USE_SCATTER]
+#define TARGET_USE_GATHER_8PARTS \
+       ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS]
+#define TARGET_USE_SCATTER_8PARTS \
+       ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS]
 #define TARGET_FUSE_CMP_AND_BRANCH_32 \
        ix86_tune_features[X86_TUNE_FUSE_CMP_AND_BRANCH_32]
 #define TARGET_FUSE_CMP_AND_BRANCH_64 \
index 8a43187f7037c7affa24f7c8d7e9f868def7b1c6..78b499304a4d43a5279cf2e3723853bff88c9c6c 100644 (file)
@@ -1302,3 +1302,11 @@ msm4
 Target Mask(ISA2_SM4) Var(ix86_isa_flags2) Save
 Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, AVX and
 SM4 built-in functions and code generation.
+
+mgather
+Target Alias(mtune-ctrl=, use_gather, ^use_gather)
+Enable vectorization for gather instruction.
+
+mscatter
+Target Alias(mtune-ctrl=, use_scatter, ^use_scatter)
+Enable vectorization for scatter instruction.
index 22d26bb0030c70e2dfcdf463c5287d2c291f4af7..735d6635ebaa85e7aa38bce21ba3bf30826451d3 100644 (file)
@@ -511,13 +511,13 @@ DEF_TUNE (X86_TUNE_USE_SCATTER_4PARTS, "use_scatter_4parts",
 
 /* X86_TUNE_USE_GATHER: Use gather instructions for vectors with 8 or more
    elements.  */
-DEF_TUNE (X86_TUNE_USE_GATHER, "use_gather",
+DEF_TUNE (X86_TUNE_USE_GATHER_8PARTS, "use_gather_8parts",
          ~(m_ZNVER1 | m_ZNVER2 | m_ZNVER4 | m_ALDERLAKE | m_ARROWLAKE
            | m_CORE_ATOM | m_GENERIC | m_GDS))
 
 /* X86_TUNE_USE_SCATTER: Use scater instructions for vectors with 8 or more
    elements.  */
-DEF_TUNE (X86_TUNE_USE_SCATTER, "use_scatter",
+DEF_TUNE (X86_TUNE_USE_SCATTER_8PARTS, "use_scatter_8parts",
          ~(m_ZNVER4))
 
 /* X86_TUNE_AVOID_128FMA_CHAINS: Avoid creating loops with tight 128bit or