[clang] [clang][Sparc] Fix -mfsmuld and -mno-fsmuld (PR #248766)

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 3 19:23:31 PST 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-sparc

Author: Brad Smith (brad0)

<details>
<summary>Changes</summary>

The backend has a no-fsmuld feature, not fsmuld, so passing +fsmuld or
-fsmuld did nothing and -mno-fsmuld still used fsmuld. Pass -no-fsmuld
and +no-fsmuld instead.

Assisted-by: Claude Opus 5.5

---
Full diff: https://github.com/llvm/llvm-project/pull/248766.diff


2 Files Affected:

- (modified) clang/lib/Driver/ToolChains/Arch/Sparc.cpp (+3-2) 
- (modified) clang/test/Driver/sparc-target-features.c (+2-2) 


``````````diff
diff --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index c24fd2df4609ba..aa50a647c9af8b 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -179,11 +179,12 @@ void sparc::getSparcTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   if (FloatABI == sparc::FloatABI::Soft)
     Features.push_back("+soft-float");
 
+  // The backend feature is the negative no-fsmuld.
   if (Arg *A = Args.getLastArg(options::OPT_mfsmuld, options::OPT_mno_fsmuld)) {
     if (A->getOption().matches(options::OPT_mfsmuld))
-      Features.push_back("+fsmuld");
+      Features.push_back("-no-fsmuld");
     else
-      Features.push_back("-fsmuld");
+      Features.push_back("+no-fsmuld");
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_mpopc, options::OPT_mno_popc)) {
diff --git a/clang/test/Driver/sparc-target-features.c b/clang/test/Driver/sparc-target-features.c
index bd17da112bbd28..dbe0889e85a9aa 100644
--- a/clang/test/Driver/sparc-target-features.c
+++ b/clang/test/Driver/sparc-target-features.c
@@ -5,8 +5,8 @@
 
 // RUN: %clang --target=sparc -mfsmuld %s -### 2>&1 | FileCheck -check-prefix=FSMULD %s
 // RUN: %clang --target=sparc -mno-fsmuld %s -### 2>&1 | FileCheck -check-prefix=NO-FSMULD %s
-// FSMULD: "-target-feature" "+fsmuld"
-// NO-FSMULD: "-target-feature" "-fsmuld"
+// FSMULD: "-target-feature" "-no-fsmuld"
+// NO-FSMULD: "-target-feature" "+no-fsmuld"
 
 // RUN: %clang --target=sparc -mpopc %s -### 2>&1 | FileCheck -check-prefix=POPC %s
 // RUN: %clang --target=sparc -mno-popc %s -### 2>&1 | FileCheck -check-prefix=NO-POPC %s

``````````

</details>


https://github.com/llvm/llvm-project/pull/248766


More information about the cfe-commits mailing list