Skip to content

Commit 934e050

Browse files
committed
[PowerPC][CodeGen] Expand ISD::AssertNoFPClass for ppc_fp128
780054d added support for `ISD::AssertNoFPClass`. This ISD node can be used with the `ppc_fp128` type, which is really just two `f64s` and requires expanding when used with `ISD::AssertNoFPClass`. Without the support for expanding the result, we get an assertion because the legalizer does not know how to expand the results of `ppc_fp128` with `ISD::AssertNoFPClass`. ``` ExpandFloatResult #0: t7: ppcf128 = AssertNoFPClass t5, TargetConstant:i32<3> LLVM ERROR: Do not know how to expand the result of this operator! ``` Thus, this patch aims to add support for the expand so we no longer assert. This fixes #151375.
1 parent 81b576e commit 934e050

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,7 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
15511551
case ISD::VAARG: ExpandRes_VAARG(N, Lo, Hi); break;
15521552

15531553
case ISD::ConstantFP: ExpandFloatRes_ConstantFP(N, Lo, Hi); break;
1554+
case ISD::AssertNoFPClass: ExpandFloatRes_AssertNoFPClass(N, Lo, Hi); break;
15541555
case ISD::FABS: ExpandFloatRes_FABS(N, Lo, Hi); break;
15551556
case ISD::STRICT_FMINNUM:
15561557
case ISD::FMINNUM: ExpandFloatRes_FMINNUM(N, Lo, Hi); break;
@@ -1966,6 +1967,14 @@ void DAGTypeLegalizer::ExpandFloatRes_FNEG(SDNode *N, SDValue &Lo,
19661967
Hi = DAG.getNode(ISD::FNEG, dl, Hi.getValueType(), Hi);
19671968
}
19681969

1970+
void DAGTypeLegalizer::ExpandFloatRes_AssertNoFPClass(SDNode *N, SDValue &Lo,
1971+
SDValue &Hi) {
1972+
SDLoc dl(N);
1973+
GetExpandedFloat(N->getOperand(0), Lo, Hi);
1974+
Lo = DAG.getNode(ISD::AssertNoFPClass, dl, Lo.getValueType(), Lo);
1975+
Hi = DAG.getNode(ISD::AssertNoFPClass, dl, Hi.getValueType(), Hi);
1976+
}
1977+
19691978
void DAGTypeLegalizer::ExpandFloatRes_FP_EXTEND(SDNode *N, SDValue &Lo,
19701979
SDValue &Hi) {
19711980
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
681681
SDNode *N, RTLIB::Libcall LC, std::optional<unsigned> CallRetResNo = {});
682682

683683
// clang-format off
684+
void ExpandFloatRes_AssertNoFPClass(SDNode *N, SDValue &Lo, SDValue &Hi);
684685
void ExpandFloatRes_FABS (SDNode *N, SDValue &Lo, SDValue &Hi);
685686
void ExpandFloatRes_FACOS (SDNode *N, SDValue &Lo, SDValue &Hi);
686687
void ExpandFloatRes_FASIN (SDNode *N, SDValue &Lo, SDValue &Hi);
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu < %s \
3+
; RUN: | FileCheck %s
4+
; RUN: llc -verify-machineinstrs -mtriple=powerpc64-ibm-aix-xcoff < %s \
5+
; RUN: | FileCheck %s
6+
7+
define ppc_fp128 @f(ppc_fp128 nofpclass(nan) %s) {
8+
; CHECK-LABEL: f:
9+
; CHECK: # %bb.0: # %entry
10+
; CHECK-NEXT: blr
11+
entry:
12+
ret ppc_fp128 %s
13+
}

0 commit comments

Comments
 (0)