File: shift-op.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.4-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,488 kB
  • sloc: cpp: 6,951,470; ansic: 1,486,052; asm: 913,550; python: 232,020; f90: 80,126; objc: 75,349; lisp: 37,276; pascal: 16,990; sh: 9,935; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,164; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (226 lines) | stat: -rw-r--r-- 6,356 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
; RUN: opt -disable-output "-passes=print<scalar-evolution>" -scalar-evolution-classify-expressions=0 < %s 2>&1 | FileCheck %s

define void @test0(i32 %init) {
;
; CHECK-LABEL: 'test0'
; CHECK-NEXT:  Determining loop execution counts for: @test0
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 32
; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 32
;
 entry:
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = lshr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test1(i32 %init) {
;
; CHECK-LABEL: 'test1'
; CHECK-NEXT:  Determining loop execution counts for: @test1
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 32
; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 32
;
 entry:
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = shl i32 %iv, 1
  %exit.cond = icmp eq i32 %iv, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test2(i32 %init) {
;
; Unpredictable because %iv could "stabilize" to either -1 or 0,
; depending on %init.
; CHECK-LABEL: 'test2'
; CHECK-NEXT:  Determining loop execution counts for: @test2
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable constant max backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable symbolic max backedge-taken count.
;
 entry:
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = ashr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test3(ptr %init.ptr) {
;
; CHECK-LABEL: 'test3'
; CHECK-NEXT:  Determining loop execution counts for: @test3
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 32
; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 32
;
 entry:
  %init = load i32, ptr %init.ptr, !range !0
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = ashr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test4(ptr %init.ptr) {
;
; CHECK-LABEL: 'test4'
; CHECK-NEXT:  Determining loop execution counts for: @test4
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 32
; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 32
;
 entry:
  %init = load i32, ptr %init.ptr, !range !1
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = ashr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv, -1
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test5(ptr %init.ptr) {
;
; %iv will "stabilize" to -1, so this is an infinite loop
; CHECK-LABEL: 'test5'
; CHECK-NEXT:  Determining loop execution counts for: @test5
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable constant max backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable symbolic max backedge-taken count.
;
 entry:
  %init = load i32, ptr %init.ptr, !range !1
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = ashr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test6(i32 %init, i32 %shift.amt) {
;
; Potentially infinite loop, since %shift.amt could be 0
; CHECK-LABEL: 'test6'
; CHECK-NEXT:  Determining loop execution counts for: @test6
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable constant max backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable symbolic max backedge-taken count.
;
 entry:
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = lshr i32 %iv, %shift.amt
  %exit.cond = icmp eq i32 %iv, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test7(i32 %init) {
;
; CHECK-LABEL: 'test7'
; CHECK-NEXT:  Determining loop execution counts for: @test7
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: constant max backedge-taken count is i32 32
; CHECK-NEXT:  Loop %loop: symbolic max backedge-taken count is i32 32
;
 entry:
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = lshr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv.shift, 0
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test8(i32 %init) {
;
; In this test case, %iv.test stabilizes to 127, not -1, so the loop
; is infinite.
; CHECK-LABEL: 'test8'
; CHECK-NEXT:  Determining loop execution counts for: @test8
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable constant max backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable symbolic max backedge-taken count.
;
 entry:
  br label %loop

 loop:
  %iv = phi i32 [ %init, %entry ], [ %iv.shift, %loop ]
  %iv.shift = ashr i32 %iv, 1
  %iv.test = lshr i32 %iv, 1
  %exit.cond = icmp eq i32 %iv.test, -1
  br i1 %exit.cond, label %leave, label %loop

 leave:
  ret void
}

define void @test9() {
;
; This is an infinite loop, make sure that it recognized as such.
; CHECK-LABEL: 'test9'
; CHECK-NEXT:  Determining loop execution counts for: @test9
; CHECK-NEXT:  Loop %loop: Unpredictable backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable constant max backedge-taken count.
; CHECK-NEXT:  Loop %loop: Unpredictable symbolic max backedge-taken count.
;
entry:
  br label %loop

leave:
  ret void

loop:
  %iv = phi i32 [ -20, %entry ], [ %iv.shift, %loop ]
  %iv.shift = ashr i32 %iv, 1
  %exit.cond = icmp sgt i32 %iv, -1
  br i1 %exit.cond, label %leave, label %loop
}

!0 = !{i32 0, i32 50000}
!1 = !{i32 -5000, i32 -1}