[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.
This commit is contained in:
Florian Hahn 2020-09-24 21:57:14 +01:00
parent 179e15d53a
commit b5a3b901c7
2 changed files with 5 additions and 1 deletions

View File

@ -12618,6 +12618,10 @@ const SCEV *ScalarEvolution::applyLoopGuards(const SCEV *Expr, const Loop *L) {
}
break;
}
case CmpInst::ICMP_EQ:
if (isa<SCEVConstant>(RHS))
RewriteMap[LHSUnknown->getValue()] = RHS;
break;
default:
break;
}

View File

@ -94,7 +94,7 @@ exit:
define void @test_guard_eq_12(i32* nocapture %a, i64 %N) {
; CHECK-LABEL: Determining loop execution counts for: @test_guard_eq_12
; CHECK-NEXT: Loop %loop: backedge-taken count is %N
; CHECK-NEXT: Loop %loop: max backedge-taken count is -1
; CHECK-NEXT: Loop %loop: max backedge-taken count is 12
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is %N
;
entry: