1; RUN: opt < %s -analyze -scalar-evolution 2>&1 | FileCheck %s
2
3; CHECK: Loop %bb: backedge-taken count is ((999 + (-1 * %x)) /u 3)
4; CHECK: Loop %bb: max backedge-taken count is 334
5
6
7; This is a tricky testcase for unsigned wrap detection which ScalarEvolution
8; doesn't yet know how to do.
9
10define i32 @f(i32 %x) nounwind readnone {
11entry:
12	%0 = icmp ugt i32 %x, 999		; <i1> [#uses=1]
13	br i1 %0, label %bb2, label %bb.nph
14
15bb.nph:		; preds = %entry
16	br label %bb
17
18bb:		; preds = %bb.nph, %bb1
19	%indvar = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb1 ]		; <i32> [#uses=2]
20	%tmp = mul i32 %indvar, 3		; <i32> [#uses=1]
21	%x_addr.04 = add i32 %tmp, %x		; <i32> [#uses=1]
22	%1 = add i32 %x_addr.04, 3		; <i32> [#uses=2]
23	br label %bb1
24
25bb1:		; preds = %bb
26	%2 = icmp ugt i32 %1, 999		; <i1> [#uses=1]
27	%indvar.next = add i32 %indvar, 1		; <i32> [#uses=1]
28	br i1 %2, label %bb1.bb2_crit_edge, label %bb
29
30bb1.bb2_crit_edge:		; preds = %bb1
31	%.lcssa = phi i32 [ %1, %bb1 ]		; <i32> [#uses=1]
32	br label %bb2
33
34bb2:		; preds = %bb1.bb2_crit_edge, %entry
35	%x_addr.0.lcssa = phi i32 [ %.lcssa, %bb1.bb2_crit_edge ], [ %x, %entry ]		; <i32> [#uses=1]
36	ret i32 %x_addr.0.lcssa
37}
38