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: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
130 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
131 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
132 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
134 %1(s16) = G_TRUNC %0(s32)
136 %3(s16) = G_TRUNC %2(s32)
137 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
139 ; SOFT: ADJCALLSTACKDOWN
140 ; SOFT-DAG: $r0 = COPY [[X32]]
141 ; SOFT-DAG: $r1 = COPY [[Y32]]
142 ; ARM-AEABI: BL &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
143 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
144 ; ARM-DEFAULT: BL &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
145 ; THUMB-DEFAULT: tBL 14, $noreg, &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
146 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
147 ; SOFT: ADJCALLSTACKUP
149 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
151 %4(s16) = G_SDIV %1, %3
152 ; CHECK: $r0 = COPY [[R]]
153 %5(s32) = G_SEXT %4(s16)
155 BX_RET 14, $noreg, implicit $r0
159 # CHECK-LABEL: name: test_udiv_i16
161 # CHECK: legalized: true
162 regBankSelected: false
164 tracksRegLiveness: true
166 - { id: 0, class: _ }
167 - { id: 1, class: _ }
168 - { id: 2, class: _ }
169 - { id: 3, class: _ }
170 - { id: 4, class: _ }
171 - { id: 5, class: _ }
176 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
177 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
178 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
179 ; leading to the following complicated sequences.
180 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
181 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
182 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
183 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
184 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
185 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
187 %1(s16) = G_TRUNC %0(s32)
189 %3(s16) = G_TRUNC %2(s32)
190 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
192 ; SOFT: ADJCALLSTACKDOWN
193 ; SOFT-DAG: $r0 = COPY [[X32]]
194 ; SOFT-DAG: $r1 = COPY [[Y32]]
195 ; ARM-AEABI: BL &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
196 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
197 ; ARM-DEFAULT: BL &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
198 ; THUMB-DEFAULT: tBL 14, $noreg, &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
199 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
200 ; SOFT: ADJCALLSTACKUP
202 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
204 %4(s16) = G_UDIV %1, %3
205 ; CHECK: $r0 = COPY [[R]]
206 %5(s32) = G_ZEXT %4(s16)
208 BX_RET 14, $noreg, implicit $r0
212 # CHECK-LABEL: name: test_sdiv_i8
214 # CHECK: legalized: true
215 regBankSelected: false
217 tracksRegLiveness: true
219 - { id: 0, class: _ }
220 - { id: 1, class: _ }
221 - { id: 2, class: _ }
222 - { id: 3, class: _ }
223 - { id: 4, class: _ }
224 - { id: 5, class: _ }
229 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
230 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
231 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
232 ; leading to the following complicated sequences.
233 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
234 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
235 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
236 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
237 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
238 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
239 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
240 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
242 %1(s8) = G_TRUNC %0(s32)
244 %3(s8) = G_TRUNC %2(s32)
245 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
247 ; SOFT: ADJCALLSTACKDOWN
248 ; SOFT-DAG: $r0 = COPY [[X32]]
249 ; SOFT-DAG: $r1 = COPY [[Y32]]
250 ; ARM-AEABI: BL &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
251 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
252 ; ARM-DEFAULT: BL &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
253 ; THUMB-DEFAULT: tBL 14, $noreg, &__divsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
254 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
255 ; SOFT: ADJCALLSTACKUP
257 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
259 %4(s8) = G_SDIV %1, %3
260 ; CHECK: $r0 = COPY [[R]]
261 %5(s32) = G_SEXT %4(s8)
263 BX_RET 14, $noreg, implicit $r0
267 # CHECK-LABEL: name: test_udiv_i8
269 # CHECK: legalized: true
270 regBankSelected: false
272 tracksRegLiveness: true
274 - { id: 0, class: _ }
275 - { id: 1, class: _ }
276 - { id: 2, class: _ }
277 - { id: 3, class: _ }
278 - { id: 4, class: _ }
279 - { id: 5, class: _ }
284 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
285 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
286 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
287 ; leading to the following complicated sequences.
288 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
289 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
290 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
291 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
292 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
293 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
295 %1(s8) = G_TRUNC %0(s32)
297 %3(s8) = G_TRUNC %2(s32)
298 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
300 ; SOFT: ADJCALLSTACKDOWN
301 ; SOFT-DAG: $r0 = COPY [[X32]]
302 ; SOFT-DAG: $r1 = COPY [[Y32]]
303 ; ARM-AEABI: BL &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
304 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidiv, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
305 ; ARM-DEFAULT: BL &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
306 ; THUMB-DEFAULT: tBL 14, $noreg, &__udivsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
307 ; SOFT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
308 ; SOFT: ADJCALLSTACKUP
310 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
312 %4(s8) = G_UDIV %1, %3
313 ; CHECK: $r0 = COPY [[R]]
314 %5(s32) = G_ZEXT %4(s8)
316 BX_RET 14, $noreg, implicit $r0
320 # CHECK-LABEL: name: test_srem_i32
322 # CHECK: legalized: true
323 regBankSelected: false
325 tracksRegLiveness: true
327 - { id: 0, class: _ }
328 - { id: 1, class: _ }
329 - { id: 2, class: _ }
334 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
335 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
338 ; HWDIV: [[Q:%[0-9]+]]:_(s32) = G_SDIV [[X]], [[Y]]
339 ; HWDIV: [[P:%[0-9]+]]:_(s32) = G_MUL [[Q]], [[Y]]
340 ; HWDIV: [[R:%[0-9]+]]:_(s32) = G_SUB [[X]], [[P]]
342 ; SOFT: ADJCALLSTACKDOWN
343 ; SOFT-DAG: $r0 = COPY [[X]]
344 ; SOFT-DAG: $r1 = COPY [[Y]]
345 ; ARM-AEABI: BL &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
346 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
347 ; SOFT-AEABI: [[R:%[0-9]+]]:_(s32) = COPY $r1
348 ; ARM-DEFAULT: BL &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
349 ; THUMB-DEFAULT: tBL 14, $noreg, &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
350 ; SOFT-DEFAULT: [[R:%[0-9]+]]:_(s32) = COPY $r0
351 ; SOFT: ADJCALLSTACKUP
353 %2(s32) = G_SREM %0, %1
354 ; CHECK: $r0 = COPY [[R]]
356 BX_RET 14, $noreg, implicit $r0
360 # CHECK-LABEL: name: test_urem_i32
362 # CHECK: legalized: true
363 regBankSelected: false
365 tracksRegLiveness: true
367 - { id: 0, class: _ }
368 - { id: 1, class: _ }
369 - { id: 2, class: _ }
374 ; CHECK-DAG: [[X:%[0-9]+]]:_(s32) = COPY $r0
375 ; CHECK-DAG: [[Y:%[0-9]+]]:_(s32) = COPY $r1
378 ; HWDIV: [[Q:%[0-9]+]]:_(s32) = G_UDIV [[X]], [[Y]]
379 ; HWDIV: [[P:%[0-9]+]]:_(s32) = G_MUL [[Q]], [[Y]]
380 ; HWDIV: [[R:%[0-9]+]]:_(s32) = G_SUB [[X]], [[P]]
382 ; SOFT: ADJCALLSTACKDOWN
383 ; SOFT-DAG: $r0 = COPY [[X]]
384 ; SOFT-DAG: $r1 = COPY [[Y]]
385 ; ARM-AEABI: BL &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
386 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0, implicit-def $r1
387 ; SOFT-AEABI: [[R:%[0-9]+]]:_(s32) = COPY $r1
388 ; ARM-DEFAULT: BL &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
389 ; THUMB-DEFAULT: tBL 14, $noreg, &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
390 ; SOFT-DEFAULT: [[R:%[0-9]+]]:_(s32) = COPY $r0
391 ; SOFT: ADJCALLSTACKUP
393 %2(s32) = G_UREM %0, %1
394 ; CHECK: $r0 = COPY [[R]]
396 BX_RET 14, $noreg, implicit $r0
400 # CHECK-LABEL: name: test_srem_i16
402 # CHECK: legalized: true
403 regBankSelected: false
405 tracksRegLiveness: true
407 - { id: 0, class: _ }
408 - { id: 1, class: _ }
409 - { id: 2, class: _ }
410 - { id: 3, class: _ }
411 - { id: 4, class: _ }
412 - { id: 5, class: _ }
417 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
418 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
419 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
420 ; leading to the following complicated sequences.
421 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
422 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
423 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
424 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
425 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 16
426 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
427 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
428 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
430 %1(s16) = G_TRUNC %0(s32)
432 %3(s16) = G_TRUNC %2(s32)
433 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
434 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
435 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
437 ; SOFT: ADJCALLSTACKDOWN
438 ; SOFT-DAG: $r0 = COPY [[X32]]
439 ; SOFT-DAG: $r1 = COPY [[Y32]]
440 ; ARM-AEABI: BL &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
441 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
442 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
443 ; ARM-DEFAULT: BL &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
444 ; THUMB-DEFAULT: tBL 14, $noreg, &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
445 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
446 ; SOFT: ADJCALLSTACKUP
448 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
450 %4(s16) = G_SREM %1, %3
451 ; CHECK: $r0 = COPY [[R]]
452 %5(s32) = G_SEXT %4(s16)
454 BX_RET 14, $noreg, implicit $r0
458 # CHECK-LABEL: name: test_urem_i16
460 # CHECK: legalized: true
461 regBankSelected: false
463 tracksRegLiveness: true
465 - { id: 0, class: _ }
466 - { id: 1, class: _ }
467 - { id: 2, class: _ }
468 - { id: 3, class: _ }
469 - { id: 4, class: _ }
470 - { id: 5, class: _ }
475 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
476 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
477 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
478 ; leading to the following complicated sequences.
479 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
480 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
481 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
482 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
483 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
484 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
486 %1(s16) = G_TRUNC %0(s32)
488 %3(s16) = G_TRUNC %2(s32)
489 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
490 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
491 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
493 ; SOFT: ADJCALLSTACKDOWN
494 ; SOFT-DAG: $r0 = COPY [[X32]]
495 ; SOFT-DAG: $r1 = COPY [[Y32]]
496 ; ARM-AEABI: BL &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
497 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
498 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
499 ; ARM-DEFAULT: BL &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
500 ; THUMB-DEFAULT: tBL 14, $noreg, &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
501 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
502 ; SOFT: ADJCALLSTACKUP
504 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
506 %4(s16) = G_UREM %1, %3
507 ; CHECK: $r0 = COPY [[R]]
508 %5(s32) = G_ZEXT %4(s16)
510 BX_RET 14, $noreg, implicit $r0
514 # CHECK-LABEL: name: test_srem_i8
516 # CHECK: legalized: true
517 regBankSelected: false
519 tracksRegLiveness: true
521 - { id: 0, class: _ }
522 - { id: 1, class: _ }
523 - { id: 2, class: _ }
524 - { id: 3, class: _ }
525 - { id: 4, class: _ }
526 - { id: 5, class: _ }
531 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
532 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
533 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
534 ; leading to the following complicated sequences.
535 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
536 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
537 ; CHECK: [[SHIFTEDX:%[0-9]+]]:_(s32) = G_SHL [[X]], [[BITS]]
538 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDX]], [[BITS]]
539 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 24
540 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
541 ; CHECK: [[SHIFTEDY:%[0-9]+]]:_(s32) = G_SHL [[Y]], [[BITS]]
542 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_ASHR [[SHIFTEDY]], [[BITS]]
544 %1(s8) = G_TRUNC %0(s32)
546 %3(s8) = G_TRUNC %2(s32)
547 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_SDIV [[X32]], [[Y32]]
548 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
549 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
551 ; SOFT: ADJCALLSTACKDOWN
552 ; SOFT-DAG: $r0 = COPY [[X32]]
553 ; SOFT-DAG: $r1 = COPY [[Y32]]
554 ; ARM-AEABI: BL &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
555 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_idivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
556 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
557 ; ARM-DEFAULT: BL &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
558 ; THUMB-DEFAULT: tBL 14, $noreg, &__modsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
559 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
560 ; SOFT: ADJCALLSTACKUP
562 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_ASHR
564 %4(s8) = G_SREM %1, %3
565 ; CHECK: $r0 = COPY [[R]]
566 %5(s32) = G_SEXT %4(s8)
568 BX_RET 14, $noreg, implicit $r0
572 # CHECK-LABEL: name: test_urem_i8
574 # CHECK: legalized: true
575 regBankSelected: false
577 tracksRegLiveness: true
579 - { id: 0, class: _ }
580 - { id: 1, class: _ }
581 - { id: 2, class: _ }
582 - { id: 3, class: _ }
583 - { id: 4, class: _ }
584 - { id: 5, class: _ }
589 ; CHECK-DAG: [[R0:%[0-9]+]]:_(s32) = COPY $r0
590 ; CHECK-DAG: [[R1:%[0-9]+]]:_(s32) = COPY $r1
591 ; The G_TRUNC will combine with the extensions introduced by the legalizer,
592 ; leading to the following complicated sequences.
593 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
594 ; CHECK: [[X:%[0-9]+]]:_(s32) = COPY [[R0]]
595 ; CHECK: [[X32:%[0-9]+]]:_(s32) = G_AND [[X]], [[BITS]]
596 ; CHECK: [[BITS:%[0-9]+]]:_(s32) = G_CONSTANT i32 255
597 ; CHECK: [[Y:%[0-9]+]]:_(s32) = COPY [[R1]]
598 ; CHECK: [[Y32:%[0-9]+]]:_(s32) = G_AND [[Y]], [[BITS]]
600 %1(s8) = G_TRUNC %0(s32)
602 %3(s8) = G_TRUNC %2(s32)
603 ; HWDIV: [[Q32:%[0-9]+]]:_(s32) = G_UDIV [[X32]], [[Y32]]
604 ; HWDIV: [[P32:%[0-9]+]]:_(s32) = G_MUL [[Q32]], [[Y32]]
605 ; HWDIV: [[R32:%[0-9]+]]:_(s32) = G_SUB [[X32]], [[P32]]
607 ; SOFT: ADJCALLSTACKDOWN
608 ; SOFT-DAG: $r0 = COPY [[X32]]
609 ; SOFT-DAG: $r1 = COPY [[Y32]]
610 ; ARM-AEABI: BL &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
611 ; THUMB-AEABI: tBL 14, $noreg, &__aeabi_uidivmod, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
612 ; SOFT-AEABI: [[R32:%[0-9]+]]:_(s32) = COPY $r1
613 ; ARM-DEFAULT: BL &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
614 ; THUMB-DEFAULT: tBL 14, $noreg, &__umodsi3, {{.*}}, implicit $r0, implicit $r1, implicit-def $r0
615 ; SOFT-DEFAULT: [[R32:%[0-9]+]]:_(s32) = COPY $r0
616 ; SOFT: ADJCALLSTACKUP
618 ; CHECK: [[R:%[0-9]+]]:_(s32) = G_AND
620 %4(s8) = G_UREM %1, %3
621 ; CHECK: $r0 = COPY [[R]]
622 %5(s32) = G_ZEXT %4(s8)
624 BX_RET 14, $noreg, implicit $r0