diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-29 06:26:56 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-29 06:26:56 +0000 |
commit | 3181a771ff5b2090b7ed55f9b18a684ea8fe625a (patch) | |
tree | 4b0d1e44c5084f266455a96d0dc986e5fa3b377b /lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | a54aa94197d5af9a72c0de422a58e938da80b2a4 (diff) |
Legalize ConstantFP into TargetConstantFP when the target allows. Implement
custom expansion of ConstantFP nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 1b12d31173..b9a6ec0d45 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -277,6 +277,11 @@ void SelectionDAG::RemoveNodeFromCSEMaps(SDNode *N) { Erased = ConstantFPs.erase(std::make_pair(V, N->getValueType(0))); break; } + case ISD::TargetConstantFP: { + uint64_t V = DoubleToBits(cast<ConstantFPSDNode>(N)->getValue()); + Erased = TargetConstantFPs.erase(std::make_pair(V, N->getValueType(0))); + break; + } case ISD::STRING: Erased = StringNodes.erase(cast<StringSDNode>(N)->getValue()); break; @@ -606,7 +611,22 @@ SDOperand SelectionDAG::getConstantFP(double Val, MVT::ValueType VT) { // we don't have issues with SNANs. SDNode *&N = ConstantFPs[std::make_pair(DoubleToBits(Val), VT)]; if (N) return SDOperand(N, 0); - N = new ConstantFPSDNode(Val, VT); + N = new ConstantFPSDNode(false, Val, VT); + AllNodes.push_back(N); + return SDOperand(N, 0); +} + +SDOperand SelectionDAG::getTargetConstantFP(double Val, MVT::ValueType VT) { + assert(MVT::isFloatingPoint(VT) && "Cannot create integer FP constant!"); + if (VT == MVT::f32) + Val = (float)Val; // Mask out extra precision. + + // 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. + SDNode *&N = TargetConstantFPs[std::make_pair(DoubleToBits(Val), VT)]; + if (N) return SDOperand(N, 0); + N = new ConstantFPSDNode(true, Val, VT); AllNodes.push_back(N); return SDOperand(N, 0); } |