aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms
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
commit5e678e03b72487d53117b05d23fd23f29bd8c344 (patch)
tree8f9fd68156dcb9dcc532d5626628c5afea5dceae /lib/Transforms
parent560a17d3bc8d3a3f6be179d428d31abd64498283 (diff)
downloadexternal_llvm-5e678e03b72487d53117b05d23fd23f29bd8c344.zip
external_llvm-5e678e03b72487d53117b05d23fd23f29bd8c344.tar.gz
external_llvm-5e678e03b72487d53117b05d23fd23f29bd8c344.tar.bz2
Oops, X+0.0 isn't foldable, but X+-0.0 is.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23772 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 67a5401..d92e126 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/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)) {