Skip to content

Commit 102edae

Browse files
committed
Use seperate function for assertnofpclass
1 parent 3357e28 commit 102edae

File tree

3 files changed

+46
-23
lines changed

3 files changed

+46
-23
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2577,13 +2577,13 @@ bool DAGTypeLegalizer::PromoteFloatOperand(SDNode *N, unsigned OpNo) {
25772577
R = PromoteFloatOp_FAKE_USE(N, OpNo);
25782578
break;
25792579
case ISD::FCOPYSIGN: R = PromoteFloatOp_FCOPYSIGN(N, OpNo); break;
2580-
case ISD::AssertNoFPClass:
25812580
case ISD::FP_TO_SINT:
25822581
case ISD::FP_TO_UINT:
25832582
case ISD::LROUND:
25842583
case ISD::LLROUND:
25852584
case ISD::LRINT:
25862585
case ISD::LLRINT: R = PromoteFloatOp_UnaryOp(N, OpNo); break;
2586+
case ISD::AssertNoFPClass: R = PromoteFloatOp_UnaryOpExt1(N, OpNo); break;
25872587
case ISD::FP_TO_SINT_SAT:
25882588
case ISD::FP_TO_UINT_SAT:
25892589
R = PromoteFloatOp_FP_TO_XINT_SAT(N, OpNo); break;
@@ -2646,6 +2646,13 @@ SDValue DAGTypeLegalizer::PromoteFloatOp_UnaryOp(SDNode *N, unsigned OpNo) {
26462646
return DAG.getNode(N->getOpcode(), SDLoc(N), N->getValueType(0), Op);
26472647
}
26482648

2649+
// Convert the promoted float value to the desired integer type
2650+
SDValue DAGTypeLegalizer::PromoteFloatOp_UnaryOpExt1(SDNode *N, unsigned OpNo) {
2651+
SDValue Op = GetPromotedFloat(N->getOperand(0));
2652+
return DAG.getNode(N->getOpcode(), SDLoc(N), N->getValueType(0), Op,
2653+
N->getOperand(1));
2654+
}
2655+
26492656
SDValue DAGTypeLegalizer::PromoteFloatOp_FP_TO_XINT_SAT(SDNode *N,
26502657
unsigned OpNo) {
26512658
SDValue Op = GetPromotedFloat(N->getOperand(0));
@@ -2809,8 +2816,10 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
28092816
case ISD::FTRUNC:
28102817
case ISD::FTAN:
28112818
case ISD::FTANH:
2812-
case ISD::AssertNoFPClass:
28132819
case ISD::FCANONICALIZE: R = PromoteFloatRes_UnaryOp(N); break;
2820+
case ISD::AssertNoFPClass:
2821+
R = PromoteFloatRes_UnaryOpExt1(N);
2822+
break;
28142823

28152824
// Binary FP Operations
28162825
case ISD::FADD:
@@ -3003,12 +3012,18 @@ SDValue DAGTypeLegalizer::PromoteFloatRes_UnaryOp(SDNode *N) {
30033012
EVT VT = N->getValueType(0);
30043013
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
30053014
SDValue Op = GetPromotedFloat(N->getOperand(0));
3006-
if (N->getOpcode() == ISD::AssertNoFPClass)
3007-
return DAG.getNode(N->getOpcode(), SDLoc(N), NVT, Op, N->getOperand(1));
3008-
else
3009-
return DAG.getNode(N->getOpcode(), SDLoc(N), NVT, Op);
3015+
return DAG.getNode(N->getOpcode(), SDLoc(N), NVT, Op);
30103016
}
30113017

3018+
// Unary operation with a more non-float operand where the result and the
3019+
// operand have PromoteFloat type action. Construct a new SDNode with the
3020+
// promoted float value of the old operand.
3021+
SDValue DAGTypeLegalizer::PromoteFloatRes_UnaryOpExt1(SDNode *N) {
3022+
EVT VT = N->getValueType(0);
3023+
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
3024+
SDValue Op = GetPromotedFloat(N->getOperand(0));
3025+
return DAG.getNode(N->getOpcode(), SDLoc(N), NVT, Op, N->getOperand(1));
3026+
}
30123027
// Binary operations where the result and both operands have PromoteFloat type
30133028
// action. Construct a new SDNode with the promoted float values of the old
30143029
// operands.
@@ -3251,8 +3266,6 @@ void DAGTypeLegalizer::SoftPromoteHalfResult(SDNode *N, unsigned ResNo) {
32513266
report_fatal_error("Do not know how to soft promote this operator's "
32523267
"result!");
32533268

3254-
// case ISD::AssertNoFPClass:
3255-
// break;
32563269
case ISD::ARITH_FENCE:
32573270
R = SoftPromoteHalfRes_ARITH_FENCE(N); break;
32583271
case ISD::BITCAST: R = SoftPromoteHalfRes_BITCAST(N); break;
@@ -3613,11 +3626,7 @@ SDValue DAGTypeLegalizer::SoftPromoteHalfRes_UnaryOp(SDNode *N) {
36133626
// Promote to the larger FP type.
36143627
Op = DAG.getNode(GetPromotionOpcode(OVT, NVT), dl, NVT, Op);
36153628

3616-
SDValue Res;
3617-
if (N->getOpcode() == ISD::AssertNoFPClass)
3618-
Res = DAG.getNode(N->getOpcode(), dl, NVT, Op, N->getOperand(1));
3619-
else
3620-
Res = DAG.getNode(N->getOpcode(), dl, NVT, Op);
3629+
SDValue Res = DAG.getNode(N->getOpcode(), dl, NVT, Op, N->getOperand(1));
36213630

36223631
// Convert back to FP16 as an integer.
36233632
return DAG.getNode(GetPromotionOpcode(NVT, OVT), dl, MVT::i16, Res);

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
774774
SDValue PromoteFloatRes_SELECT(SDNode *N);
775775
SDValue PromoteFloatRes_SELECT_CC(SDNode *N);
776776
SDValue PromoteFloatRes_UnaryOp(SDNode *N);
777+
SDValue PromoteFloatRes_UnaryOpExt1(SDNode *N);
777778
SDValue PromoteFloatRes_UNDEF(SDNode *N);
778779
SDValue BitcastToInt_ATOMIC_SWAP(SDNode *N);
779780
SDValue PromoteFloatRes_XINT_TO_FP(SDNode *N);
@@ -787,6 +788,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
787788
SDValue PromoteFloatOp_FP_EXTEND(SDNode *N, unsigned OpNo);
788789
SDValue PromoteFloatOp_STRICT_FP_EXTEND(SDNode *N, unsigned OpNo);
789790
SDValue PromoteFloatOp_UnaryOp(SDNode *N, unsigned OpNo);
791+
SDValue PromoteFloatOp_UnaryOpExt1(SDNode *N, unsigned OpNo);
790792
SDValue PromoteFloatOp_FP_TO_XINT_SAT(SDNode *N, unsigned OpNo);
791793
SDValue PromoteFloatOp_STORE(SDNode *N, unsigned OpNo);
792794
SDValue PromoteFloatOp_ATOMIC_STORE(SDNode *N, unsigned OpNo);

llvm/test/CodeGen/ARM/nofpclass.ll

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2-
; RUN: llc -mtriple=armv8-unknown-none-eabi < %s | FileCheck %s
2+
; RUN: llc -mtriple=armv8-unknown-none-eabi < %s | FileCheck %s --check-prefixes=CHECK,HARD
3+
; RUN: llc -mtriple=armv8-unknown-none-eabi -mattr=+soft-float < %s | FileCheck %s --check-prefixes=CHECK,SOFT
34

45
define nofpclass(nan inf) half @f1(half returned nofpclass(nan inf) %x) {
56
; CHECK-LABEL: f1:
@@ -10,15 +11,26 @@ entry:
1011
}
1112

1213
define noundef half @f2(half nofpclass(nan) %a) {
13-
; CHECK-LABEL: f2:
14-
; CHECK: @ %bb.0: @ %entry
15-
; CHECK-NEXT: vmov.f32 s0, #1.000000e+00
16-
; CHECK-NEXT: vmov s2, r0
17-
; CHECK-NEXT: vcvtb.f32.f16 s2, s2
18-
; CHECK-NEXT: vadd.f32 s0, s2, s0
19-
; CHECK-NEXT: vcvtb.f16.f32 s0, s0
20-
; CHECK-NEXT: vmov r0, s0
21-
; CHECK-NEXT: bx lr
14+
; HARD-LABEL: f2:
15+
; HARD: @ %bb.0: @ %entry
16+
; HARD-NEXT: vmov.f32 s0, #1.000000e+00
17+
; HARD-NEXT: vmov s2, r0
18+
; HARD-NEXT: vcvtb.f32.f16 s2, s2
19+
; HARD-NEXT: vadd.f32 s0, s2, s0
20+
; HARD-NEXT: vcvtb.f16.f32 s0, s0
21+
; HARD-NEXT: vmov r0, s0
22+
; HARD-NEXT: bx lr
23+
;
24+
; SOFT-LABEL: f2:
25+
; SOFT: @ %bb.0: @ %entry
26+
; SOFT-NEXT: .save {r11, lr}
27+
; SOFT-NEXT: push {r11, lr}
28+
; SOFT-NEXT: uxth r0, r0
29+
; SOFT-NEXT: bl __aeabi_h2f
30+
; SOFT-NEXT: mov r1, #1065353216
31+
; SOFT-NEXT: bl __aeabi_fadd
32+
; SOFT-NEXT: bl __aeabi_f2h
33+
; SOFT-NEXT: pop {r11, pc}
2234
entry:
2335
%0 = fadd half %a, 0xH3C00
2436
ret half %0

0 commit comments

Comments
 (0)