Implement i64->ppcf128 conversions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42919 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dale Johannesen 2007-10-12 17:52:03 +00:00
parent b89f67e3e6
commit 6e63e09236

View File

@ -6032,7 +6032,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
case ISD::UINT_TO_FP: { case ISD::UINT_TO_FP: {
bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP; bool isSigned = Node->getOpcode() == ISD::SINT_TO_FP;
MVT::ValueType SrcVT = Node->getOperand(0).getValueType(); MVT::ValueType SrcVT = Node->getOperand(0).getValueType();
if (VT == MVT::ppcf128) { if (VT == MVT::ppcf128 && SrcVT != MVT::i64) {
static uint64_t zero = 0; static uint64_t zero = 0;
if (isSigned) { if (isSigned) {
Hi = LegalizeOp(DAG.getNode(ISD::SINT_TO_FP, MVT::f64, Hi = LegalizeOp(DAG.getNode(ISD::SINT_TO_FP, MVT::f64,
@ -6044,6 +6044,7 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
Node->getOperand(0))); Node->getOperand(0)));
Lo = DAG.getConstantFP(APFloat(APInt(64, 1, &zero)), MVT::f64); Lo = DAG.getConstantFP(APFloat(APInt(64, 1, &zero)), MVT::f64);
Hi = DAG.getNode(ISD::BUILD_PAIR, VT, Lo, Hi); Hi = DAG.getNode(ISD::BUILD_PAIR, VT, Lo, Hi);
// X>=0 ? {(f64)x, 0} : {(f64)x, 0} + 2^32
ExpandOp(DAG.getNode(ISD::SELECT_CC, MVT::ppcf128, Node->getOperand(0), ExpandOp(DAG.getNode(ISD::SELECT_CC, MVT::ppcf128, Node->getOperand(0),
DAG.getConstant(0, MVT::i32), DAG.getConstant(0, MVT::i32),
DAG.getNode(ISD::FADD, MVT::ppcf128, Hi, DAG.getNode(ISD::FADD, MVT::ppcf128, Hi,
@ -6056,6 +6057,24 @@ void SelectionDAGLegalize::ExpandOp(SDOperand Op, SDOperand &Lo, SDOperand &Hi){
} }
break; break;
} }
if (VT == MVT::ppcf128 && SrcVT == MVT::i64 && !isSigned) {
// si64->ppcf128 done by libcall, below
static uint64_t TwoE64[] = { 0x43f0000000000000LL, 0 };
ExpandOp(DAG.getNode(ISD::SINT_TO_FP, MVT::ppcf128, Node->getOperand(0)),
Lo, Hi);
Hi = DAG.getNode(ISD::BUILD_PAIR, VT, Lo, Hi);
// x>=0 ? (ppcf128)(i64)x : (ppcf128)(i64)x + 2^64
ExpandOp(DAG.getNode(ISD::SELECT_CC, MVT::ppcf128, Node->getOperand(0),
DAG.getConstant(0, MVT::i64),
DAG.getNode(ISD::FADD, MVT::ppcf128, Hi,
DAG.getConstantFP(
APFloat(APInt(128, 2, TwoE64)),
MVT::ppcf128)),
Hi,
DAG.getCondCode(ISD::SETLT)),
Lo, Hi);
break;
}
RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL; RTLIB::Libcall LC = RTLIB::UNKNOWN_LIBCALL;
if (Node->getOperand(0).getValueType() == MVT::i64) { if (Node->getOperand(0).getValueType() == MVT::i64) {
if (VT == MVT::f32) if (VT == MVT::f32)