1 ; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s
4 define void @test0(i32 %init) {
7 ; CHECK-NEXT: Determining loop execution counts for: @test0
8 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
9 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 32
10 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 32
16 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
17 %iv.shift = lshr i32 %iv, 1
18 %exit.cond = icmp eq i32 %iv, 0
19 br i1 %exit.cond, label %leave, label %loop
25 define void @test1(i32 %init) {
27 ; CHECK-LABEL: 'test1'
28 ; CHECK-NEXT: Determining loop execution counts for: @test1
29 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
30 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 32
31 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 32
37 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
38 %iv.shift = shl i32 %iv, 1
39 %exit.cond = icmp eq i32 %iv, 0
40 br i1 %exit.cond, label %leave, label %loop
46 define void @test2(i32 %init) {
48 ; Unpredictable because %iv could "stabilize" to either -1 or 0,
50 ; CHECK-LABEL: 'test2'
51 ; CHECK-NEXT: Determining loop execution counts for: @test2
52 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
53 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
54 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
60 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
61 %iv.shift = ashr i32 %iv, 1
62 %exit.cond = icmp eq i32 %iv, 0
63 br i1 %exit.cond, label %leave, label %loop
69 define void @test3(ptr %init.ptr) {
71 ; CHECK-LABEL: 'test3'
72 ; CHECK-NEXT: Determining loop execution counts for: @test3
73 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
74 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 32
75 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 32
78 %init = load i32, ptr %init.ptr, !range !0
82 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
83 %iv.shift = ashr i32 %iv, 1
84 %exit.cond = icmp eq i32 %iv, 0
85 br i1 %exit.cond, label %leave, label %loop
91 define void @test4(ptr %init.ptr) {
93 ; CHECK-LABEL: 'test4'
94 ; CHECK-NEXT: Determining loop execution counts for: @test4
95 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
96 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 32
97 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 32
100 %init = load i32, ptr %init.ptr, !range !1
104 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
105 %iv.shift = ashr i32 %iv, 1
106 %exit.cond = icmp eq i32 %iv, -1
107 br i1 %exit.cond, label %leave, label %loop
113 define void @test5(ptr %init.ptr) {
115 ; %iv will "stabilize" to -1, so this is an infinite loop
116 ; CHECK-LABEL: 'test5'
117 ; CHECK-NEXT: Determining loop execution counts for: @test5
118 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
119 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
120 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
123 %init = load i32, ptr %init.ptr, !range !1
127 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
128 %iv.shift = ashr i32 %iv, 1
129 %exit.cond = icmp eq i32 %iv, 0
130 br i1 %exit.cond, label %leave, label %loop
136 define void @test6(i32 %init, i32 %shift.amt) {
138 ; Potentially infinite loop, since %shift.amt could be 0
139 ; CHECK-LABEL: 'test6'
140 ; CHECK-NEXT: Determining loop execution counts for: @test6
141 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
142 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
143 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
149 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
150 %iv.shift = lshr i32 %iv, %shift.amt
151 %exit.cond = icmp eq i32 %iv, 0
152 br i1 %exit.cond, label %leave, label %loop
158 define void @test7(i32 %init) {
160 ; CHECK-LABEL: 'test7'
161 ; CHECK-NEXT: Determining loop execution counts for: @test7
162 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
163 ; CHECK-NEXT: Loop %loop: constant max backedge-taken count is i32 32
164 ; CHECK-NEXT: Loop %loop: symbolic max backedge-taken count is i32 32
170 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
171 %iv.shift = lshr i32 %iv, 1
172 %exit.cond = icmp eq i32 %iv.shift, 0
173 br i1 %exit.cond, label %leave, label %loop
179 define void @test8(i32 %init) {
181 ; In this test case, %iv.test stabilizes to 127, not -1, so the loop
183 ; CHECK-LABEL: 'test8'
184 ; CHECK-NEXT: Determining loop execution counts for: @test8
185 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
186 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
187 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
193 %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
194 %iv.shift = ashr i32 %iv, 1
195 %iv.test = lshr i32 %iv, 1
196 %exit.cond = icmp eq i32 %iv.test, -1
197 br i1 %exit.cond, label %leave, label %loop
203 define void @test9() {
205 ; This is an infinite loop, make sure that it recognized as such.
206 ; CHECK-LABEL: 'test9'
207 ; CHECK-NEXT: Determining loop execution counts for: @test9
208 ; CHECK-NEXT: Loop %loop: Unpredictable backedge-taken count.
209 ; CHECK-NEXT: Loop %loop: Unpredictable constant max backedge-taken count.
210 ; CHECK-NEXT: Loop %loop: Unpredictable symbolic max backedge-taken count.
219 %iv = phi i32 [ -20, %entry ], [ %iv.shift, %loop ]
220 %iv.shift = ashr i32 %iv, 1
221 %exit.cond = icmp sgt i32 %iv, -1
222 br i1 %exit.cond, label %leave, label %loop
225 !0 = !{i32 0, i32 50000}
226 !1 = !{i32 -5000, i32 -1}