Skip to content

Commit 3d409e5

Browse files
committed
[ValueTracking] Tracking or disjoint conditions as add in Assumption/DomCondition Cache
We can definitionally treat `or disjoint` as `add` anywhere.
1 parent 5d39baf commit 3d409e5

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ static void computeKnownBitsFromCmp(const Value *V, CmpInst::Predicate Pred,
699699
}
700700
default:
701701
const APInt *Offset = nullptr;
702-
if (match(LHS, m_CombineOr(m_V, m_Add(m_V, m_APInt(Offset)))) &&
702+
if (match(LHS, m_CombineOr(m_V, m_AddLike(m_V, m_APInt(Offset)))) &&
703703
match(RHS, m_APInt(C))) {
704704
ConstantRange LHSRange = ConstantRange::makeAllowedICmpRegion(Pred, *C);
705705
if (Offset)
@@ -9285,7 +9285,7 @@ void llvm::findValuesAffectedByCondition(
92859285
} else {
92869286
// Handle (A + C1) u< C2, which is the canonical form of
92879287
// A > C3 && A < C4.
9288-
if (match(A, m_Add(m_Value(X), m_ConstantInt())) &&
9288+
if (match(A, m_AddLike(m_Value(X), m_ConstantInt())) &&
92899289
match(B, m_ConstantInt()))
92909290
AddAffected(X);
92919291

llvm/test/Transforms/InstCombine/known-bits.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,7 @@ define i1 @test_icmp_or_distjoint(i8 %n, i1 %other) {
490490
; CHECK-NEXT: [[CMP:%.*]] = icmp ugt i8 [[N_OR]], -111
491491
; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
492492
; CHECK: if.then:
493-
; CHECK-NEXT: [[R:%.*]] = icmp slt i8 [[N]], 0
494-
; CHECK-NEXT: ret i1 [[R]]
493+
; CHECK-NEXT: ret i1 true
495494
; CHECK: if.else:
496495
; CHECK-NEXT: ret i1 [[OTHER:%.*]]
497496
;

0 commit comments

Comments
 (0)