summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-10-17 17:56:38 +0000
committerChris Lattner <sabre@nondot.org>2005-10-17 17:56:38 +0000
commit7fde91e365fa8f172144043251f76bb89ead10c5 (patch)
tree72a61d2e5a9ec543d223d368100c21f876ef7c29 /llvm/lib
parent32979336a70e4c01f4af4212dda8e5932fdccb12 (diff)
downloadbcm5719-llvm-7fde91e365fa8f172144043251f76bb89ead10c5.tar.gz
bcm5719-llvm-7fde91e365fa8f172144043251f76bb89ead10c5.zip
Oops, X+0.0 isn't foldable, but X+-0.0 is.
llvm-svn: 23772
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
index 67a54018c37..d92e126b080 100644
--- a/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -694,11 +694,12 @@ Instruction *InstCombiner::visitAdd(BinaryOperator &I) {
return ReplaceInstUsesWith(I, RHS);
// X + 0 --> X
- // NOTE: -0 + +0 = +0 in non-default rounding modes. When we support them
- // we must disable this. Note that 0.0-0.0 = -0.0, so this doesn't hold
- // for SUB.
- if (RHSC->isNullValue())
+ if (!I.getType()->isFloatingPoint()) { // NOTE: -0 + +0 = +0.
+ if (RHSC->isNullValue())
+ return ReplaceInstUsesWith(I, LHS);
+ } else if (cast<ConstantFP>(RHSC)->isExactlyValue(-0.0)) {
return ReplaceInstUsesWith(I, LHS);
+ }
// X + (signbit) --> X ^ signbit
if (ConstantInt *CI = dyn_cast<ConstantInt>(RHSC)) {
OpenPOWER on IntegriCloud