Skip to content

Commit 3a69ebf

Browse files
committed
[SCEV] Add another test using info from loop guards for BTC with NE.
1 parent 4f1897c commit 3a69ebf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,32 @@ exit:
246246
ret void
247247
}
248248

249+
define void @test_guard_ult_ne(i32* nocapture readonly %data, i64 %count) {
250+
; CHECK-LABEL: @test_guard_ult_ne
251+
; CHECK: Loop %loop: backedge-taken count is (-1 + %count)
252+
; CHECK-NEXT: Loop %loop: max backedge-taken count is -2
253+
; CHECK-NEXT: Loop %loop: Predicated backedge-taken count is (-1 + %count)
254+
;
255+
entry:
256+
%cmp.ult = icmp ult i64 %count, 5
257+
br i1 %cmp.ult, label %guardbb, label %exit
258+
259+
guardbb:
260+
%cmp.ne = icmp ne i64 %count, 0
261+
br i1 %cmp.ne, label %loop, label %exit
262+
263+
loop:
264+
%iv = phi i64 [ %iv.next, %loop ], [ 0, %guardbb ]
265+
%idx = getelementptr inbounds i32, i32* %data, i64 %iv
266+
store i32 1, i32* %idx, align 4
267+
%iv.next = add nuw i64 %iv, 1
268+
%exitcond.not = icmp eq i64 %iv.next, %count
269+
br i1 %exitcond.not, label %exit, label %loop
270+
271+
exit:
272+
ret void
273+
}
274+
249275
; Test case for PR47247. Both the guard condition and the assume limit the
250276
; max backedge-taken count.
251277

0 commit comments

Comments
 (0)