Skip to content

Commit 9fa69ed

Browse files
committed
SCEV: cover a codepath in isImpliedCondBalancedTypes
The code that checks a predicate against a swapped predicate in isImpliedCondBalancedTypes is not covered by any existing test, within any Analysis or Transform. Fix this by adding a test to SCEV.
1 parent 95621e6 commit 9fa69ed

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11872,7 +11872,6 @@ bool ScalarEvolution::isImpliedCondBalancedTypes(
1187211872
// FIXME: use CmpPredicate::getMatching here.
1187311873
if (ICmpInst::getSwappedCmpPredicate(FoundPred) ==
1187411874
static_cast<CmpInst::Predicate>(Pred)) {
11875-
return false;
1187611875
// We can write the implication
1187711876
// 0. LHS Pred RHS <- FoundLHS SwapPred FoundRHS
1187811877
// using one of the following ways:

llvm/test/Analysis/ScalarEvolution/implied-via-division.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ define void @swapped_predicate(i32 %n) nounwind {
416416
; Prove that (n >= 1) ===> (0 >= -n / 2).
417417
; CHECK-LABEL: 'swapped_predicate'
418418
; CHECK-NEXT: Determining loop execution counts for: @swapped_predicate
419-
; CHECK-NEXT: Loop %header: backedge-taken count is (-1 * (0 smin (-1 + (-1 * %n.div.2)<nsw>)<nsw>))<nsw>
419+
; CHECK-NEXT: Loop %header: backedge-taken count is (1 + %n.div.2)<nsw>
420420
; CHECK-NEXT: Loop %header: constant max backedge-taken count is i32 1073741824
421-
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (-1 * (0 smin (-1 + (-1 * %n.div.2)<nsw>)<nsw>))<nsw>
421+
; CHECK-NEXT: Loop %header: symbolic max backedge-taken count is (1 + %n.div.2)<nsw>
422422
; CHECK-NEXT: Loop %header: Trip multiple is 1
423423
;
424424
entry:

0 commit comments

Comments
 (0)