diff options
author | Joshua Cao <cao.joshua@yahoo.com> | 2023-06-06 20:27:24 -0700 |
---|---|---|
committer | Joshua Cao <cao.joshua@yahoo.com> | 2023-06-06 21:06:22 -0700 |
commit | cb9f1aaddac0ce6bf9386309e33e104ba3f9359c (patch) | |
tree | f56c4b940129288ce43be8a35cfaa44cf342d97a /llvm/lib/Analysis/ValueTracking.cpp | |
parent | f23b4faaffb1172c3f090f5a28825240aa36969d (diff) | |
download | llvm-cb9f1aaddac0ce6bf9386309e33e104ba3f9359c.zip llvm-cb9f1aaddac0ce6bf9386309e33e104ba3f9359c.tar.gz llvm-cb9f1aaddac0ce6bf9386309e33e104ba3f9359c.tar.bz2 |
[ValueTracking] Implied conditions for lshr
`V1 >> V2 u<= V1` for any V1, V2
This works for lshr and any div's that are changed to lshr's
This fixes issues in clang and rustc:
https://github.com/llvm/llvm-project/issues/62441
https://github.com/rust-lang/rust/issues/110971
Reviewed By: goldstein.w.n
Differential Revision: https://reviews.llvm.org/D151541
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index c1c38c6..5393be0 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -7913,6 +7913,10 @@ static bool isTruePredicate(CmpInst::Predicate Pred, const Value *LHS, if (match(RHS, m_NUWAdd(m_Specific(LHS), m_APInt(C)))) return true; + // RHS >> V u<= RHS for any V + if (match(LHS, m_LShr(m_Specific(RHS), m_Value()))) + return true; + // Match A to (X +_{nuw} CA) and B to (X +_{nuw} CB) auto MatchNUWAddsToSameValue = [&](const Value *A, const Value *B, const Value *&X, |