Index: llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4999,11 +4999,11 @@ 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::SINT_TO_FP: + case ISD::STRICT_UINT_TO_FP: + case ISD::UINT_TO_FP: Res = ExpandIntOp_XINT_TO_FP(N); break; case ISD::STORE: Res = ExpandIntOp_STORE(cast(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: case ISD::SRA: @@ -5288,14 +5288,17 @@ return SDValue(DAG.UpdateNodeOperands(N, Lo), 0); } -SDValue DAGTypeLegalizer::ExpandIntOp_SINT_TO_FP(SDNode *N) { +SDValue DAGTypeLegalizer::ExpandIntOp_XINT_TO_FP(SDNode *N) { bool IsStrict = N->isStrictFPOpcode(); + bool IsSigned = N->getOpcode() == ISD::SINT_TO_FP || + N->getOpcode() == ISD::STRICT_SINT_TO_FP; 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); + RTLIB::Libcall LC = IsSigned ? RTLIB::getSINTTOFP(Op.getValueType(), DstVT) + : RTLIB::getUINTTOFP(Op.getValueType(), DstVT); assert(LC != RTLIB::UNKNOWN_LIBCALL && - "Don't know how to expand this SINT_TO_FP!"); + "Don't know how to expand this XINT_TO_FP!"); TargetLowering::MakeLibCallOptions CallOptions; CallOptions.setSExt(true); std::pair Tmp = @@ -5408,27 +5411,6 @@ return DAG.getNode(ISD::TRUNCATE, SDLoc(N), N->getValueType(0), InL); } -SDValue DAGTypeLegalizer::ExpandIntOp_UINT_TO_FP(SDNode *N) { - 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::getUINTTOFP(Op.getValueType(), DstVT); - assert(LC != RTLIB::UNKNOWN_LIBCALL && - "Don't know how to expand this UINT_TO_FP!"); - TargetLowering::MakeLibCallOptions CallOptions; - CallOptions.setSExt(true); - std::pair 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_ATOMIC_STORE(SDNode *N) { SDLoc dl(N); SDValue Swap = DAG.getAtomic(ISD::ATOMIC_SWAP, dl, Index: llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h =================================================================== --- llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h +++ llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h @@ -493,10 +493,9 @@ SDValue ExpandIntOp_SETCC(SDNode *N); SDValue ExpandIntOp_SETCCCARRY(SDNode *N); SDValue ExpandIntOp_Shift(SDNode *N); - SDValue ExpandIntOp_SINT_TO_FP(SDNode *N); SDValue ExpandIntOp_STORE(StoreSDNode *N, unsigned OpNo); SDValue ExpandIntOp_TRUNCATE(SDNode *N); - SDValue ExpandIntOp_UINT_TO_FP(SDNode *N); + SDValue ExpandIntOp_XINT_TO_FP(SDNode *N); SDValue ExpandIntOp_RETURNADDR(SDNode *N); SDValue ExpandIntOp_ATOMIC_STORE(SDNode *N); SDValue ExpandIntOp_SPLAT_VECTOR(SDNode *N);