diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-22 17:14:12 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-22 17:14:12 +0000 |
commit | 3456cb5672715f9d7528cae17fbe1de395240a5c (patch) | |
tree | 0480c227ad5680329ecc1f7759c20c4b1a31cbda /llvm/lib/IR/Instructions.cpp | |
parent | 1960d13e29ad8520ebbec3d24fb4b0b58c548091 (diff) | |
download | llvm-3456cb5672715f9d7528cae17fbe1de395240a5c.zip llvm-3456cb5672715f9d7528cae17fbe1de395240a5c.tar.gz llvm-3456cb5672715f9d7528cae17fbe1de395240a5c.tar.bz2 |
[SimplifyCFG] Add missing implications to isImpliedTrueByMatchingCmp.
Summary: [u|s]gt and [u|s]lt imply [u|s]ge and [u|s]le are true, respectively.
I've simplified the existing tests and added additional tests to cover the new
cases mentioned above. I've also added tests for all the cases where the
first compare doesn't imply anything about the second compare.
llvm-svn: 267171
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r-- | llvm/lib/IR/Instructions.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index e17db65..13e5821 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -3562,11 +3562,14 @@ bool CmpInst::isImpliedTrueByMatchingCmp(Predicate Pred1, Predicate Pred2) { switch (Pred1) { default: break; - case ICMP_UGT: // A >u B implies A != B is true. - case ICMP_ULT: // A <u B implies A != B is true. - case ICMP_SGT: // A >s B implies A != B is true. - case ICMP_SLT: // A <s B implies A != B is true. - return Pred2 == ICMP_NE; + 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. + return Pred2 == ICMP_NE || Pred2 == ICMP_ULE; + case ICMP_SGT: // A >s B implies A != B and A >=s B are true. + return Pred2 == ICMP_NE || Pred2 == ICMP_SGE; + case ICMP_SLT: // A <s B implies A != B and A <=s B are true. + return Pred2 == ICMP_NE || Pred2 == ICMP_SLE; } return false; } |