aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-08-25 22:10:57 +0000
committerDale Johannesen <dalej@apple.com>2007-08-25 22:10:57 +0000
commit7f2c1d1a4f0703cfedd3808f0ec695724f99144d (patch)
treeffc179ca0ffd11a220e9766cbb999fa5a06309a0 /lib
parentcd71bed933fe221f8f42fc7f494e1608c894d192 (diff)
downloadexternal_llvm-7f2c1d1a4f0703cfedd3808f0ec695724f99144d.tar.gz
external_llvm-7f2c1d1a4f0703cfedd3808f0ec695724f99144d.tar.bz2
external_llvm-7f2c1d1a4f0703cfedd3808f0ec695724f99144d.zip
Add APFloat interface to ConstantFPSDNode. Change
over uses in DAGCombiner. Fix interfaces to work with APFloats. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp16
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp5
2 files changed, 8 insertions, 13 deletions
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d9c09e163b..2b119a095a 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3195,14 +3195,10 @@ SDOperand DAGCombiner::visitFCOPYSIGN(SDNode *N) {
return DAG.getNode(ISD::FCOPYSIGN, VT, N0, N1);
if (N1CFP) {
+ APFloat V = N1CFP->getValueAPF();
// copysign(x, c1) -> fabs(x) iff ispos(c1)
// copysign(x, c1) -> fneg(fabs(x)) iff isneg(c1)
- union {
- double d;
- int64_t i;
- } u;
- u.d = N1CFP->getValue();
- if (u.i >= 0)
+ if (!V.isNegative())
return DAG.getNode(ISD::FABS, VT, N0);
else
return DAG.getNode(ISD::FNEG, VT, DAG.getNode(ISD::FABS, VT, N0));
@@ -3792,7 +3788,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
default: assert(0 && "Unknown FP type");
case MVT::f32:
if (!AfterLegalize || TLI.isTypeLegal(MVT::i32)) {
- Tmp = DAG.getConstant(FloatToBits(CFP->getValue()), MVT::i32);
+ Tmp = DAG.getConstant(FloatToBits(CFP->getValueAPF().convertToFloat()), MVT::i32);
return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(),
ST->getSrcValueOffset(), ST->isVolatile(),
ST->getAlignment());
@@ -3800,7 +3796,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
break;
case MVT::f64:
if (!AfterLegalize || TLI.isTypeLegal(MVT::i64)) {
- Tmp = DAG.getConstant(DoubleToBits(CFP->getValue()), MVT::i64);
+ Tmp = DAG.getConstant(DoubleToBits(CFP->getValueAPF().convertToDouble()), MVT::i64);
return DAG.getStore(Chain, Tmp, Ptr, ST->getSrcValue(),
ST->getSrcValueOffset(), ST->isVolatile(),
ST->getAlignment());
@@ -3808,7 +3804,7 @@ SDOperand DAGCombiner::visitSTORE(SDNode *N) {
// Many FP stores are not make apparent until after legalize, e.g. for
// argument passing. Since this is so common, custom legalize the
// 64-bit integer store into two 32-bit stores.
- uint64_t Val = DoubleToBits(CFP->getValue());
+ uint64_t Val = DoubleToBits(CFP->getValueAPF().convertToDouble());
SDOperand Lo = DAG.getConstant(Val & 0xFFFFFFFF, MVT::i32);
SDOperand Hi = DAG.getConstant(Val >> 32, MVT::i32);
if (!TLI.isLittleEndian()) std::swap(Lo, Hi);
@@ -4365,7 +4361,7 @@ SDOperand DAGCombiner::SimplifySelectCC(SDOperand N0, SDOperand N1,
// Check to see if we can simplify the select into an fabs node
if (ConstantFPSDNode *CFP = dyn_cast<ConstantFPSDNode>(N1)) {
// Allow either -0.0 or 0.0
- if (CFP->getValue() == 0.0) {
+ if (CFP->getValueAPF().isZero()) {
// select (setg[te] X, +/-0.0), X, fneg(X) -> fabs
if ((CC == ISD::SETGE || CC == ISD::SETGT) &&
N0 == N2 && N3.getOpcode() == ISD::FNEG &&
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 6155ee160c..4bd07b60b7 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -48,8 +48,8 @@ static SDVTList makeVTList(const MVT::ValueType *VTs, unsigned NumVTs) {
/// it returns true for things that are clearly not equal, like -0.0 and 0.0.
/// As such, this method can be used to do an exact bit-for-bit comparison of
/// two floating point values.
-bool ConstantFPSDNode::isExactlyValue(double V) const {
- return Value.bitwiseIsEqual(APFloat(V));
+bool ConstantFPSDNode::isExactlyValue(APFloat V) const {
+ return Value.bitwiseIsEqual(V);
}
//===----------------------------------------------------------------------===//
@@ -669,7 +669,6 @@ SDOperand SelectionDAG::getConstant(uint64_t Val, MVT::ValueType VT, bool isT) {
return SDOperand(N, 0);
}
-
SDOperand SelectionDAG::getConstantFP(double Val, MVT::ValueType VT,
bool isTarget) {
assert(MVT::isFloatingPoint(VT) && "Cannot create integer FP constant!");