summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-02-25 22:46:08 +0000
committerSanjay Patel <spatel@rotateright.com>2015-02-25 22:46:08 +0000
commitcc29f4f2cbd82735bed4e322847b6b1e53d5a465 (patch)
tree42e38fbdadf47d3a693a620247ce8d17b8fbfbc5 /llvm/lib/Transforms
parent3588686baf06f622b000a4fd68ec826dc1f64353 (diff)
downloadbcm5719-llvm-cc29f4f2cbd82735bed4e322847b6b1e53d5a465.tar.gz
bcm5719-llvm-cc29f4f2cbd82735bed4e322847b6b1e53d5a465.zip
only propagate equality comparisons of FP values that we are certain are non-zero
This is a follow-on to r227491 which tightens the check for propagating FP values. If a non-constant value happens to be a zero, we would hit the same bug as before. Bug noted and patch suggested by Eli Friedman. llvm-svn: 230564
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 4a8578029b2..73a1f259b8b 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2182,12 +2182,16 @@ bool GVN::propagateEquality(Value *LHS, Value *RHS,
// Handle the floating point versions of equality comparisons too.
if ((isKnownTrue && Cmp->getPredicate() == CmpInst::FCMP_OEQ) ||
(isKnownFalse && Cmp->getPredicate() == CmpInst::FCMP_UNE)) {
- // Floating point -0.0 and 0.0 compare equal, so we can't
- // propagate a constant based on that comparison.
+
+ // Floating point -0.0 and 0.0 compare equal, so we can only
+ // propagate values if we know that we have a constant and that
+ // its value is non-zero.
+
// FIXME: We should do this optimization if 'no signed zeros' is
// applicable via an instruction-level fast-math-flag or some other
// indicator that relaxed FP semantics are being used.
- if (!isa<ConstantFP>(Op1) || !cast<ConstantFP>(Op1)->isZero())
+
+ if (isa<ConstantFP>(Op1) && !cast<ConstantFP>(Op1)->isZero())
Worklist.push_back(std::make_pair(Op0, Op1));
}
OpenPOWER on IntegriCloud