https://gcc.gnu.org/g:319a956cd25ccc05c9447d55d76f0c98e8f6b598
commit r16-5641-g319a956cd25ccc05c9447d55d76f0c98e8f6b598 Author: liuhongt <[email protected]> Date: Mon Nov 24 21:33:46 2025 -0800 Refactor mgather/mscatter implementation. Current implementation is an alias to -mtune-crtl=(Alias(mtune-ctrl=, use_gather, ^use_gather)), and maybe override by another -mtune-crtl= .i.e -mgather -mscatter will only enable mscatter The patch fixes the issue. gcc/ChangeLog: * config/i386/i386-options.cc (set_ix86_tune_features): Set gather/scatter tune if OPTION_SET_P. * config/i386/i386.opt: Refactor mgather/mscatter. Diff: --- gcc/config/i386/i386-options.cc | 15 +++++++++++++++ gcc/config/i386/i386.opt | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index ba598a817f30..35064d83a007 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -1837,6 +1837,21 @@ set_ix86_tune_features (struct gcc_options *opts, } parse_mtune_ctrl_str (opts, dump); + + /* mgather/mscatter option would overwrite -mtune-crtl option. */ + if (OPTION_SET_P (ix86_use_gather)) + { + ix86_tune_features[X86_TUNE_USE_GATHER_2PARTS] = ix86_use_gather; + ix86_tune_features[X86_TUNE_USE_GATHER_4PARTS] = ix86_use_gather; + ix86_tune_features[X86_TUNE_USE_GATHER_8PARTS] = ix86_use_gather; + } + + if (OPTION_SET_P (ix86_use_scatter)) + { + ix86_tune_features[X86_TUNE_USE_SCATTER_2PARTS] = ix86_use_scatter; + ix86_tune_features[X86_TUNE_USE_SCATTER_4PARTS] = ix86_use_scatter; + ix86_tune_features[X86_TUNE_USE_SCATTER_8PARTS] = ix86_use_scatter; + } } diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 844945023451..c0093ef12436 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -1290,11 +1290,11 @@ 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) +Target Var(ix86_use_gather) Init(0) Optimization. Enable vectorization for gather instruction. mscatter -Target Alias(mtune-ctrl=, use_scatter, ^use_scatter) +Target Var(ix86_use_scatter) Init(0) Optimization Enable vectorization for scatter instruction. mapxf
