diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-21 14:04:54 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2016-04-21 14:04:54 +0000 |
commit | af83e40dee4270cf5a3b34229b981e6d7a5d07da (patch) | |
tree | a97484326d63a4bd521897e08c013d7c40b58186 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 1978f7fe2999171a43a2a577bc3e771f29abd9ea (diff) | |
download | bcm5719-llvm-af83e40dee4270cf5a3b34229b981e6d7a5d07da.tar.gz bcm5719-llvm-af83e40dee4270cf5a3b34229b981e6d7a5d07da.zip |
Refactor implied condition logic from ValueTracking directly into CmpInst. NFC.
Differential Revision: http://reviews.llvm.org/D19330
llvm-svn: 266987
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 54 |
1 files changed, 2 insertions, 52 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 7053195e2f3..0f6b0ec3629 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3935,61 +3935,11 @@ static Optional<bool> isImpliedCondMatchingOperands(CmpInst::Predicate APred, std::swap(BLHS, BRHS); BPred = ICmpInst::getSwappedPredicate(BPred); } - - // If the predicates match, then we know the first condition implies the - // second is true. - if (APred == BPred) + if (CmpInst::isTrueWhenOperandsMatch(APred, BPred)) return true; - - // If an inverted APred matches BPred, we can infer the second condition is - // false. - if (CmpInst::getInversePredicate(APred) == BPred) + if (CmpInst::isFalseWhenOperandsMatch(APred, BPred)) return false; - // If a swapped APred matches BPred, we can infer the second condition is - // false in many cases. - if (CmpInst::getSwappedPredicate(APred) == BPred) { - switch (APred) { - default: - break; - case CmpInst::ICMP_UGT: // A >u B implies A <u B is false. - case CmpInst::ICMP_ULT: // A <u B implies A >u B is false. - case CmpInst::ICMP_SGT: // A >s B implies A <s B is false. - case CmpInst::ICMP_SLT: // A <s B implies A >s B is false. - return false; - } - } - - // The predicates must match sign or at least one of them must be an equality - // comparison (which is signless). - if (ICmpInst::isSigned(APred) != ICmpInst::isSigned(BPred) && - !ICmpInst::isEquality(APred) && !ICmpInst::isEquality(BPred)) - return None; - - switch (APred) { - default: - break; - case CmpInst::ICMP_EQ: - // A == B implies A > B and A < B are false. - if (CmpInst::isFalseWhenEqual(BPred)) - return false; - - break; - case CmpInst::ICMP_UGT: - case CmpInst::ICMP_ULT: - case CmpInst::ICMP_SGT: - case CmpInst::ICMP_SLT: - // A > B implies A == B is false. - // A < B implies A == B is false. - if (BPred == CmpInst::ICMP_EQ) - return false; - - // A > B implies A != B is true. - // A < B implies A != B is true. - if (BPred == CmpInst::ICMP_NE) - return true; - break; - } return None; } |