]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
target/119549 - fixup handling of -mno-sse4 in target attribute
authorRichard Biener <rguenther@suse.de>
Mon, 31 Mar 2025 12:56:25 +0000 (14:56 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 1 Apr 2025 08:31:21 +0000 (10:31 +0200)
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.

gcc/common/config/i386/i386-common.cc
gcc/config/i386/i386-options.cc
gcc/testsuite/gcc.target/i386/pr119549.c [new file with mode: 0644]

index 80aec3244bc3b86f6fe6f67415a0fdd534356943..4815fbc4d3593c60585fdcc4ec90aeda025f848a 100644 (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;
index 91f59e16fd5c0490bb2f9777a113b2d52510aab9..a9fac011f3d2b1b0481fd6028bc62752c6fa4e1b 100644 (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)
        {
diff --git a/gcc/testsuite/gcc.target/i386/pr119549.c b/gcc/testsuite/gcc.target/i386/pr119549.c
new file mode 100644 (file)
index 0000000..a465bec
--- /dev/null
@@ -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");
+}
+