summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-06-08 15:12:33 +0000
committerSanjay Patel <spatel@rotateright.com>2019-06-08 15:12:33 +0000
commit4329c15f11759b94b7739a7860b8fd141598c052 (patch)
tree767b7317b8b495edd6ee76a812505a94dc27fa82 /llvm/lib/Analysis/InstructionSimplify.cpp
parent375297f38fe87034e4f35c2b1115922d3773ced5 (diff)
downloadbcm5719-llvm-4329c15f11759b94b7739a7860b8fd141598c052.tar.gz
bcm5719-llvm-4329c15f11759b94b7739a7860b8fd141598c052.zip
[InstSimplify] enhance fcmp fold with never-nan operand
This is 1 step towards correcting our usage of fast-math-flags when applied on an fcmp. In this case, we are checking for 'nnan' on the fcmp itself rather than the operand of the fcmp. But I'm leaving that clause in until we're more confident that we can stop relying on fcmp's FMF. By using the more general "isKnownNeverNaN()", we gain a simplification shown on the tests with 'uitofp' regardless of the FMF on the fcmp (uitofp never produces a NaN). On the tests with 'fabs', we are now relying on the FMF for the call fabs instruction in addition to the FMF on the fcmp. I'll update the 'ult' case below here as a follow-up assuming no problems here. Differential Revision: https://reviews.llvm.org/D62979 llvm-svn: 362879
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index 9eb0e908aab..47369db4b46 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -3477,7 +3477,8 @@ static Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
if (match(RHS, m_AnyZeroFP())) {
switch (Pred) {
case FCmpInst::FCMP_OGE:
- if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
+ if ((FMF.noNaNs() || isKnownNeverNaN(LHS, Q.TLI)) &&
+ CannotBeOrderedLessThanZero(LHS, Q.TLI))
return getTrue(RetTy);
break;
case FCmpInst::FCMP_UGE:
@@ -3485,6 +3486,7 @@ static Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
return getTrue(RetTy);
break;
case FCmpInst::FCMP_ULT:
+ // TODO: This should match 'oge'.
if (FMF.noNaNs() && CannotBeOrderedLessThanZero(LHS, Q.TLI))
return getFalse(RetTy);
break;
OpenPOWER on IntegriCloud