Skip to content

Commit 63cc2e3

Browse files
authored
[PowerPC][CodeGen] Expand ISD::AssertNoFPClass for ppc_fp128 (#152357)
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 ddd4974 commit 63cc2e3

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 8 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,13 @@ 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+
// TODO: Handle ppcf128 by preserving AssertNoFPClass for one of the halves.
1973+
SDLoc dl(N);
1974+
GetExpandedFloat(N->getOperand(0), Lo, Hi);
1975+
}
1976+
19691977
void DAGTypeLegalizer::ExpandFloatRes_FP_EXTEND(SDNode *N, SDValue &Lo,
19701978
SDValue &Hi) {
19711979
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: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
3+
; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff < %s | FileCheck %s
4+
5+
; TODO: Update this test after adding the proper expansion of nofpclass for
6+
; ppc_fp128 to test with more masks and to demonstrate preserving nofpclass
7+
; after legalization.
8+
9+
define ppc_fp128 @f(ppc_fp128 nofpclass(nan) %s) {
10+
; CHECK-LABEL: f:
11+
; CHECK: # %bb.0: # %entry
12+
; CHECK-NEXT: blr
13+
entry:
14+
ret ppc_fp128 %s
15+
}

0 commit comments

Comments
 (0)