[llvm] Fix `fp128` reaching `llvm_unreachable` on 32-bit PowerPC (PR #216613)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 15:51:22 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-powerpc

Author: beetrees

<details>
<summary>Changes</summary>

`fp128` is a legal type that is passed in vector registers when `vsx` is enabled on 32-bit PowerPC: the switch statement didn't account for that, causing an LLVM assertion.

Fixes #<!-- -->213355

cc @<!-- -->folkertdev

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


2 Files Affected:

- (modified) llvm/lib/Target/PowerPC/PPCISelLowering.cpp (+1-4) 
- (added) llvm/test/CodeGen/PowerPC/ppc32-f128-abi.ll (+9) 


``````````diff
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
index d599bba54079b..66f58106c9d9d 100644
--- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -4281,13 +4281,10 @@ SDValue PPCTargetLowering::LowerFormalArguments_32SVR4(
         case MVT::v16i8:
         case MVT::v8i16:
         case MVT::v4i32:
-          RC = &PPC::VRRCRegClass;
-          break;
         case MVT::v4f32:
-          RC = &PPC::VRRCRegClass;
-          break;
         case MVT::v2f64:
         case MVT::v2i64:
+        case MVT::f128:
           RC = &PPC::VRRCRegClass;
           break;
       }
diff --git a/llvm/test/CodeGen/PowerPC/ppc32-f128-abi.ll b/llvm/test/CodeGen/PowerPC/ppc32-f128-abi.ll
new file mode 100644
index 0000000000000..967c39e551718
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/ppc32-f128-abi.ll
@@ -0,0 +1,9 @@
+; RUN: llc -verify-machineinstrs -mattr=+vsx < %s | FileCheck %s
+target triple = "powerpc-unknown-linux-gnu"
+
+; CHECK-LABEL: return_second:
+; CHECK: vmr 2, 3
+; CHECK-NEXT: blr
+define fp128 @return_second(fp128, fp128) {
+    ret fp128 %1
+}

``````````

</details>


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


More information about the llvm-commits mailing list