Skip to content

Commit af43528

Browse files
committed
[LegalizeTypes][X86] Add support for expanding the result type of STRICT_LLROUND and STRICT_LLRINT.
This doesn't handle softening the input type, but we don't handle softening any of the strict nodes yet. Skipping that made it easy to reuse an existing function for creating a libcall from a node with a chain.
1 parent a0337d2 commit af43528

File tree

2 files changed

+344
-15
lines changed

2 files changed

+344
-15
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,6 +1698,8 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) {
16981698
case ISD::FLT_ROUNDS_: ExpandIntRes_FLT_ROUNDS(N, Lo, Hi); break;
16991699
case ISD::FP_TO_SINT: ExpandIntRes_FP_TO_SINT(N, Lo, Hi); break;
17001700
case ISD::FP_TO_UINT: ExpandIntRes_FP_TO_UINT(N, Lo, Hi); break;
1701+
case ISD::STRICT_LLROUND:
1702+
case ISD::STRICT_LLRINT:
17011703
case ISD::LLROUND:
17021704
case ISD::LLRINT: ExpandIntRes_LLROUND_LLRINT(N, Lo, Hi); break;
17031705
case ISD::LOAD: ExpandIntRes_LOAD(cast<LoadSDNode>(N), Lo, Hi); break;
@@ -2586,15 +2588,16 @@ void DAGTypeLegalizer::ExpandIntRes_FP_TO_UINT(SDNode *N, SDValue &Lo,
25862588

25872589
void DAGTypeLegalizer::ExpandIntRes_LLROUND_LLRINT(SDNode *N, SDValue &Lo,
25882590
SDValue &Hi) {
2589-
SDValue Op = N->getOperand(0);
2591+
SDValue Op = N->getOperand(N->isStrictFPOpcode() ? 1 : 0);
25902592

25912593
assert(getTypeAction(Op.getValueType()) != TargetLowering::TypePromoteFloat &&
25922594
"Input type needs to be promoted!");
25932595

25942596
EVT VT = Op.getValueType();
25952597

25962598
RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
2597-
if (N->getOpcode() == ISD::LLROUND) {
2599+
if (N->getOpcode() == ISD::LLROUND ||
2600+
N->getOpcode() == ISD::STRICT_LLROUND) {
25982601
if (VT == MVT::f32)
25992602
LC = RTLIB::LLROUND_F32;
26002603
else if (VT == MVT::f64)
@@ -2606,7 +2609,8 @@ void DAGTypeLegalizer::ExpandIntRes_LLROUND_LLRINT(SDNode *N, SDValue &Lo,
26062609
else if (VT == MVT::ppcf128)
26072610
LC = RTLIB::LLROUND_PPCF128;
26082611
assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unexpected llround input type!");
2609-
} else if (N->getOpcode() == ISD::LLRINT) {
2612+
} else if (N->getOpcode() == ISD::LLRINT ||
2613+
N->getOpcode() == ISD::STRICT_LLRINT) {
26102614
if (VT == MVT::f32)
26112615
LC = RTLIB::LLRINT_F32;
26122616
else if (VT == MVT::f64)
@@ -2623,6 +2627,17 @@ void DAGTypeLegalizer::ExpandIntRes_LLROUND_LLRINT(SDNode *N, SDValue &Lo,
26232627

26242628
SDLoc dl(N);
26252629
EVT RetVT = N->getValueType(0);
2630+
2631+
if (N->isStrictFPOpcode()) {
2632+
// FIXME: Support softening for strict fp!
2633+
assert(getTypeAction(VT) != TargetLowering::TypeSoftenFloat &&
2634+
"Softening strict fp calls not supported yet!");
2635+
std::pair<SDValue, SDValue> Tmp = ExpandChainLibCall(LC, N, true);
2636+
SplitInteger(Tmp.first, Lo, Hi);
2637+
ReplaceValueWith(SDValue(N, 1), Tmp.second);
2638+
return;
2639+
}
2640+
26262641
TargetLowering::MakeLibCallOptions CallOptions;
26272642
CallOptions.setSExt(true);
26282643

0 commit comments

Comments
 (0)