diff options
author | Sanjay Patel <spatel@rotateright.com> | 2015-02-25 22:46:08 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2015-02-25 22:46:08 +0000 |
commit | cc29f4f2cbd82735bed4e322847b6b1e53d5a465 (patch) | |
tree | 42e38fbdadf47d3a693a620247ce8d17b8fbfbc5 /llvm/lib/Transforms | |
parent | 3588686baf06f622b000a4fd68ec826dc1f64353 (diff) | |
download | bcm5719-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.cpp | 10 |
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)); } |