1 ; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-a8 | \
2 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-SWDIV
3 ; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=swift | \
4 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-HWDIV-ARM-OR-THUMB2
5 ; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-r4 | \
6 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-SWDIV
7 ; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-r4f | \
8 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-SWDIV
9 ; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-r5 | \
10 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-HWDIV-ARM-OR-THUMB2
11 ; RUN: llc < %s -mtriple=arm-none-eabi -mcpu=cortex-a8 | \
12 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-EABI
13 ; RUN: llc < %s -mtriple=armv7 -mcpu=cortex-a7 | \
14 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-HWDIV-ARM-OR-THUMB2
15 ; RUN: llc < %s -mtriple=armv7 -mcpu=cortex-a7 -march=thumb | \
16 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-THUMB,CHECK-HWDIV-ARM-OR-THUMB2
17 ; RUN: llc %s -o - -mtriple=thumbv8m.main -mcpu=cortex-m33 | \
18 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-THUMB,CHECK-HWDIV-ARM-OR-THUMB2
19 ; RUN: llc < %s -mtriple=thumbv8m.base -mcpu=cortex-m23 | \
20 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-THUMB,CHECK-HWDIV-THUMB1
21 ; RUN: llc < %s -mtriple=armv7ve-none-linux-gnu | \
22 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV
23 ; RUN: llc < %s -mtriple=thumbv7ve-none-linux-gnu | \
24 ; RUN: FileCheck %s -check-prefixes=CHECK,CHECK-HWDIV,CHECK-THUMB
26 define i32 @f1(i32 %a, i32 %b) {
29 ; CHECK-SWDIV: __divsi3
31 ; CHECK-THUMB: .thumb_func
34 ; CHECK-EABI: __aeabi_idiv
35 %tmp1 = sdiv i32 %a, %b ; <i32> [#uses=1]
39 define i32 @f2(i32 %a, i32 %b) {
42 ; CHECK-SWDIV: __udivsi3
44 ; CHECK-THUMB: .thumb_func
47 ; CHECK-EABI: __aeabi_uidiv
48 %tmp1 = udiv i32 %a, %b ; <i32> [#uses=1]
52 define i32 @f3(i32 %a, i32 %b) {
55 ; CHECK-SWDIV: __modsi3
57 ; CHECK-THUMB: .thumb_func
59 ; CHECK-HWDIV-ARM-OR-THUMB2-NEXT: mls
60 ; CHECK-HWDIV-THUMB1-NEXT: muls
61 ; CHECK-HWDIV-THUMB1-NEXT: subs
63 ; EABI MODE = Remainder in R1, quotient in R0
64 ; CHECK-EABI: __aeabi_idivmod
65 ; CHECK-EABI-NEXT: mov r0, r1
66 %tmp1 = srem i32 %a, %b ; <i32> [#uses=1]
70 define i32 @f4(i32 %a, i32 %b) {
73 ; CHECK-SWDIV: __umodsi3
75 ; CHECK-THUMB: .thumb_func
77 ; CHECK-HWDIV-ARM-OR-THUMB2-NEXT: mls
78 ; CHECK-HWDIV-THUMB1-NEXT: muls
79 ; CHECK-HWDIV-THUMB1-NEXT: subs
81 ; EABI MODE = Remainder in R1, quotient in R0
82 ; CHECK-EABI: __aeabi_uidivmod
83 ; CHECK-EABI-NEXT: mov r0, r1
84 %tmp1 = urem i32 %a, %b ; <i32> [#uses=1]
89 define i64 @f5(i64 %a, i64 %b) {
92 ; CHECK-SWDIV: __moddi3
94 ; CHECK-HWDIV: __moddi3
96 ; EABI MODE = Remainder in R2-R3, quotient in R0-R1
97 ; CHECK-EABI: __aeabi_ldivmod
98 ; CHECK-EABI-NEXT: mov r0, r2
99 ; CHECK-EABI-NEXT: mov r1, r3
100 %tmp1 = srem i64 %a, %b ; <i64> [#uses=1]
104 define i64 @f6(i64 %a, i64 %b) {
107 ; CHECK-SWDIV: __umoddi3
109 ; CHECK-HWDIV: __umoddi3
111 ; EABI MODE = Remainder in R2-R3, quotient in R0-R1
112 ; CHECK-EABI: __aeabi_uldivmod
113 ; CHECK-EABI-NEXT: mov r0, r2
114 ; CHECK-EABI-NEXT: mov r1, r3
115 %tmp1 = urem i64 %a, %b ; <i64> [#uses=1]
119 ; Make sure we avoid a libcall for some constants.
120 define i64 @f7(i64 %a) {
124 ; CHECK-HWDIV-ARM-OR-THUMB2: adc
125 ; CHECK-HWDIV-ARM-OR-THUMB2: umull
128 ; No 32-bit => 64-bit HW multiply instruction prevents optimisation
129 ; CHECK-HWDIV-THUMB1: __umoddi3
130 %tmp1 = urem i64 %a, 3
134 ; Make sure we avoid a libcall for some constants.
135 define i64 @f8(i64 %a) {
139 ; CHECK-HWDIV-ARM-OR-THUMB2: adc
140 ; CHECK-HWDIV-ARM-OR-THUMB2: umull
143 ; No 32-bit => 64-bit HW multiply instruction prevents optimisation
144 ; CHECK-HWDIV-THUMB1: __udivdi3
145 %tmp1 = udiv i64 %a, 3