Skip to content

Commit 16fc3b1

Browse files
RKSimonKornevNikita
authored andcommitted
[DAG] VectorLegalizer::ExpandUINT_TO_FLOAT- pull out repeated getValueType calls. NFC.
1 parent af73b4a commit 16fc3b1

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,8 @@ void VectorLegalizer::ExpandUINT_TO_FLOAT(SDNode *Node,
17331733
bool IsStrict = Node->isStrictFPOpcode();
17341734
unsigned OpNo = IsStrict ? 1 : 0;
17351735
SDValue Src = Node->getOperand(OpNo);
1736-
EVT VT = Src.getValueType();
1736+
EVT SrcVT = Src.getValueType();
1737+
EVT DstVT = Node->getValueType(0);
17371738
SDLoc DL(Node);
17381739

17391740
// Attempt to expand using TargetLowering.
@@ -1747,11 +1748,11 @@ void VectorLegalizer::ExpandUINT_TO_FLOAT(SDNode *Node,
17471748
}
17481749

17491750
// Make sure that the SINT_TO_FP and SRL instructions are available.
1750-
if (((!IsStrict && TLI.getOperationAction(ISD::SINT_TO_FP, VT) ==
1751+
if (((!IsStrict && TLI.getOperationAction(ISD::SINT_TO_FP, SrcVT) ==
17511752
TargetLowering::Expand) ||
1752-
(IsStrict && TLI.getOperationAction(ISD::STRICT_SINT_TO_FP, VT) ==
1753+
(IsStrict && TLI.getOperationAction(ISD::STRICT_SINT_TO_FP, SrcVT) ==
17531754
TargetLowering::Expand)) ||
1754-
TLI.getOperationAction(ISD::SRL, VT) == TargetLowering::Expand) {
1755+
TLI.getOperationAction(ISD::SRL, SrcVT) == TargetLowering::Expand) {
17551756
if (IsStrict) {
17561757
UnrollStrictFPOp(Node, Results);
17571758
return;
@@ -1761,46 +1762,42 @@ void VectorLegalizer::ExpandUINT_TO_FLOAT(SDNode *Node,
17611762
return;
17621763
}
17631764

1764-
unsigned BW = VT.getScalarSizeInBits();
1765+
unsigned BW = SrcVT.getScalarSizeInBits();
17651766
assert((BW == 64 || BW == 32) &&
17661767
"Elements in vector-UINT_TO_FP must be 32 or 64 bits wide");
17671768

1768-
SDValue HalfWord = DAG.getConstant(BW / 2, DL, VT);
1769+
SDValue HalfWord = DAG.getConstant(BW / 2, DL, SrcVT);
17691770

17701771
// Constants to clear the upper part of the word.
17711772
// Notice that we can also use SHL+SHR, but using a constant is slightly
17721773
// faster on x86.
17731774
uint64_t HWMask = (BW == 64) ? 0x00000000FFFFFFFF : 0x0000FFFF;
1774-
SDValue HalfWordMask = DAG.getConstant(HWMask, DL, VT);
1775+
SDValue HalfWordMask = DAG.getConstant(HWMask, DL, SrcVT);
17751776

17761777
// Two to the power of half-word-size.
1777-
SDValue TWOHW =
1778-
DAG.getConstantFP(1ULL << (BW / 2), DL, Node->getValueType(0));
1778+
SDValue TWOHW = DAG.getConstantFP(1ULL << (BW / 2), DL, DstVT);
17791779

17801780
// Clear upper part of LO, lower HI
1781-
SDValue HI = DAG.getNode(ISD::SRL, DL, VT, Src, HalfWord);
1782-
SDValue LO = DAG.getNode(ISD::AND, DL, VT, Src, HalfWordMask);
1781+
SDValue HI = DAG.getNode(ISD::SRL, DL, SrcVT, Src, HalfWord);
1782+
SDValue LO = DAG.getNode(ISD::AND, DL, SrcVT, Src, HalfWordMask);
17831783

17841784
if (IsStrict) {
17851785
// Convert hi and lo to floats
17861786
// Convert the hi part back to the upper values
17871787
// TODO: Can any fast-math-flags be set on these nodes?
1788-
SDValue fHI = DAG.getNode(ISD::STRICT_SINT_TO_FP, DL,
1789-
{Node->getValueType(0), MVT::Other},
1788+
SDValue fHI = DAG.getNode(ISD::STRICT_SINT_TO_FP, DL, {DstVT, MVT::Other},
17901789
{Node->getOperand(0), HI});
1791-
fHI = DAG.getNode(ISD::STRICT_FMUL, DL, {Node->getValueType(0), MVT::Other},
1790+
fHI = DAG.getNode(ISD::STRICT_FMUL, DL, {DstVT, MVT::Other},
17921791
{fHI.getValue(1), fHI, TWOHW});
1793-
SDValue fLO = DAG.getNode(ISD::STRICT_SINT_TO_FP, DL,
1794-
{Node->getValueType(0), MVT::Other},
1792+
SDValue fLO = DAG.getNode(ISD::STRICT_SINT_TO_FP, DL, {DstVT, MVT::Other},
17951793
{Node->getOperand(0), LO});
17961794

17971795
SDValue TF = DAG.getNode(ISD::TokenFactor, DL, MVT::Other, fHI.getValue(1),
17981796
fLO.getValue(1));
17991797

18001798
// Add the two halves
18011799
SDValue Result =
1802-
DAG.getNode(ISD::STRICT_FADD, DL, {Node->getValueType(0), MVT::Other},
1803-
{TF, fHI, fLO});
1800+
DAG.getNode(ISD::STRICT_FADD, DL, {DstVT, MVT::Other}, {TF, fHI, fLO});
18041801

18051802
Results.push_back(Result);
18061803
Results.push_back(Result.getValue(1));
@@ -1810,13 +1807,12 @@ void VectorLegalizer::ExpandUINT_TO_FLOAT(SDNode *Node,
18101807
// Convert hi and lo to floats
18111808
// Convert the hi part back to the upper values
18121809
// TODO: Can any fast-math-flags be set on these nodes?
1813-
SDValue fHI = DAG.getNode(ISD::SINT_TO_FP, DL, Node->getValueType(0), HI);
1814-
fHI = DAG.getNode(ISD::FMUL, DL, Node->getValueType(0), fHI, TWOHW);
1815-
SDValue fLO = DAG.getNode(ISD::SINT_TO_FP, DL, Node->getValueType(0), LO);
1810+
SDValue fHI = DAG.getNode(ISD::SINT_TO_FP, DL, DstVT, HI);
1811+
fHI = DAG.getNode(ISD::FMUL, DL, DstVT, fHI, TWOHW);
1812+
SDValue fLO = DAG.getNode(ISD::SINT_TO_FP, DL, DstVT, LO);
18161813

18171814
// Add the two halves
1818-
Results.push_back(
1819-
DAG.getNode(ISD::FADD, DL, Node->getValueType(0), fHI, fLO));
1815+
Results.push_back(DAG.getNode(ISD::FADD, DL, DstVT, fHI, fLO));
18201816
}
18211817

18221818
SDValue VectorLegalizer::ExpandFNEG(SDNode *Node) {

0 commit comments

Comments
 (0)