diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-18 13:08:49 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-01-22 22:56:26 +0100 |
commit | efba7ed05e50066deaa19f741c06902a23a9c124 (patch) | |
tree | 9a7244069d705730dfbfe68a427b5d7fdf015df0 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 9aa816a816b31642b38ff9c2eac9a3f9b6f7724f (diff) | |
download | llvm-efba7ed05e50066deaa19f741c06902a23a9c124.zip llvm-efba7ed05e50066deaa19f741c06902a23a9c124.tar.gz llvm-efba7ed05e50066deaa19f741c06902a23a9c124.tar.bz2 |
[PatternMatch] Make m_c_ICmp swap the predicate (PR42801)
This addresses https://bugs.llvm.org/show_bug.cgi?id=42801.
The m_c_ICmp() matcher is changed to provide the swapped predicate
if the operands are swapped.
Existing uses of m_c_ICmp() fall in one of two categories: Working
on equality predicates only, where swapping is irrelevant.
Or performing a manual swap, in which case this patch removes it.
The only exception is the foldICmpWithLowBitMaskedVal() fold, which
does not swap the predicate, and instead reasons about whether
a swap occurred or not for each predicate. Getting the swapped
predicate allows us to merge the logic for pairs of predicates,
instead of duplicating it.
Differential Revision: https://reviews.llvm.org/D72976
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 |
1 files changed, 0 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index ad6765e..7b9de94 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -592,10 +592,6 @@ static bool isKnownNonZeroFromAssume(const Value *V, const Query &Q) { CmpInst::Predicate Pred; if (!match(Cmp, m_c_ICmp(Pred, m_V, m_Value(RHS)))) return false; - // Canonicalize 'v' to be on the LHS of the comparison. - if (Cmp->getOperand(1) != RHS) - Pred = CmpInst::getSwappedPredicate(Pred); - // assume(v u> y) -> assume(v != 0) if (Pred == ICmpInst::ICMP_UGT) return true; |