[llvm] 637421c - [ValueTracking] Tracking `or disjoint` conditions as `add` in Assumption/DomCondition Cache
Noah Goldstein via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 28 11:49:20 PDT 2024
Author: Noah Goldstein
Date: 2024-03-28T13:49:05-05:00
New Revision: 637421cb887fd51e6edde31d8f9e041f53c3f495
URL: https://github.com/llvm/llvm-project/commit/637421cb887fd51e6edde31d8f9e041f53c3f495
DIFF: https://github.com/llvm/llvm-project/commit/637421cb887fd51e6edde31d8f9e041f53c3f495.diff
LOG: [ValueTracking] Tracking `or disjoint` conditions as `add` in Assumption/DomCondition Cache
We can definitionally treat `or disjoint` as `add` anywhere.
Closes #86302
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/known-bits.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 797665cf06c875..b5e8a1d22f264b 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -699,7 +699,7 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
}
default:
const APInt *Offset = nullptr;
- if (match(LHS, m_CombineOr(m_V, m_Add(m_V, m_APInt(Offset)))) &&
+ if (match(LHS, m_CombineOr(m_V, m_AddLike(m_V, m_APInt(Offset)))) &&
match(RHS, m_APInt(C))) {
ConstantRange LHSRange = ConstantRange::makeAllowedICmpRegion(Pred, *C);
if (Offset)
@@ -9285,7 +9285,7 @@ void llvm::findValuesAffectedByCondition(
} else {
// Handle (A + C1) u< C2, which is the canonical form of
// A > C3 && A < C4.
- if (match(A, m_Add(m_Value(X), m_ConstantInt())) &&
+ if (match(A, m_AddLike(m_Value(X), m_ConstantInt())) &&
match(B, m_ConstantInt()))
AddAffected(X);
diff --git a/llvm/test/Transforms/InstCombine/known-bits.ll b/llvm/test/Transforms/InstCombine/known-bits.ll
index ff7b81b2f2b25d..5305c78f691231 100644
--- a/llvm/test/Transforms/InstCombine/known-bits.ll
+++ b/llvm/test/Transforms/InstCombine/known-bits.ll
@@ -490,8 +490,7 @@ define i1 @test_icmp_or_distjoint(i8 %n, i1 %other) {
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[N_OR]], -111
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
; CHECK: if.then:
-; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[N]], 0
-; CHECK-NEXT: ret i1 [[R]]
+; CHECK-NEXT: ret i1 true
; CHECK: if.else:
; CHECK-NEXT: ret i1 [[OTHER:%.*]]
;
More information about the llvm-commits
mailing list