Improve comment, pass in the original VT so that we can shrink a long double constant

all the way to float, not stopping at double.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47937 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-03-05 06:46:58 +00:00
parent b7664c6173
commit aa2acbbbf0

View File

@ -486,7 +486,9 @@ static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP,
// If a FP immediate is precise when represented as a float and if the // If a FP immediate is precise when represented as a float and if the
// target can do an extending load from float to double, we put it into // target can do an extending load from float to double, we put it into
// the constant pool as a float, even if it's is statically typed as a // the constant pool as a float, even if it's is statically typed as a
// double. // double. This shrinks FP constants and canonicalizes them for targets where
// an FP extending load is the same cost as a normal load (such as on the x87
// fp stack or PPC FP unit).
MVT::ValueType VT = CFP->getValueType(0); MVT::ValueType VT = CFP->getValueType(0);
ConstantFP *LLVMC = ConstantFP::get(MVT::getTypeForValueType(VT), ConstantFP *LLVMC = ConstantFP::get(MVT::getTypeForValueType(VT),
CFP->getValueAPF()); CFP->getValueAPF());
@ -505,7 +507,7 @@ static SDOperand ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP,
// Only do this if the target has a native EXTLOAD instruction from // Only do this if the target has a native EXTLOAD instruction from
// smaller type. // smaller type.
TLI.isLoadXLegal(ISD::EXTLOAD, SVT) && TLI.isLoadXLegal(ISD::EXTLOAD, SVT) &&
TLI.ShouldShrinkFPConstant(VT)) { TLI.ShouldShrinkFPConstant(OrigVT)) {
const Type *SType = MVT::getTypeForValueType(SVT); const Type *SType = MVT::getTypeForValueType(SVT);
LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType)); LLVMC = cast<ConstantFP>(ConstantExpr::getFPTrunc(LLVMC, SType));
VT = SVT; VT = SVT;