Skip to content

Commit 7e3e7a8

Browse files
committed
CodeGen: Add ISD::AssertNoFPClass
It is used to mark a value that we are sure that it is not some fcType. The examples include: * An arguments of a function is marked with nofpclass * Output value of an intrinsic can be sure to not be some type So that the following operation can make some assumptions.
1 parent 1cf9f76 commit 7e3e7a8

File tree

7 files changed

+19
-0
lines changed

7 files changed

+19
-0
lines changed

llvm/include/llvm/CodeGen/ISDOpcodes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ enum NodeType {
6767
/// poisoned the assertion will not be true for that value.
6868
AssertAlign,
6969

70+
/// AssertNoFPClass - These nodes record if a register contains a float
71+
/// value that is known to be not some type.
72+
/// NOTE: In case of the source value (or any vector element value) is
73+
/// poisoned the assertion will not be true for that value.
74+
AssertNoFPClass,
75+
7076
/// Various leaf nodes.
7177
BasicBlock,
7278
VALUETYPE,

llvm/include/llvm/Target/TargetSelectionDAG.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ def SDT_assert : SDTypeProfile<1, 1,
859859
[SDTCisInt<0>, SDTCisInt<1>, SDTCisSameAs<1, 0>]>;
860860
def assertsext : SDNode<"ISD::AssertSext", SDT_assert>;
861861
def assertzext : SDNode<"ISD::AssertZext", SDT_assert>;
862+
def assernofpclass : SDNode<"ISD::AssertNoFPClass", SDTFPUnaryOp>;
862863
def assertalign : SDNode<"ISD::AssertAlign", SDT_assert>;
863864

864865
def convergencectrl_anchor : SDNode<"ISD::CONVERGENCECTRL_ANCHOR",

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
168168
case ISD::POISON:
169169
case ISD::UNDEF: R = SoftenFloatRes_UNDEF(N); break;
170170
case ISD::VAARG: R = SoftenFloatRes_VAARG(N); break;
171+
case ISD::AssertNoFPClass: R = GetSoftenedFloat(N->getOperand(0)); break;
171172
case ISD::VECREDUCE_FADD:
172173
case ISD::VECREDUCE_FMUL:
173174
case ISD::VECREDUCE_FMIN:
@@ -2576,6 +2577,7 @@ bool DAGTypeLegalizer::PromoteFloatOperand(SDNode *N, unsigned OpNo) {
25762577
R = PromoteFloatOp_FAKE_USE(N, OpNo);
25772578
break;
25782579
case ISD::FCOPYSIGN: R = PromoteFloatOp_FCOPYSIGN(N, OpNo); break;
2580+
case ISD::AssertNoFPClass:
25792581
case ISD::FP_TO_SINT:
25802582
case ISD::FP_TO_UINT:
25812583
case ISD::LROUND:
@@ -2803,6 +2805,7 @@ void DAGTypeLegalizer::PromoteFloatResult(SDNode *N, unsigned ResNo) {
28032805
case ISD::FTRUNC:
28042806
case ISD::FTAN:
28052807
case ISD::FTANH:
2808+
case ISD::AssertNoFPClass:
28062809
case ISD::FCANONICALIZE: R = PromoteFloatRes_UnaryOp(N); break;
28072810

28082811
// Binary FP Operations

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
129129
case ISD::UINT_TO_FP:
130130
case ISD::ZERO_EXTEND:
131131
case ISD::FCANONICALIZE:
132+
case ISD::AssertNoFPClass:
132133
R = ScalarizeVecRes_UnaryOp(N);
133134
break;
134135
case ISD::ADDRSPACECAST:
@@ -1278,6 +1279,7 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) {
12781279
case ISD::UINT_TO_FP:
12791280
case ISD::VP_UINT_TO_FP:
12801281
case ISD::FCANONICALIZE:
1282+
case ISD::AssertNoFPClass:
12811283
SplitVecRes_UnaryOp(N, Lo, Hi);
12821284
break;
12831285
case ISD::ADDRSPACECAST:
@@ -4846,6 +4848,7 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
48464848
case ISD::FREEZE:
48474849
case ISD::ARITH_FENCE:
48484850
case ISD::FCANONICALIZE:
4851+
case ISD::AssertNoFPClass:
48494852
Res = WidenVecRes_Unary(N);
48504853
break;
48514854
case ISD::FMA: case ISD::VP_FMA:

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7365,6 +7365,10 @@ SDValue SelectionDAG::getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
73657365
N2.getOpcode() == ISD::TargetConstant && "Invalid FP_ROUND!");
73667366
if (N1.getValueType() == VT) return N1; // noop conversion.
73677367
break;
7368+
case ISD::AssertNoFPClass:
7369+
assert(N1.getValueType().isFloatingPoint() &&
7370+
"AssertNoFPClass is used for a non-floating type");
7371+
return N1;
73687372
case ISD::AssertSext:
73697373
case ISD::AssertZext: {
73707374
EVT EVT = cast<VTSDNode>(N2)->getVT();

llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {
122122
case ISD::TokenFactor: return "TokenFactor";
123123
case ISD::AssertSext: return "AssertSext";
124124
case ISD::AssertZext: return "AssertZext";
125+
case ISD::AssertNoFPClass: return "AssertNoFPClass";
125126
case ISD::AssertAlign: return "AssertAlign";
126127

127128
case ISD::BasicBlock: return "BasicBlock";

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3265,6 +3265,7 @@ void SelectionDAGISel::SelectCodeCommon(SDNode *NodeToMatch,
32653265
return;
32663266
case ISD::AssertSext:
32673267
case ISD::AssertZext:
3268+
case ISD::AssertNoFPClass:
32683269
case ISD::AssertAlign:
32693270
ReplaceUses(SDValue(NodeToMatch, 0), NodeToMatch->getOperand(0));
32703271
CurDAG->RemoveDeadNode(NodeToMatch);

0 commit comments

Comments
 (0)