Skip to content

Fix fp128 reaching llvm_unreachable on 32-bit PowerPC - #216613

Merged
folkertdev merged 1 commit into
llvm:mainfrom
beetrees:fix-fp128-powerpc32
Sep 1, 2026
Merged

folkertdev merged 1 commit into
llvm:mainfrom
beetrees:fix-fp128-powerpc32

Conversation

@beetrees

Copy link
Copy Markdown
Contributor

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

@llvmorg-github-actions

Copy link
Copy Markdown

@llvm/pr-subscribers-backend-powerpc

Author: beetrees

Changes

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 --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
+}

@RolandF77 RolandF77 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@folkertdev
folkertdev merged commit 8d1b38f into llvm:main Sep 1, 2026
14 checks passed
@folkertdev

Copy link
Copy Markdown
Contributor

I guess I'll just ask: could this be backported? The blast radius is non-existent, and having this work one LLVM major version earlier would be convenient for Rust.

@beetrees
beetrees deleted the fix-fp128-powerpc32 branch September 2, 2026 13:22
Iasonaskrpr pushed a commit to Iasonaskrpr/llvm-project that referenced this pull request Sep 4, 2026
`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 llvm#213355

cc @folkertdev
asudarsa-qti pushed a commit to asudarsa-qti/llvm-project that referenced this pull request Sep 4, 2026
`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 llvm#213355

cc @folkertdev
addmisol pushed a commit to addmisol/llvm-project2 that referenced this pull request Sep 6, 2026
`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 llvm#213355

cc @folkertdev
@folkertdev

Copy link
Copy Markdown
Contributor

Just hit this during development again, so it would be convenient to backport

/cherry-pick 8d1b38f

@llvmbot

llvmbot commented Sep 18, 2026

Copy link
Copy Markdown
Member

/cherry-pick 8d1b38f

Error: Command failed due to missing milestone.

@folkertdev

Copy link
Copy Markdown
Contributor

/cherry-pick 8d1b38f

@llvmbot

llvmbot commented Sep 18, 2026

Copy link
Copy Markdown
Member

/pull-request #224574

Zalathar added a commit to Zalathar/rust that referenced this pull request Sep 19, 2026
…rees

mark `f128` as reliable on `powerpc64` with `+vsx`

This feature is only enabled by default for powerpc64le, and not enabled on the big-endian targets. Even with vsx, the default long double is ppcf128 on the big-endian targets, so LLVM calls the incorrect libcall. Also some libcalls just don't exist.

I tested this with and without `rustflags = ["-C", "target-feature=+vsx"]` in the `bootstrap.toml`:

```
./x.py test library/core --target powerpc64-unknown-linux-gnu
./x.py test library/core --target powerpc64le-unknown-linux-gnu
```

These all hit one failure, in the docs test for `library/core/src/keyword_docs.rs` where `become` is used: powerpc does not support guaranteed tail calls. Anyway, that is not relevant for f128 support.

Sadly `powerpc-unknown-linux-gnu` with `+vsx` hits the issue fixed in llvm/llvm-project#216613, I've requested a backport for the fix.

r? beetrees or @tgross35
cc @Gelbpunkt
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 19, 2026
…rees

mark `f128` as reliable on `powerpc64` with `+vsx`

This feature is only enabled by default for powerpc64le, and not enabled on the big-endian targets. Even with vsx, the default long double is ppcf128 on the big-endian targets, so LLVM calls the incorrect libcall. Also some libcalls just don't exist.

I tested this with and without `rustflags = ["-C", "target-feature=+vsx"]` in the `bootstrap.toml`:

```
./x.py test library/core --target powerpc64-unknown-linux-gnu
./x.py test library/core --target powerpc64le-unknown-linux-gnu
```

These all hit one failure, in the docs test for `library/core/src/keyword_docs.rs` where `become` is used: powerpc does not support guaranteed tail calls. Anyway, that is not relevant for f128 support.

Sadly `powerpc-unknown-linux-gnu` with `+vsx` hits the issue fixed in llvm/llvm-project#216613, I've requested a backport for the fix.

r? beetrees or @tgross35
cc @Gelbpunkt
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Sep 19, 2026
…rees

mark `f128` as reliable on `powerpc64` with `+vsx`

This feature is only enabled by default for powerpc64le, and not enabled on the big-endian targets. Even with vsx, the default long double is ppcf128 on the big-endian targets, so LLVM calls the incorrect libcall. Also some libcalls just don't exist.

I tested this with and without `rustflags = ["-C", "target-feature=+vsx"]` in the `bootstrap.toml`:

```
./x.py test library/core --target powerpc64-unknown-linux-gnu
./x.py test library/core --target powerpc64le-unknown-linux-gnu
```

These all hit one failure, in the docs test for `library/core/src/keyword_docs.rs` where `become` is used: powerpc does not support guaranteed tail calls. Anyway, that is not relevant for f128 support.

Sadly `powerpc-unknown-linux-gnu` with `+vsx` hits the issue fixed in llvm/llvm-project#216613, I've requested a backport for the fix.

r? beetrees or @tgross35
cc @Gelbpunkt
rust-bors Bot pushed a commit to rust-lang/rust that referenced this pull request Sep 19, 2026
Rollup merge of #162979 - folkertdev:ppc-enable-f128, r=beetrees

mark `f128` as reliable on `powerpc64` with `+vsx`

This feature is only enabled by default for powerpc64le, and not enabled on the big-endian targets. Even with vsx, the default long double is ppcf128 on the big-endian targets, so LLVM calls the incorrect libcall. Also some libcalls just don't exist.

I tested this with and without `rustflags = ["-C", "target-feature=+vsx"]` in the `bootstrap.toml`:

```
./x.py test library/core --target powerpc64-unknown-linux-gnu
./x.py test library/core --target powerpc64le-unknown-linux-gnu
```

These all hit one failure, in the docs test for `library/core/src/keyword_docs.rs` where `become` is used: powerpc does not support guaranteed tail calls. Anyway, that is not relevant for f128 support.

Sadly `powerpc-unknown-linux-gnu` with `+vsx` hits the issue fixed in llvm/llvm-project#216613, I've requested a backport for the fix.

r? beetrees or @tgross35
cc @Gelbpunkt
dyung pushed a commit to llvmbot/llvm-project that referenced this pull request Sep 19, 2026
`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 llvm#213355

cc @folkertdev

(cherry picked from commit 8d1b38f)
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 20, 2026
mark `f128` as reliable on `powerpc64` with `+vsx`

This feature is only enabled by default for powerpc64le, and not enabled on the big-endian targets. Even with vsx, the default long double is ppcf128 on the big-endian targets, so LLVM calls the incorrect libcall. Also some libcalls just don't exist.

I tested this with and without `rustflags = ["-C", "target-feature=+vsx"]` in the `bootstrap.toml`:

```
./x.py test library/core --target powerpc64-unknown-linux-gnu
./x.py test library/core --target powerpc64le-unknown-linux-gnu
```

These all hit one failure, in the docs test for `library/core/src/keyword_docs.rs` where `become` is used: powerpc does not support guaranteed tail calls. Anyway, that is not relevant for f128 support.

Sadly `powerpc-unknown-linux-gnu` with `+vsx` hits the issue fixed in llvm/llvm-project#216613, I've requested a backport for the fix.

r? beetrees or @tgross35
cc @Gelbpunkt
github-actions Bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Sep 21, 2026
mark `f128` as reliable on `powerpc64` with `+vsx`

This feature is only enabled by default for powerpc64le, and not enabled on the big-endian targets. Even with vsx, the default long double is ppcf128 on the big-endian targets, so LLVM calls the incorrect libcall. Also some libcalls just don't exist.

I tested this with and without `rustflags = ["-C", "target-feature=+vsx"]` in the `bootstrap.toml`:

```
./x.py test library/core --target powerpc64-unknown-linux-gnu
./x.py test library/core --target powerpc64le-unknown-linux-gnu
```

These all hit one failure, in the docs test for `library/core/src/keyword_docs.rs` where `become` is used: powerpc does not support guaranteed tail calls. Anyway, that is not relevant for f128 support.

Sadly `powerpc-unknown-linux-gnu` with `+vsx` hits the issue fixed in llvm/llvm-project#216613, I've requested a backport for the fix.

r? beetrees or @tgross35
cc @Gelbpunkt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

llvm_unreachable when compiling a function that takes fp128 on 32-bit PowerPC with vsx enabled

4 participants