This is originally from [1] ------------ For the command line, or target attribute, the actual operation goes into ix86_handle_option, and as long as we get it right in this ix86_handle_option, everything else should be fine. As for the macros generated by the mask name (TARGET_SSE4_1_P), their meanings remain the same, so in my opinion they can be handled this way. But to be on the safe side, I agree that it should be adjusted in ix86_valid_target_attribute_inner_p first. In GCC16, we can do a refactor for this. --------------
[1] https://gcc.gnu.org/pipermail/gcc-patches/2025-April/679880.html Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. Ok for trunk? gcc/ChangeLog: PR target/119549 * common/config/i386/i386-common.cc (ix86_handle_option): Refactor msse4 and mno-sse4. * config/i386/i386.opt (msse4): Remove RejectNegative. (mno-sse4): Remove the entry. * config/i386/i386-expand.cc (ix86_valid_target_attribute_inner_p): Remove special code which handles mno-sse4. --- gcc/common/config/i386/i386-common.cc | 23 ++++++++++++----------- gcc/config/i386/i386-options.cc | 7 ------- gcc/config/i386/i386.opt | 6 +----- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc index 4815fbc4d35..296df3b3230 100644 --- a/gcc/common/config/i386/i386-common.cc +++ b/gcc/common/config/i386/i386-common.cc @@ -1519,17 +1519,18 @@ ix86_handle_option (struct gcc_options *opts, return true; case OPT_msse4: - gcc_assert (value != 0); - opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE4_SET; - opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_SET; - return true; - - case OPT_mno_sse4: - gcc_assert (value != 0); - opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE4_UNSET; - opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_UNSET; - opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE4_UNSET; - opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE4_UNSET; + if (value) + { + opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SSE4_SET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_SET; + } + else + { + opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_SSE4_UNSET; + opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_SSE4_UNSET; + opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_SSE4_UNSET; + opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_SSE4_UNSET; + } return true; case OPT_msse4a: diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc index 964449fa8cd..45aa9b4b732 100644 --- a/gcc/config/i386/i386-options.cc +++ b/gcc/config/i386/i386-options.cc @@ -1271,13 +1271,6 @@ ix86_valid_target_attribute_inner_p (tree fndecl, tree args, char *p_strings[], } } - /* Fixup -msse4 which is RejectNegative to -mno-sse4 when negated. */ - if (opt == OPT_msse4 && !opt_set_p) - { - opt = OPT_mno_sse4; - opt_set_p = true; - } - /* Process the option. */ if (opt == N_OPTS) { diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 27d34bd64ea..0abf13480f5 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -721,13 +721,9 @@ Target Mask(ISA_SSE4_2) Var(ix86_isa_flags) Save Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1 and SSE4.2 built-in functions and code generation. msse4 -Target RejectNegative Mask(ISA_SSE4_2) Var(ix86_isa_flags) Save +Target Mask(ISA_SSE4_2) Var(ix86_isa_flags) Save Support MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1 and SSE4.2 built-in functions and code generation. -mno-sse4 -Target RejectNegative InverseMask(ISA_SSE4_1) Var(ix86_isa_flags) Save -Do not support SSE4.1 and SSE4.2 built-in functions and code generation. - msse5 Target Undocumented Alias(mavx) Warn(%<-msse5%> was removed) ;; Deprecated -- 2.34.1