1; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-a8    | \
2; RUN:     FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-SWDIV
3; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=swift        | \
4; RUN:     FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-HWDIV
5; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-r4    | \
6; RUN:     FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-SWDIV
7; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-r4f   | \
8; RUN:     FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-SWDIV
9; RUN: llc < %s -mtriple=arm-apple-ios -mcpu=cortex-r5    | \
10; RUN:     FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-HWDIV
11; RUN: llc < %s -mtriple=arm-none-eabi -mcpu=cortex-a8    | \
12; RUN:     FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-EABI
13
14define i32 @f1(i32 %a, i32 %b) {
15entry:
16; CHECK-LABEL: f1
17; CHECK-SWDIV: __divsi3
18
19; CHECK-HWDIV: sdiv
20
21; CHECK-EABI: __aeabi_idiv
22        %tmp1 = sdiv i32 %a, %b         ; <i32> [#uses=1]
23        ret i32 %tmp1
24}
25
26define i32 @f2(i32 %a, i32 %b) {
27entry:
28; CHECK-LABEL: f2
29; CHECK-SWDIV: __udivsi3
30
31; CHECK-HWDIV: udiv
32
33; CHECK-EABI: __aeabi_uidiv
34        %tmp1 = udiv i32 %a, %b         ; <i32> [#uses=1]
35        ret i32 %tmp1
36}
37
38define i32 @f3(i32 %a, i32 %b) {
39entry:
40; CHECK-LABEL: f3
41; CHECK-SWDIV: __modsi3
42
43; CHECK-HWDIV: sdiv
44; CHECK-HWDIV: mls
45
46; EABI MODE = Remainder in R1, quotient in R0
47; CHECK-EABI: __aeabi_idivmod
48; CHECK-EABI-NEXT: mov r0, r1
49        %tmp1 = srem i32 %a, %b         ; <i32> [#uses=1]
50        ret i32 %tmp1
51}
52
53define i32 @f4(i32 %a, i32 %b) {
54entry:
55; CHECK-LABEL: f4
56; CHECK-SWDIV: __umodsi3
57
58; CHECK-HWDIV: udiv
59; CHECK-HWDIV: mls
60
61; EABI MODE = Remainder in R1, quotient in R0
62; CHECK-EABI: __aeabi_uidivmod
63; CHECK-EABI-NEXT: mov r0, r1
64        %tmp1 = urem i32 %a, %b         ; <i32> [#uses=1]
65        ret i32 %tmp1
66}
67
68
69define i64 @f5(i64 %a, i64 %b) {
70entry:
71; CHECK-LABEL: f5
72; CHECK-SWDIV: __moddi3
73
74; CHECK-HWDIV: __moddi3
75
76; EABI MODE = Remainder in R2-R3, quotient in R0-R1
77; CHECK-EABI: __aeabi_ldivmod
78; CHECK-EABI-NEXT: mov r0, r2
79; CHECK-EABI-NEXT: mov r1, r3
80        %tmp1 = srem i64 %a, %b         ; <i64> [#uses=1]
81        ret i64 %tmp1
82}
83
84define i64 @f6(i64 %a, i64 %b) {
85entry:
86; CHECK-LABEL: f6
87; CHECK-SWDIV: __umoddi3
88
89; CHECK-HWDIV: __umoddi3
90
91; EABI MODE = Remainder in R2-R3, quotient in R0-R1
92; CHECK-EABI: __aeabi_uldivmod
93; CHECK-EABI-NEXT: mov r0, r2
94; CHECK-EABI-NEXT: mov r1, r3
95        %tmp1 = urem i64 %a, %b         ; <i64> [#uses=1]
96        ret i64 %tmp1
97}
98