1 ; RUN: opt -mtriple=thumbv8.1m.main-arm-none-eabi -hardware-loops -disable-arm-loloops=false %s -S -o - | FileCheck %s
3 @g = common local_unnamed_addr global i32* null, align 4
5 ; CHECK-LABEL: do_with_i32_urem
7 ; CHECK: [[TEST:%[^ ]+]] = call i1 @llvm.test.set.loop.iterations.i32(i32 %n)
8 ; CHECK: br i1 [[TEST]], label %while.body.preheader, label %while.end
10 ; CHECK: while.body.preheader:
11 ; CHECK-NEXT: br label %while.body
14 ; CHECK: [[REM:%[^ ]+]] = phi i32 [ %n, %while.body.preheader ], [ [[LOOP_DEC:%[^ ]+]], %while.body ]
15 ; CHECK: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
16 ; CHECK: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
17 ; CHECK: br i1 [[CMP]], label %while.body, label %while.end.loopexit
19 define i32 @do_with_i32_urem(i32 %n) {
21 %cmp7 = icmp eq i32 %n, 0
22 br i1 %cmp7, label %while.end, label %while.body.preheader
28 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
29 %res.08 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]
30 %rem = urem i32 %i.09, 5
31 %add = add i32 %rem, %res.08
32 %inc1 = add nuw i32 %i.09, 1
33 %exitcond = icmp eq i32 %inc1, %n
34 br i1 %exitcond, label %while.end.loopexit, label %while.body
40 %res.0.lcssa = phi i32 [ 0, %entry ], [ %add, %while.end.loopexit ]
44 ; CHECK-LABEL: do_with_i32_srem
46 ; CHECK: [[TEST:%[^ ]+]] = call i1 @llvm.test.set.loop.iterations.i32(i32 %n)
47 ; CHECK: br i1 [[TEST]], label %while.body.preheader, label %while.end
49 ; CHECK: while.body.preheader:
50 ; CHECK-NEXT: br label %while.body
53 ; CHECK: [[REM:%[^ ]+]] = phi i32 [ %n, %while.body.preheader ], [ [[LOOP_DEC:%[^ ]+]], %while.body ]
54 ; CHECK: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
55 ; CHECK: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
56 ; CHECK: br i1 [[CMP]], label %while.body, label %while.end.loopexit
58 define i32 @do_with_i32_srem(i32 %n) {
60 %cmp7 = icmp eq i32 %n, 0
61 br i1 %cmp7, label %while.end, label %while.body.preheader
67 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
68 %res.08 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]
69 %rem = srem i32 %i.09, 5
70 %add = sub i32 %rem, %res.08
71 %inc1 = add nuw i32 %i.09, 1
72 %exitcond = icmp eq i32 %inc1, %n
73 br i1 %exitcond, label %while.end.loopexit, label %while.body
79 %res.0.lcssa = phi i32 [ 0, %entry ], [ %add, %while.end.loopexit ]
83 ; CHECK-LABEL: do_with_i32_udiv
85 ; CHECK: [[TEST:%[^ ]+]] = call i1 @llvm.test.set.loop.iterations.i32(i32 %n)
86 ; CHECK: br i1 [[TEST]], label %while.body.preheader, label %while.end
88 ; CHECK: while.body.preheader:
89 ; CHECK-NEXT: br label %while.body
92 ; CHECK: [[REM:%[^ ]+]] = phi i32 [ %n, %while.body.preheader ], [ [[LOOP_DEC:%[^ ]+]], %while.body ]
93 ; CHECK: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
94 ; CHECK: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
95 ; CHECK: br i1 [[CMP]], label %while.body, label %while.end.loopexit
97 define i32 @do_with_i32_udiv(i32 %n) {
99 %cmp7 = icmp eq i32 %n, 0
100 br i1 %cmp7, label %while.end, label %while.body.preheader
102 while.body.preheader:
106 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
107 %res.08 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]
108 %rem = udiv i32 %i.09, 5
109 %add = add i32 %rem, %res.08
110 %inc1 = add nuw i32 %i.09, 1
111 %exitcond = icmp eq i32 %inc1, %n
112 br i1 %exitcond, label %while.end.loopexit, label %while.body
118 %res.0.lcssa = phi i32 [ 0, %entry ], [ %add, %while.end.loopexit ]
122 ; CHECK-LABEL: do_with_i32_sdiv
124 ; CHECK: [[TEST:%[^ ]+]] = call i1 @llvm.test.set.loop.iterations.i32(i32 %n)
125 ; CHECK: br i1 [[TEST]], label %while.body.preheader, label %while.end
127 ; CHECK: while.body.preheader:
128 ; CHECK-NEXT: br label %while.body
131 ; CHECK: [[REM:%[^ ]+]] = phi i32 [ %n, %while.body.preheader ], [ [[LOOP_DEC:%[^ ]+]], %while.body ]
132 ; CHECK: [[LOOP_DEC]] = call i32 @llvm.loop.decrement.reg.i32.i32.i32(i32 [[REM]], i32 1)
133 ; CHECK: [[CMP:%[^ ]+]] = icmp ne i32 [[LOOP_DEC]], 0
134 ; CHECK: br i1 [[CMP]], label %while.body, label %while.end.loopexit
136 define i32 @do_with_i32_sdiv(i32 %n) {
138 %cmp7 = icmp eq i32 %n, 0
139 br i1 %cmp7, label %while.end, label %while.body.preheader
141 while.body.preheader:
145 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
146 %res.08 = phi i32 [ %add, %while.body ], [ 0, %while.body.preheader ]
147 %rem = sdiv i32 %i.09, 5
148 %add = sub i32 %rem, %res.08
149 %inc1 = add nuw i32 %i.09, 1
150 %exitcond = icmp eq i32 %inc1, %n
151 br i1 %exitcond, label %while.end.loopexit, label %while.body
157 %res.0.lcssa = phi i32 [ 0, %entry ], [ %add, %while.end.loopexit ]
161 ; CHECK-LABEL: do_with_i64_urem
162 ; CHECK-NOT: llvm.{{.*}}.loop.iterations
163 ; CHECK-NOT: llvm.loop.decrement
164 define i64 @do_with_i64_urem(i32 %n) {
166 %cmp7 = icmp eq i32 %n, 0
167 br i1 %cmp7, label %while.end, label %while.body.preheader
169 while.body.preheader:
173 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
174 %res.08 = phi i64 [ %add, %while.body ], [ 0, %while.body.preheader ]
175 %conv = zext i32 %i.09 to i64
176 %rem = urem i64 %conv, 5
177 %add = add i64 %rem, %res.08
178 %inc1 = add nuw i32 %i.09, 1
179 %exitcond = icmp eq i32 %inc1, %n
180 br i1 %exitcond, label %while.end.loopexit, label %while.body
186 %res.0.lcssa = phi i64 [ 0, %entry ], [ %add, %while.end.loopexit ]
190 ; CHECK-LABEL: do_with_i64_srem
191 ; CHECK-NOT: llvm.{{.*}}.loop.iterations
192 ; CHECK-NOT: llvm.loop.decrement
193 define i64 @do_with_i64_srem(i32 %n) {
195 %cmp7 = icmp eq i32 %n, 0
196 br i1 %cmp7, label %while.end, label %while.body.preheader
198 while.body.preheader:
202 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
203 %res.08 = phi i64 [ %add, %while.body ], [ 0, %while.body.preheader ]
204 %conv = zext i32 %i.09 to i64
205 %rem = srem i64 %conv, 5
206 %add = sub i64 %rem, %res.08
207 %inc1 = add nuw i32 %i.09, 1
208 %exitcond = icmp eq i32 %inc1, %n
209 br i1 %exitcond, label %while.end.loopexit, label %while.body
215 %res.0.lcssa = phi i64 [ 0, %entry ], [ %add, %while.end.loopexit ]
219 ; CHECK-LABEL: do_with_i64_udiv
220 ; CHECK-NOT: llvm.{{.*}}.loop.iterations
221 ; CHECK-NOT: llvm.loop.decrement
222 define i64 @do_with_i64_udiv(i32 %n) {
224 %cmp7 = icmp eq i32 %n, 0
225 br i1 %cmp7, label %while.end, label %while.body.preheader
227 while.body.preheader:
231 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
232 %res.08 = phi i64 [ %add, %while.body ], [ 0, %while.body.preheader ]
233 %conv = zext i32 %i.09 to i64
234 %rem = udiv i64 %conv, 5
235 %add = add i64 %rem, %res.08
236 %inc1 = add nuw i32 %i.09, 1
237 %exitcond = icmp eq i32 %inc1, %n
238 br i1 %exitcond, label %while.end.loopexit, label %while.body
244 %res.0.lcssa = phi i64 [ 0, %entry ], [ %add, %while.end.loopexit ]
248 ; CHECK-LABEL: do_with_i64_sdiv
249 ; CHECK-NOT: call void @llvm.{{.*}}.loop.iterations
250 ; CHECK-NOT: call i32 @llvm.loop.decrement
251 define i64 @do_with_i64_sdiv(i32 %n) {
253 %cmp7 = icmp eq i32 %n, 0
254 br i1 %cmp7, label %while.end, label %while.body.preheader
256 while.body.preheader:
260 %i.09 = phi i32 [ %inc1, %while.body ], [ 0, %while.body.preheader ]
261 %res.08 = phi i64 [ %add, %while.body ], [ 0, %while.body.preheader ]
262 %conv = zext i32 %i.09 to i64
263 %rem = sdiv i64 %conv, 5
264 %add = sub i64 %rem, %res.08
265 %inc1 = add nuw i32 %i.09, 1
266 %exitcond = icmp eq i32 %inc1, %n
267 br i1 %exitcond, label %while.end.loopexit, label %while.body
273 %res.0.lcssa = phi i64 [ 0, %entry ], [ %add, %while.end.loopexit ]