diff options
| author | Craig Topper <craig.topper@intel.com> | 2020-01-13 12:40:15 -0800 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2020-01-13 13:11:12 -0800 |
| commit | 26c7a4ed101fae85d2041ee1c8e8483b96e4460e (patch) | |
| tree | 0e68675b507601f830b0840f2b932eb212c712ac /llvm/lib/CodeGen/SelectionDAG | |
| parent | 577efd09e3b7b3a1ec7fcf0597397f137da99843 (diff) | |
| download | bcm5719-llvm-26c7a4ed101fae85d2041ee1c8e8483b96e4460e.tar.gz bcm5719-llvm-26c7a4ed101fae85d2041ee1c8e8483b96e4460e.zip | |
[LegalizeIntegerTypes][X86] Add support for expanding input of STRICT_SINT_TO_FP/STRICT_UINT_TO_FP into a libcall.
Needed to support i128->fp128 on 32-bit X86.
Add full set of strict sint_to_fp/uint_to_fp conversion tests for fp128.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index e2226483dda..a2988b4f891 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -3759,9 +3759,11 @@ bool DAGTypeLegalizer::ExpandIntegerOperand(SDNode *N, unsigned OpNo) { case ISD::SELECT_CC: Res = ExpandIntOp_SELECT_CC(N); break; case ISD::SETCC: Res = ExpandIntOp_SETCC(N); break; case ISD::SETCCCARRY: Res = ExpandIntOp_SETCCCARRY(N); break; + case ISD::STRICT_SINT_TO_FP: case ISD::SINT_TO_FP: Res = ExpandIntOp_SINT_TO_FP(N); break; case ISD::STORE: Res = ExpandIntOp_STORE(cast<StoreSDNode>(N), OpNo); break; case ISD::TRUNCATE: Res = ExpandIntOp_TRUNCATE(N); break; + case ISD::STRICT_UINT_TO_FP: case ISD::UINT_TO_FP: Res = ExpandIntOp_UINT_TO_FP(N); break; case ISD::SHL: @@ -4028,14 +4030,24 @@ SDValue DAGTypeLegalizer::ExpandIntOp_RETURNADDR(SDNode *N) { } SDValue DAGTypeLegalizer::ExpandIntOp_SINT_TO_FP(SDNode *N) { - SDValue Op = N->getOperand(0); + bool IsStrict = N->isStrictFPOpcode(); + SDValue Chain = IsStrict ? N->getOperand(0) : SDValue(); + SDValue Op = N->getOperand(IsStrict ? 1 : 0); EVT DstVT = N->getValueType(0); RTLIB::Libcall LC = RTLIB::getSINTTOFP(Op.getValueType(), DstVT); assert(LC != RTLIB::UNKNOWN_LIBCALL && "Don't know how to expand this SINT_TO_FP!"); TargetLowering::MakeLibCallOptions CallOptions; CallOptions.setSExt(true); - return TLI.makeLibCall(DAG, LC, DstVT, Op, CallOptions, SDLoc(N)).first; + std::pair<SDValue, SDValue> Tmp = + TLI.makeLibCall(DAG, LC, DstVT, Op, CallOptions, SDLoc(N), Chain); + + if (!IsStrict) + return Tmp.first; + + ReplaceValueWith(SDValue(N, 1), Tmp.second); + ReplaceValueWith(SDValue(N, 0), Tmp.first); + return SDValue(); } SDValue DAGTypeLegalizer::ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo) { @@ -4138,7 +4150,9 @@ SDValue DAGTypeLegalizer::ExpandIntOp_TRUNCATE(SDNode *N) { } SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { - SDValue Op = N->getOperand(0); + bool IsStrict = N->isStrictFPOpcode(); + SDValue Chain = IsStrict ? N->getOperand(0) : SDValue(); + SDValue Op = N->getOperand(IsStrict ? 1 : 0); EVT SrcVT = Op.getValueType(); EVT DstVT = N->getValueType(0); SDLoc dl(N); @@ -4147,8 +4161,10 @@ SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { // treated as signed) is representable in DstVT. Check that the mantissa // size of DstVT is >= than the number of bits in SrcVT -1. const fltSemantics &sem = DAG.EVTToAPFloatSemantics(DstVT); - if (APFloat::semanticsPrecision(sem) >= SrcVT.getSizeInBits()-1 && - TLI.getOperationAction(ISD::SINT_TO_FP, SrcVT) == TargetLowering::Custom){ + if (!IsStrict && + APFloat::semanticsPrecision(sem) >= SrcVT.getSizeInBits() - 1 && + TLI.getOperationAction(ISD::SINT_TO_FP, SrcVT) == + TargetLowering::Custom) { // Do a signed conversion then adjust the result. SDValue SignedConv = DAG.getNode(ISD::SINT_TO_FP, dl, DstVT, Op); SignedConv = TLI.LowerOperation(SignedConv, DAG); @@ -4211,7 +4227,15 @@ SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { "Don't know how to expand this UINT_TO_FP!"); TargetLowering::MakeLibCallOptions CallOptions; CallOptions.setSExt(true); - return TLI.makeLibCall(DAG, LC, DstVT, Op, CallOptions, dl).first; + std::pair<SDValue, SDValue> Tmp = + TLI.makeLibCall(DAG, LC, DstVT, Op, CallOptions, dl, Chain); + + if (!IsStrict) + return Tmp.first; + + ReplaceValueWith(SDValue(N, 1), Tmp.second); + ReplaceValueWith(SDValue(N, 0), Tmp.first); + return SDValue(); } SDValue DAGTypeLegalizer::ExpandIntOp_ATOMIC_STORE(SDNode *N) { |

