]> 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, 22 Apr 2025 12:51:03 +0000 (14:51 +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.

(cherry picked from commit ae2912748b9913fe9cd198db1b3fa704d0cbc728)

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 73ba6246760000099bd77ef43aca5dcccbac418e..150ce9825b48ce5b2ff3ff7d1939e94067e5beff 100644 (file)
@@ -1467,11 +1467,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 81dd217ab7270a68c10aee1ab79f2b1ddffbd32b..cd459878b83e4585f60f077b24348273ff091a04 100644 (file)
@@ -1266,6 +1266,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");
+}
+