target/119549 - fixup handling of -mno-sse4 in target attribute

The following fixes ix86_valid_target_attribute_inner_p to properly
handle target("no-sse4") via OPT_mno_sse4 rather than as unset OPT_msse4.
I've added asserts to ix86_handle_option that RejectNegative is honored
for both.

	PR target/119549
	* common/config/i386/i386-common.cc (ix86_handle_option):
	Assert that both OPT_msse4 and OPT_mno_sse4 are never unset.
	* config/i386/i386-options.cc (ix86_valid_target_attribute_inner_p):
	Process negated OPT_msse4 as OPT_mno_sse4.

	* gcc.target/i386/pr119549.c: New testcase.
This commit is contained in:
Richard Biener 2025-03-31 14:56:25 +02:00 committed by Richard Biener
parent de92ac6f11
commit ae2912748b
3 changed files with 24 additions and 0 deletions

View file

@ -1519,11 +1519,13 @@ 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;

View file

@ -1271,6 +1271,13 @@ 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)
{

View file

@ -0,0 +1,15 @@
/* { dg-do compile } */
/* { dg-options "-msse4" } */
typedef long long v2di __attribute__((vector_size(16)));
static inline __attribute__((always_inline))
int rte_trace_feature_is_enabled() { return 1; } /* { dg-error "inlining failed" } */
void __attribute__((target ("no-sse3"))) __attribute__((target ("no-sse4")))
rte_eal_trace_generic_void_init(void)
{
if (!rte_trace_feature_is_enabled()) return;
__asm__ volatile ("" : : : "memory");
}