diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-22 17:57:34 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-22 17:57:34 +0000 |
commit | 1a601590640f6af67873bf0a72cbf4de39bad95f (patch) | |
tree | 5edd298c98951e2ad8053fd4ba9eb3d30649b458 /llvm/lib/IR/Instructions.cpp | |
parent | 2b909e9917b27568f256aece48b5c3d5f07d3ad0 (diff) | |
download | llvm-1a601590640f6af67873bf0a72cbf4de39bad95f.zip llvm-1a601590640f6af67873bf0a72cbf4de39bad95f.tar.gz llvm-1a601590640f6af67873bf0a72cbf4de39bad95f.tar.bz2 |
[SimplifyCFG] Add final missing implications to isImpliedTrueByMatchingCmp.
Summary: eq imply [u|s]ge and [u|s]le are true.
Remove redundant logic by implementing isImpliedFalseByMatchingCmp(Pred1, Pred2)
as isImpliedTrueByMatchingCmp(Pred1, getInversePredicate(Pred2)).
llvm-svn: 267177
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r-- | llvm/lib/IR/Instructions.cpp | 37 |
1 files changed, 5 insertions, 32 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 13e5821..8ad9c07 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -3562,6 +3562,10 @@ bool CmpInst::isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2) { switch (Pred1) { default: break; + case ICMP_EQ: + // A == B implies A >=u B, A <=u B, A >=u B, and A <=u B are true. + return Pred2 == ICMP_UGE || Pred2 == ICMP_ULE || Pred2 == ICMP_SGE || + Pred2 == ICMP_SLE; case ICMP_UGT: // A >u B implies A != B and A >=u B are true. return Pred2 == ICMP_NE || Pred2 == ICMP_UGE; case ICMP_ULT: // A <u B implies A != B and A <=u B are true. @@ -3575,38 +3579,7 @@ bool CmpInst::isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2) { } bool CmpInst::isImpliedFalseByMatchingCmp(Predicate Pred1, Predicate Pred2) { - // If an inverted Pred1 matches Pred2, we can infer the second condition is - // false. - if (getInversePredicate(Pred1) == Pred2) - return true; - - // If a swapped Pred1 matches Pred2, we can infer the second condition is - // false in many cases. - if (getSwappedPredicate(Pred1) == Pred2) { - switch (Pred1) { - default: - break; - case ICMP_UGT: // A >u B implies A <u B is false. - case ICMP_ULT: // A <u B implies A >u B is false. - case ICMP_SGT: // A >s B implies A <s B is false. - case ICMP_SLT: // A <s B implies A >s B is false. - return true; - } - } - // A == B implies A > B and A < B are false. - if (Pred1 == ICMP_EQ && isFalseWhenEqual(Pred2)) - return true; - - switch (Pred1) { - default: - break; - case ICMP_UGT: // A >u B implies A == B is false. - case ICMP_ULT: // A <u B implies A == B is false. - case ICMP_SGT: // A >s B implies A == B is false. - case ICMP_SLT: // A <s B implies A == B is false. - return Pred2 == ICMP_EQ; - } - return false; + return isImpliedTrueByMatchingCmp(Pred1, getInversePredicate(Pred2)); } //===----------------------------------------------------------------------===// |