aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorJoshua Cao <cao.joshua@yahoo.com>2023-06-06 20:27:24 -0700
committerJoshua Cao <cao.joshua@yahoo.com>2023-06-06 21:06:22 -0700
commitcb9f1aaddac0ce6bf9386309e33e104ba3f9359c (patch)
treef56c4b940129288ce43be8a35cfaa44cf342d97a /llvm/lib/Analysis/ValueTracking.cpp
parentf23b4faaffb1172c3f090f5a28825240aa36969d (diff)
downloadllvm-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.cpp4
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,