1 # RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=+hwdiv-arm -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,HWDIV
2 # RUN: llc -O0 -mtriple arm-linux-gnueabi -mattr=-hwdiv-arm -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,SOFT,SOFT-AEABI,ARM-AEABI
3 # RUN: llc -O0 -mtriple arm-linux-gnu -mattr=+hwdiv-arm -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,HWDIV
4 # RUN: llc -O0 -mtriple arm-linux-gnu -mattr=-hwdiv-arm -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,SOFT,SOFT-DEFAULT,ARM-DEFAULT
5 # RUN: llc -O0 -mtriple thumb-linux-gnueabi -mattr=+v6t2,+hwdiv -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,HWDIV
6 # RUN: llc -O0 -mtriple thumb-linux-gnueabi -mattr=+v6t2,-hwdiv -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,SOFT,SOFT-AEABI,THUMB-AEABI
7 # RUN: llc -O0 -mtriple thumb-linux-gnu -mattr=+v6t2,+hwdiv -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,HWDIV
8 # RUN: llc -O0 -mtriple thumb-linux-gnu -mattr=+v6t2,-hwdiv -run-pass=legalizer %s -o - | FileCheck %s -check-prefixes=CHECK,SOFT,SOFT-DEFAULT,THUMB-DEFAULT
10 define void @test_sdiv_i32() { ret void }
11 define void @test_udiv_i32() { ret void }
13 define void @test_sdiv_i16() { ret void }
14 define void @test_udiv_i16() { ret void }
16 define void @test_sdiv_i8() { ret void }
17 define void @test_udiv_i8() { ret void }
19 define void @test_srem_i32() { ret void }
20 define void @test_urem_i32() { ret void }
22 define void @test_srem_i16() { ret void }
23 define void @test_urem_i16() { ret void }
25 define void @test_srem_i8() { ret void }
26 define void @test_urem_i8() { ret void }
30 # CHECK-LABEL: name: test_sdiv_i32
32 # CHECK: legalized: true
33 regBankSelected: false
35 tracksRegLiveness: true
44 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
45 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
48 ; HWDIV: [[R:%[0-9]+]]:_(s32) = G_SDIV [[X]], [[Y]]
50 ; SOFT: ADJCALLSTACKDOWN
51 ; SOFT-DAG: $r0 = COPY [[X]]
52 ; SOFT-DAG: $r1 = COPY [[Y]]
53 ; ARM-AEABI: BL &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
54 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
55 ; ARM-DEFAULT: BL &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
56 ; THUMB-DEFAULT: tBL 14, $noreg, &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
57 ; SOFT: [[R:%[0-9]+]]:_(s32) = COPY $r0
58 ; SOFT: ADJCALLSTACKUP
60 %2(s32) = G_SDIV %0, %1
61 ; CHECK: $r0 = COPY [[R]]
63 BX_RET 14, $noreg, implicit $r0
67 # CHECK-LABEL: name: test_udiv_i32
69 # CHECK: legalized: true
70 regBankSelected: false
72 tracksRegLiveness: true
81 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
82 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
85 ; HWDIV: [[R:%[0-9]+]]:_(s32) = G_UDIV [[X]], [[Y]]
87 ; SOFT: ADJCALLSTACKDOWN
88 ; SOFT-DAG: $r0 = COPY [[X]]
89 ; SOFT-DAG: $r1 = COPY [[Y]]
90 ; ARM-AEABI: BL &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
91 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
92 ; ARM-DEFAULT: BL &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
93 ; THUMB-DEFAULT: tBL 14, $noreg, &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
94 ; SOFT: [[R:%[0-9]+]]:_(s32) = COPY $r0
95 ; SOFT: ADJCALLSTACKUP
97 %2(s32) = G_UDIV %0, %1
98 ; CHECK: $r0 = COPY [[R]]
100 BX_RET 14, $noreg, implicit $r0
104 # CHECK-LABEL: name: test_sdiv_i16
106 # CHECK: legalized: true
107 regBankSelected: false
109 tracksRegLiveness: true
111 - { id: 0, class: _ }
112 - { id: 1, class: _ }
113 - { id: 2, class: _ }
114 - { id: 3, class: _ }
115 - { id: 4, class: _ }
116 - { id: 5, class: _ }
121 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
122 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
123 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
124 ; leading to the following complicated sequences.
125 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
126 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
127 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
128 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
129 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
130 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
131 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
133 %1(s16) = G_TRUNC %0(s32)
135 %3(s16) = G_TRUNC %2(s32)
136 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
138 ; SOFT: ADJCALLSTACKDOWN
139 ; SOFT-DAG: $r0 = COPY [[X32]]
140 ; SOFT-DAG: $r1 = COPY [[Y32]]
141 ; ARM-AEABI: BL &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
142 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
143 ; ARM-DEFAULT: BL &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
144 ; THUMB-DEFAULT: tBL 14, $noreg, &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
145 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
146 ; SOFT: ADJCALLSTACKUP
148 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
150 %4(s16) = G_SDIV %1, %3
151 ; CHECK: $r0 = COPY [[R]]
152 %5(s32) = G_SEXT %4(s16)
154 BX_RET 14, $noreg, implicit $r0
158 # CHECK-LABEL: name: test_udiv_i16
160 # CHECK: legalized: true
161 regBankSelected: false
163 tracksRegLiveness: true
165 - { id: 0, class: _ }
166 - { id: 1, class: _ }
167 - { id: 2, class: _ }
168 - { id: 3, class: _ }
169 - { id: 4, class: _ }
170 - { id: 5, class: _ }
175 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
176 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
177 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
178 ; leading to the following complicated sequences.
179 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
180 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
181 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
182 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
183 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
185 %1(s16) = G_TRUNC %0(s32)
187 %3(s16) = G_TRUNC %2(s32)
188 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
190 ; SOFT: ADJCALLSTACKDOWN
191 ; SOFT-DAG: $r0 = COPY [[X32]]
192 ; SOFT-DAG: $r1 = COPY [[Y32]]
193 ; ARM-AEABI: BL &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
194 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
195 ; ARM-DEFAULT: BL &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
196 ; THUMB-DEFAULT: tBL 14, $noreg, &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
197 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
198 ; SOFT: ADJCALLSTACKUP
200 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
202 %4(s16) = G_UDIV %1, %3
203 ; CHECK: $r0 = COPY [[R]]
204 %5(s32) = G_ZEXT %4(s16)
206 BX_RET 14, $noreg, implicit $r0
210 # CHECK-LABEL: name: test_sdiv_i8
212 # CHECK: legalized: true
213 regBankSelected: false
215 tracksRegLiveness: true
217 - { id: 0, class: _ }
218 - { id: 1, class: _ }
219 - { id: 2, class: _ }
220 - { id: 3, class: _ }
221 - { id: 4, class: _ }
222 - { id: 5, class: _ }
227 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
228 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
229 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
230 ; leading to the following complicated sequences.
231 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
232 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
233 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
234 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
235 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
236 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
237 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
239 %1(s8) = G_TRUNC %0(s32)
241 %3(s8) = G_TRUNC %2(s32)
242 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
244 ; SOFT: ADJCALLSTACKDOWN
245 ; SOFT-DAG: $r0 = COPY [[X32]]
246 ; SOFT-DAG: $r1 = COPY [[Y32]]
247 ; ARM-AEABI: BL &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
248 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
249 ; ARM-DEFAULT: BL &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
250 ; THUMB-DEFAULT: tBL 14, $noreg, &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
251 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
252 ; SOFT: ADJCALLSTACKUP
254 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
256 %4(s8) = G_SDIV %1, %3
257 ; CHECK: $r0 = COPY [[R]]
258 %5(s32) = G_SEXT %4(s8)
260 BX_RET 14, $noreg, implicit $r0
264 # CHECK-LABEL: name: test_udiv_i8
266 # CHECK: legalized: true
267 regBankSelected: false
269 tracksRegLiveness: true
271 - { id: 0, class: _ }
272 - { id: 1, class: _ }
273 - { id: 2, class: _ }
274 - { id: 3, class: _ }
275 - { id: 4, class: _ }
276 - { id: 5, class: _ }
281 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
282 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
283 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
284 ; leading to the following complicated sequences.
285 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
286 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
287 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
288 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
289 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
291 %1(s8) = G_TRUNC %0(s32)
293 %3(s8) = G_TRUNC %2(s32)
294 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
296 ; SOFT: ADJCALLSTACKDOWN
297 ; SOFT-DAG: $r0 = COPY [[X32]]
298 ; SOFT-DAG: $r1 = COPY [[Y32]]
299 ; ARM-AEABI: BL &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
300 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
301 ; ARM-DEFAULT: BL &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
302 ; THUMB-DEFAULT: tBL 14, $noreg, &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
303 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
304 ; SOFT: ADJCALLSTACKUP
306 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
308 %4(s8) = G_UDIV %1, %3
309 ; CHECK: $r0 = COPY [[R]]
310 %5(s32) = G_ZEXT %4(s8)
312 BX_RET 14, $noreg, implicit $r0
316 # CHECK-LABEL: name: test_srem_i32
318 # CHECK: legalized: true
319 regBankSelected: false
321 tracksRegLiveness: true
323 - { id: 0, class: _ }
324 - { id: 1, class: _ }
325 - { id: 2, class: _ }
330 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
331 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
334 ; HWDIV: [[Q:%[0-9]+]]:_(s32) = G_SDIV [[X]], [[Y]]
335 ; HWDIV: [[P:%[0-9]+]]:_(s32) = G_MUL [[Q]], [[Y]]
336 ; HWDIV: [[R:%[0-9]+]]:_(s32) = G_SUB [[X]], [[P]]
338 ; SOFT: ADJCALLSTACKDOWN
339 ; SOFT-DAG: $r0 = COPY [[X]]
340 ; SOFT-DAG: $r1 = COPY [[Y]]
341 ; ARM-AEABI: BL &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
342 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
343 ; SOFT-AEABI: [[R:%[0-9]+]]:_(s32) = COPY $r1
344 ; ARM-DEFAULT: BL &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
345 ; THUMB-DEFAULT: tBL 14, $noreg, &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
346 ; SOFT-DEFAULT: [[R:%[0-9]+]]:_(s32) = COPY $r0
347 ; SOFT: ADJCALLSTACKUP
349 %2(s32) = G_SREM %0, %1
350 ; CHECK: $r0 = COPY [[R]]
352 BX_RET 14, $noreg, implicit $r0
356 # CHECK-LABEL: name: test_urem_i32
358 # CHECK: legalized: true
359 regBankSelected: false
361 tracksRegLiveness: true
363 - { id: 0, class: _ }
364 - { id: 1, class: _ }
365 - { id: 2, class: _ }
370 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
371 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
374 ; HWDIV: [[Q:%[0-9]+]]:_(s32) = G_UDIV [[X]], [[Y]]
375 ; HWDIV: [[P:%[0-9]+]]:_(s32) = G_MUL [[Q]], [[Y]]
376 ; HWDIV: [[R:%[0-9]+]]:_(s32) = G_SUB [[X]], [[P]]
378 ; SOFT: ADJCALLSTACKDOWN
379 ; SOFT-DAG: $r0 = COPY [[X]]
380 ; SOFT-DAG: $r1 = COPY [[Y]]
381 ; ARM-AEABI: BL &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
382 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
383 ; SOFT-AEABI: [[R:%[0-9]+]]:_(s32) = COPY $r1
384 ; ARM-DEFAULT: BL &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
385 ; THUMB-DEFAULT: tBL 14, $noreg, &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
386 ; SOFT-DEFAULT: [[R:%[0-9]+]]:_(s32) = COPY $r0
387 ; SOFT: ADJCALLSTACKUP
389 %2(s32) = G_UREM %0, %1
390 ; CHECK: $r0 = COPY [[R]]
392 BX_RET 14, $noreg, implicit $r0
396 # CHECK-LABEL: name: test_srem_i16
398 # CHECK: legalized: true
399 regBankSelected: false
401 tracksRegLiveness: true
403 - { id: 0, class: _ }
404 - { id: 1, class: _ }
405 - { id: 2, class: _ }
406 - { id: 3, class: _ }
407 - { id: 4, class: _ }
408 - { id: 5, class: _ }
413 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
414 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
415 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
416 ; leading to the following complicated sequences.
417 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
418 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
419 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
420 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
421 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
422 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
423 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
425 %1(s16) = G_TRUNC %0(s32)
427 %3(s16) = G_TRUNC %2(s32)
428 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
429 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
430 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
432 ; SOFT: ADJCALLSTACKDOWN
433 ; SOFT-DAG: $r0 = COPY [[X32]]
434 ; SOFT-DAG: $r1 = COPY [[Y32]]
435 ; ARM-AEABI: BL &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
436 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
437 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
438 ; ARM-DEFAULT: BL &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
439 ; THUMB-DEFAULT: tBL 14, $noreg, &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
440 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
441 ; SOFT: ADJCALLSTACKUP
443 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
445 %4(s16) = G_SREM %1, %3
446 ; CHECK: $r0 = COPY [[R]]
447 %5(s32) = G_SEXT %4(s16)
449 BX_RET 14, $noreg, implicit $r0
453 # CHECK-LABEL: name: test_urem_i16
455 # CHECK: legalized: true
456 regBankSelected: false
458 tracksRegLiveness: true
460 - { id: 0, class: _ }
461 - { id: 1, class: _ }
462 - { id: 2, class: _ }
463 - { id: 3, class: _ }
464 - { id: 4, class: _ }
465 - { id: 5, class: _ }
470 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
471 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
472 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
473 ; leading to the following complicated sequences.
474 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
475 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
476 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
477 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
478 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
480 %1(s16) = G_TRUNC %0(s32)
482 %3(s16) = G_TRUNC %2(s32)
483 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
484 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
485 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
487 ; SOFT: ADJCALLSTACKDOWN
488 ; SOFT-DAG: $r0 = COPY [[X32]]
489 ; SOFT-DAG: $r1 = COPY [[Y32]]
490 ; ARM-AEABI: BL &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
491 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
492 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
493 ; ARM-DEFAULT: BL &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
494 ; THUMB-DEFAULT: tBL 14, $noreg, &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
495 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
496 ; SOFT: ADJCALLSTACKUP
498 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
500 %4(s16) = G_UREM %1, %3
501 ; CHECK: $r0 = COPY [[R]]
502 %5(s32) = G_ZEXT %4(s16)
504 BX_RET 14, $noreg, implicit $r0
508 # CHECK-LABEL: name: test_srem_i8
510 # CHECK: legalized: true
511 regBankSelected: false
513 tracksRegLiveness: true
515 - { id: 0, class: _ }
516 - { id: 1, class: _ }
517 - { id: 2, class: _ }
518 - { id: 3, class: _ }
519 - { id: 4, class: _ }
520 - { id: 5, class: _ }
525 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
526 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
527 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
528 ; leading to the following complicated sequences.
529 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
530 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
531 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
532 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
533 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
534 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
535 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
537 %1(s8) = G_TRUNC %0(s32)
539 %3(s8) = G_TRUNC %2(s32)
540 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
541 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
542 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
544 ; SOFT: ADJCALLSTACKDOWN
545 ; SOFT-DAG: $r0 = COPY [[X32]]
546 ; SOFT-DAG: $r1 = COPY [[Y32]]
547 ; ARM-AEABI: BL &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
548 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
549 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
550 ; ARM-DEFAULT: BL &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
551 ; THUMB-DEFAULT: tBL 14, $noreg, &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
552 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
553 ; SOFT: ADJCALLSTACKUP
555 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
557 %4(s8) = G_SREM %1, %3
558 ; CHECK: $r0 = COPY [[R]]
559 %5(s32) = G_SEXT %4(s8)
561 BX_RET 14, $noreg, implicit $r0
565 # CHECK-LABEL: name: test_urem_i8
567 # CHECK: legalized: true
568 regBankSelected: false
570 tracksRegLiveness: true
572 - { id: 0, class: _ }
573 - { id: 1, class: _ }
574 - { id: 2, class: _ }
575 - { id: 3, class: _ }
576 - { id: 4, class: _ }
577 - { id: 5, class: _ }
582 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
583 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
584 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
585 ; leading to the following complicated sequences.
586 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
587 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
588 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
589 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
590 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
592 %1(s8) = G_TRUNC %0(s32)
594 %3(s8) = G_TRUNC %2(s32)
595 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
596 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
597 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
599 ; SOFT: ADJCALLSTACKDOWN
600 ; SOFT-DAG: $r0 = COPY [[X32]]
601 ; SOFT-DAG: $r1 = COPY [[Y32]]
602 ; ARM-AEABI: BL &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
603 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
604 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
605 ; ARM-DEFAULT: BL &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
606 ; THUMB-DEFAULT: tBL 14, $noreg, &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
607 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
608 ; SOFT: ADJCALLSTACKUP
610 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
612 %4(s8) = G_UREM %1, %3
613 ; CHECK: $r0 = COPY [[R]]
614 %5(s32) = G_ZEXT %4(s8)
616 BX_RET 14, $noreg, implicit $r0