https://gcc.gnu.org/g:d78bd76a49fb900db937d1bbabee7c5cb41ff4ba

commit r16-4285-gd78bd76a49fb900db937d1bbabee7c5cb41ff4ba
Author: Alfie Richards <[email protected]>
Date:   Tue Oct 7 09:34:48 2025 +0000

    c: Fix i386 target attribute regression [PR 122180]
    
    My patch (r16-4182-g73888cefe6da65) broke another target (i386), which this
    patch fixes.
    
    The issue was the target_version code was incorrectly being triggered on
    targets that do not support target_version semantics (i386).
    
            PR target/122180
    
    gcc/c/ChangeLog:
    
            * c-decl.cc (pushdecl): Add TARGET_HAS_FMV_TARGET_ATTRIBUTE check.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/pr122180.c: New test.

Diff:
---
 gcc/c/c-decl.cc                          | 7 +++++--
 gcc/testsuite/gcc.target/i386/pr122180.c | 7 +++++++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index d0dc5eeda39b..4a940d5eec33 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -3414,8 +3414,11 @@ pushdecl (tree x)
            }
        }
 
-      /* Check if x is part of a FMV set with b_use.  */
-      if (b_use && TREE_CODE (b_use->decl) == FUNCTION_DECL
+      /* Check if x is part of a FMV set with b_use.
+        FMV is only supported in c for targets with target_version
+        attributes.  */
+      if (!TARGET_HAS_FMV_TARGET_ATTRIBUTE
+         && b_use && TREE_CODE (b_use->decl) == FUNCTION_DECL
          && TREE_CODE (x) == FUNCTION_DECL && DECL_FILE_SCOPE_P (b_use->decl)
          && DECL_FILE_SCOPE_P (x)
          && disjoint_version_decls (x, b_use->decl)
diff --git a/gcc/testsuite/gcc.target/i386/pr122180.c 
b/gcc/testsuite/gcc.target/i386/pr122180.c
new file mode 100644
index 000000000000..6153d6c4c710
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr122180.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+
+static void s() __attribute__((target("avx")));
+static void s() { }
+void f() {
+        s();
+}

Reply via email to