diff options
author | Dale Johannesen <dalej@apple.com> | 2007-09-14 22:26:36 +0000 |
---|---|---|
committer | Dale Johannesen <dalej@apple.com> | 2007-09-14 22:26:36 +0000 |
commit | 9e3d3abd937c9bb79d56d25ec0e0724c7cbba67c (patch) | |
tree | c30fb34d6aa099b2c600d4a43088b7e99ef4e79b /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 24f2ea3971065eb9e88d50ebeddad0463337cae3 (diff) |
Remove the assumption that FP's are either float or
double from some of the many places in the optimizers
it appears, and do something reasonable with x86
long double.
Make APInt::dump() public, remove newline, use it to
dump ConstantSDNode's.
Allow APFloats in FoldingSet.
Expand X86 backend handling of long doubles (conversions
to/from int, mostly).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41967 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 0defc12e05..3744c4ad66 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -322,13 +322,7 @@ static void AddNodeIDNode(FoldingSetNodeID &ID, SDNode *N) { break; case ISD::TargetConstantFP: case ISD::ConstantFP: { - APFloat V = cast<ConstantFPSDNode>(N)->getValueAPF(); - if (&V.getSemantics() == &APFloat::IEEEdouble) - ID.AddDouble(V.convertToDouble()); - else if (&V.getSemantics() == &APFloat::IEEEsingle) - ID.AddDouble((double)V.convertToFloat()); - else - assert(0); + ID.AddAPFloat(cast<ConstantFPSDNode>(N)->getValueAPF()); break; } case ISD::TargetGlobalAddress: @@ -709,25 +703,21 @@ SDOperand SelectionDAG::getConstantFP(const APFloat& V, MVT::ValueType VT, MVT::ValueType EltVT = MVT::isVector(VT) ? MVT::getVectorElementType(VT) : VT; - bool isDouble = (EltVT == MVT::f64); - double Val = isDouble ? V.convertToDouble() : (double)V.convertToFloat(); // Do the map lookup using the actual bit pattern for the floating point // value, so that we don't have problems with 0.0 comparing equal to -0.0, and // we don't have issues with SNANs. unsigned Opc = isTarget ? ISD::TargetConstantFP : ISD::ConstantFP; - // ?? Should we store float/double/longdouble separately in ID? FoldingSetNodeID ID; AddNodeIDNode(ID, Opc, getVTList(EltVT), 0, 0); - ID.AddDouble(Val); + ID.AddAPFloat(V); void *IP = 0; SDNode *N = NULL; if ((N = CSEMap.FindNodeOrInsertPos(ID, IP))) if (!MVT::isVector(VT)) return SDOperand(N, 0); if (!N) { - N = new ConstantFPSDNode(isTarget, - isDouble ? APFloat(Val) : APFloat((float)Val), EltVT); + N = new ConstantFPSDNode(isTarget, V, EltVT); CSEMap.InsertNode(N, IP); AllNodes.push_back(N); } @@ -3724,9 +3714,15 @@ void SDNode::dump(const SelectionDAG *G) const { if (const ConstantSDNode *CSDN = dyn_cast<ConstantSDNode>(this)) { cerr << "<" << CSDN->getValue() << ">"; } else if (const ConstantFPSDNode *CSDN = dyn_cast<ConstantFPSDNode>(this)) { - cerr << "<" << (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle ? - CSDN->getValueAPF().convertToFloat() : - CSDN->getValueAPF().convertToDouble()) << ">"; + if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEsingle) + cerr << "<" << CSDN->getValueAPF().convertToFloat() << ">"; + else if (&CSDN->getValueAPF().getSemantics()==&APFloat::IEEEdouble) + cerr << "<" << CSDN->getValueAPF().convertToDouble() << ">"; + else { + cerr << "<APFloat("; + CSDN->getValueAPF().convertToAPInt().dump(); + cerr << ")>"; + } } else if (const GlobalAddressSDNode *GADN = dyn_cast<GlobalAddressSDNode>(this)) { int offset = GADN->getOffset(); |