summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorKristof Beyls <kristof.beyls@arm.com>2012-09-12 11:25:02 +0000
committerKristof Beyls <kristof.beyls@arm.com>2012-09-12 11:25:02 +0000
commite6b876f4e514726f7f8fe0d0982901fef13859bb (patch)
treec51c44b1383e97b1001f56caa06f0ee5b7f89f79 /llvm/lib/CodeGen/SelectionDAG
parent9566ca9af852fc9b688b69f4aa3302bb2230827f (diff)
downloadbcm5719-llvm-e6b876f4e514726f7f8fe0d0982901fef13859bb.tar.gz
bcm5719-llvm-e6b876f4e514726f7f8fe0d0982901fef13859bb.zip
Fix constant folding through bitcasts by no longer relying on undefined behaviour (converting NaN values between float and double).
SelectionDAG::getConstantFP(double Val, EVT VT, bool isTarget); should not be used when Val is not a simple constant (as the comment in SelectionDAG.h indicates). This patch avoids using this function when folding an unknown constant through a bitcast, where it cannot be guaranteed that Val will be a simple constant. llvm-svn: 163703
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index d85d41bd86a..b515fbaf600 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -2454,9 +2454,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL,
}
case ISD::BITCAST:
if (VT == MVT::f32 && C->getValueType(0) == MVT::i32)
- return getConstantFP(Val.bitsToFloat(), VT);
+ return getConstantFP(APFloat(Val), VT);
else if (VT == MVT::f64 && C->getValueType(0) == MVT::i64)
- return getConstantFP(Val.bitsToDouble(), VT);
+ return getConstantFP(APFloat(Val), VT);
break;
case ISD::BSWAP:
return getConstant(Val.byteSwap(), VT);
OpenPOWER on IntegriCloud