[clang] [llvm] [Mips] Set _MIPS_SPFPSET to 16 before MIPS32 with 32-bit FPRs (PR #246579)

Alex Rønne Petersen via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 27 02:31:03 PST 2026


================
@@ -253,10 +253,16 @@ MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS,
 
   // Before MIPS32, single-precision arithmetic can only use the even FPRs
   // when the FPRs are 32 bits wide. The odd FPRs only hold the upper half of
-  // a double. A single-float FPU such as the R5900 has 32 single-precision
-  // FPRs.
-  if (isABI_O32() && !IsSoftFloat && !IsSingleFloat && hasMips1() &&
-      !hasMips32() && !isFP64bit())
+  // a double. The R5900 has 32 single-precision FPRs. Like GCC, an explicit
+  // -nooddspreg (-modd-spreg in Clang) still allows them.
+  bool OddSPRegGiven = false;
+  for (StringRef Feature : llvm::split(FS, ','))
+    if (Feature == "-nooddspreg")
+      OddSPRegGiven = true;
+    else if (Feature == "+nooddspreg")
+      OddSPRegGiven = false;
+  if (isABI_O32() && !IsSoftFloat && !IsR5900 && hasMips1() && !hasMips32() &&
----------------
alexrp wrote:

Minor point but the `!IsSoftFloat` check needs to go to match GCC.

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


More information about the cfe-commits mailing list