Skip to content

Commit 9f62f41

Browse files
Update LegalizeVectorOps.cpp
1 parent ca603d2 commit 9f62f41

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,27 @@ void VectorLegalizer::ExpandUINT_TO_FLOAT(SDNode *Node,
17761776
assert((BW == 64 || BW == 32) &&
17771777
"Elements in vector-UINT_TO_FP must be 32 or 64 bits wide");
17781778

1779+
// If STRICT_/FMUL is not supported by the target (in case of f16) replace the
1780+
// UINT_TO_FP with a larger float and round to the smaller type
1781+
if ((!IsStrict && TLI.getOperationAction(ISD::FMUL, Node->getValueType(0)) ==
1782+
TargetLowering::Expand) ||
1783+
(IsStrict &&
1784+
TLI.getOperationAction(ISD::STRICT_FMUL, Node->getValueType(0)) ==
1785+
TargetLowering::Expand)) {
1786+
EVT FPVT = BW == 32 ? MVT::f32 : MVT::f64;
1787+
SDLoc DL(Node);
1788+
unsigned Round = IsStrict ? ISD::STRICT_FP_ROUND : ISD::FP_ROUND;
1789+
unsigned UIToFP = IsStrict ? ISD::STRICT_UINT_TO_FP : ISD::UINT_TO_FP;
1790+
SDValue Result = DAG.getNode(
1791+
Round, DL, Node->getValueType(0),
1792+
DAG.getNode(UIToFP, DL, VT.changeVectorElementType(FPVT), Src),
1793+
DAG.getTargetConstant(
1794+
0, DL,
1795+
DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout())));
1796+
Results.push_back(Result);
1797+
return;
1798+
}
1799+
17791800
SDValue HalfWord = DAG.getConstant(BW / 2, DL, VT);
17801801

17811802
// Constants to clear the upper part of the word.

0 commit comments

Comments
 (0)