summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2017-12-01 12:34:16 +0000
committerFlorian Hahn <florian.hahn@arm.com>2017-12-01 12:34:16 +0000
commit03c5509e661432d177da88af875979881017151a (patch)
tree97b7ea93f55a74de3455a7966f957e9bdab9ccae /lib/Analysis
parent8c4503a35074fd4da13c834ab01ecb65e1d1bb63 (diff)
[InstSimplify] More fcmp cases when comparing against negative constants.
Summary: For known positive non-zero value X: fcmp uge X, -C => true fcmp ugt X, -C => true fcmp une X, -C => true fcmp oeq X, -C => false fcmp ole X, -C => false fcmp olt X, -C => false Patch by Paul Walker. Reviewers: majnemer, t.p.northover, spatel, RKSimon Reviewed By: spatel Subscribers: fhahn, llvm-commits Differential Revision: https://reviews.llvm.org/D40012 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319538 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/InstructionSimplify.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp
index 6bed2f3a901..145aa13dfc8 100644
--- a/lib/Analysis/InstructionSimplify.cpp
+++ b/lib/Analysis/InstructionSimplify.cpp
@@ -3378,6 +3378,28 @@ static Value *SimplifyFCmpInst(unsigned Predicate, Value *LHS, Value *RHS,
default:
break;
}
+ } else if (C->isNegative()) {
+ assert(!C->isNaN() && "Unexpected NaN constant!");
+ // TODO: We can catch more cases by using a range check rather than
+ // relying on CannotBeOrderedLessThanZero.
+ switch (Pred) {
+ case FCmpInst::FCMP_UGE:
+ case FCmpInst::FCMP_UGT:
+ case FCmpInst::FCMP_UNE:
+ // (X >= 0) implies (X > C) when (C < 0)
+ if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
+ return getTrue(RetTy);
+ break;
+ case FCmpInst::FCMP_OEQ:
+ case FCmpInst::FCMP_OLE:
+ case FCmpInst::FCMP_OLT:
+ // (X >= 0) implies !(X < C) when (C < 0)
+ if (CannotBeOrderedLessThanZero(LHS, Q.TLI))
+ return getFalse(RetTy);
+ break;
+ default:
+ break;
+ }
}
}