Skip to content

Commit b5a3b90

Browse files
committed
[SCEV] Add support for x == constant to CollectCondition.
Add support for EQ predicates with constant operand. In that case, using the constant instead of an unknown expression should always be beneficial.
1 parent 179e15d commit b5a3b90

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12618,6 +12618,10 @@ const SCEV *ScalarEvolution::applyLoopGuards(const SCEV *Expr, const Loop *L) {
1261812618
}
1261912619
break;
1262012620
}
12621+
case CmpInst::ICMP_EQ:
12622+
if (isa<SCEVConstant>(RHS))
12623+
RewriteMap[LHSUnknown->getValue()] = RHS;
12624+
break;
1262112625
default:
1262212626
break;
1262312627
}

llvm/test/Analysis/ScalarEvolution/max-backedge-taken-count-guard-info.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ exit:
9494
define void @test_guard_eq_12(i32* nocapture %a, i64 %N) {
9595
; CHECK-LABEL: Determining loop execution counts for: @test_guard_eq_12
9696
; CHECK-NEXT: Loop %loop: backedge-taken count is %N
97-
; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
97+
; CHECK-NEXT: Loop %loop: max backedge-taken count is 12
9898
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is %N
9999
;
100100
entry:

0 commit comments

Comments
 (0)