[llvm-commits] [llvm] r69948 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
Dan Gohman
gohman at apple.com
Thu Apr 23 19:40:23 PDT 2009
Author: djg
Date: Thu Apr 23 21:40:23 2009
New Revision: 69948
URL: http://llvm.org/viewvc/llvm-project?rev=69948&view=rev
Log:
Instead of requiring TLI.LowerCallTo to return an ISD::BUILD_PAIR,
use ISD::EXTRACT_ELEMENT. SelectionDAG has a special fast-path for
the cast of an EXTRACT_ELEMENT with a BUILD_PAIR operand, for the
common case.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp?rev=69948&r1=69947&r2=69948&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp Thu Apr 23 21:40:23 2009
@@ -860,9 +860,12 @@
RTLIB::ADD_F32, RTLIB::ADD_F64,
RTLIB::ADD_F80, RTLIB::ADD_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FCEIL(SDNode *N,
@@ -871,9 +874,12 @@
RTLIB::CEIL_F32, RTLIB::CEIL_F64,
RTLIB::CEIL_F80, RTLIB::CEIL_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FCOS(SDNode *N,
@@ -882,9 +888,12 @@
RTLIB::COS_F32, RTLIB::COS_F64,
RTLIB::COS_F80, RTLIB::COS_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FDIV(SDNode *N, SDValue &Lo,
@@ -897,9 +906,12 @@
RTLIB::DIV_PPCF128),
N->getValueType(0), Ops, 2, false,
N->getDebugLoc());
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FEXP(SDNode *N,
@@ -908,9 +920,12 @@
RTLIB::EXP_F32, RTLIB::EXP_F64,
RTLIB::EXP_F80, RTLIB::EXP_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FEXP2(SDNode *N,
@@ -919,9 +934,12 @@
RTLIB::EXP2_F32, RTLIB::EXP2_F64,
RTLIB::EXP2_F80, RTLIB::EXP2_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FFLOOR(SDNode *N,
@@ -930,9 +948,12 @@
RTLIB::FLOOR_F32,RTLIB::FLOOR_F64,
RTLIB::FLOOR_F80,RTLIB::FLOOR_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FLOG(SDNode *N,
@@ -941,9 +962,12 @@
RTLIB::LOG_F32, RTLIB::LOG_F64,
RTLIB::LOG_F80, RTLIB::LOG_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FLOG2(SDNode *N,
@@ -952,9 +976,12 @@
RTLIB::LOG2_F32, RTLIB::LOG2_F64,
RTLIB::LOG2_F80, RTLIB::LOG2_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FLOG10(SDNode *N,
@@ -963,9 +990,12 @@
RTLIB::LOG10_F32,RTLIB::LOG10_F64,
RTLIB::LOG10_F80,RTLIB::LOG10_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FMUL(SDNode *N, SDValue &Lo,
@@ -978,9 +1008,12 @@
RTLIB::MUL_PPCF128),
N->getValueType(0), Ops, 2, false,
N->getDebugLoc());
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FNEARBYINT(SDNode *N,
@@ -991,9 +1024,12 @@
RTLIB::NEARBYINT_F80,
RTLIB::NEARBYINT_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FNEG(SDNode *N, SDValue &Lo,
@@ -1017,9 +1053,12 @@
RTLIB::POW_F32, RTLIB::POW_F64,
RTLIB::POW_F80, RTLIB::POW_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FPOWI(SDNode *N,
@@ -1028,9 +1067,12 @@
RTLIB::POWI_F32, RTLIB::POWI_F64,
RTLIB::POWI_F80, RTLIB::POWI_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FRINT(SDNode *N,
@@ -1039,9 +1081,12 @@
RTLIB::RINT_F32, RTLIB::RINT_F64,
RTLIB::RINT_F80, RTLIB::RINT_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FSIN(SDNode *N,
@@ -1050,9 +1095,12 @@
RTLIB::SIN_F32, RTLIB::SIN_F64,
RTLIB::SIN_F80, RTLIB::SIN_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FSQRT(SDNode *N,
@@ -1061,9 +1109,12 @@
RTLIB::SQRT_F32, RTLIB::SQRT_F64,
RTLIB::SQRT_F80, RTLIB::SQRT_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FSUB(SDNode *N, SDValue &Lo,
@@ -1076,9 +1127,12 @@
RTLIB::SUB_PPCF128),
N->getValueType(0), Ops, 2, false,
N->getDebugLoc());
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_FTRUNC(SDNode *N,
@@ -1087,9 +1141,12 @@
RTLIB::TRUNC_F32, RTLIB::TRUNC_F64,
RTLIB::TRUNC_F80, RTLIB::TRUNC_PPCF128),
N, false);
- assert(Call.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Call.getOperand(0); Hi = Call.getOperand(1);
+ MVT NVT = TLI.getTypeToTransformTo(N->getValueType(0));
+ DebugLoc dl = N->getDebugLoc();
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Call,
+ DAG.getIntPtrConstant(1));
}
void DAGTypeLegalizer::ExpandFloatRes_LOAD(SDNode *N, SDValue &Lo,
@@ -1157,9 +1214,10 @@
assert(LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported XINT_TO_FP!");
Hi = MakeLibCall(LC, VT, &Src, 1, true, dl);
- assert(Hi.getNode()->getOpcode() == ISD::BUILD_PAIR &&
- "Call lowered wrongly!");
- Lo = Hi.getOperand(0); Hi = Hi.getOperand(1);
+ Lo = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Hi,
+ DAG.getIntPtrConstant(0));
+ Hi = DAG.getNode(ISD::EXTRACT_ELEMENT, dl, NVT, Hi,
+ DAG.getIntPtrConstant(1));
}
if (isSigned)
More information about the llvm-commits
mailing list