source: icGREP/icgrep-devel/llvm-3.8.0.src/test/CodeGen/ARM/divmod-eabi.ll @ 5027

Last change on this file since 5027 was 5027, checked in by cameron, 3 years ago

Upgrade to llvm 3.8

File size: 5.1 KB
Line 
1; RUN: llc -mtriple armv7-none-eabi %s -o - | FileCheck %s --check-prefix=EABI
2; RUN: llc -mtriple armv7-none-eabihf %s -o - | FileCheck %s --check-prefix=EABI
3; Both "none-eabi" and "androideabi" must lower SREM/UREM to __aeabi_{u,i}divmod
4; RUN: llc -mtriple armv7-linux-androideabi %s -o - | FileCheck %s --check-prefix=EABI
5; RUN: llc -mtriple armv7-linux-gnueabi %s -o - | FileCheck %s --check-prefix=GNU
6; RUN: llc -mtriple armv7-apple-darwin %s -o - | FileCheck %s --check-prefix=DARWIN
7; FIXME: long-term, we will use "-apple-macho" and won't need this exception:
8; RUN: llc -mtriple armv7-apple-darwin-eabi %s -o - | FileCheck %s --check-prefix=DARWIN
9
10define signext i16 @f16(i16 signext %a, i16 signext %b) {
11; EABI-LABEL: f16:
12; GNU-LABEL: f16:
13; DARWIN-LABEL: f16:
14entry:
15  %conv = sext i16 %a to i32
16  %conv1 = sext i16 %b to i32
17  %div = sdiv i32 %conv, %conv1
18  %rem = srem i32 %conv, %conv1
19; EABI: __aeabi_idivmod
20; EABI: mov [[div:r[0-9]+]], r0
21; EABI: mov [[rem:r[0-9]+]], r1
22; GNU: __aeabi_idiv
23; GNU: mov [[sum:r[0-9]+]], r0
24; GNU: __modsi3
25; GNU: add [[sum]]{{.*}}r0
26; DARWIN: ___divsi3
27; DARWIN: mov [[sum:r[0-9]+]], r0
28; DARWIN: __modsi3
29; DARWIN: add [[sum]]{{.*}}r0
30  %rem8 = srem i32 %conv1, %conv
31; EABI: __aeabi_idivmod
32; GNU: __modsi3
33; DARWIN: __modsi3
34  %add = add nsw i32 %rem, %div
35  %add13 = add nsw i32 %add, %rem8
36  %conv14 = trunc i32 %add13 to i16
37; EABI: add r0{{.*}}r1
38; EABI: sxth r0, r0
39; GNU: add r0{{.*}}[[sum]]
40; GNU: sxth r0, r0
41; DARWIN: add r0{{.*}}[[sum]]
42; DARWIN: sxth r0, r0
43  ret i16 %conv14
44}
45
46define i32 @f32(i32 %a, i32 %b) {
47; EABI-LABEL: f32:
48; GNU-LABEL: f32:
49; DARWIN-LABEL: f32:
50entry:
51  %div = sdiv i32 %a, %b
52  %rem = srem i32 %a, %b
53; EABI: __aeabi_idivmod
54; EABI: mov [[div:r[0-9]+]], r0
55; EABI: mov [[rem:r[0-9]+]], r1
56; GNU: __aeabi_idiv
57; GNU: mov [[sum:r[0-9]+]], r0
58; GNU: __modsi3
59; GNU: add [[sum]]{{.*}}r0
60; DARWIN: ___divsi3
61; DARWIN: mov [[sum:r[0-9]+]], r0
62; DARWIN: __modsi3
63; DARWIN: add [[sum]]{{.*}}r0
64  %rem1 = srem i32 %b, %a
65; EABI: __aeabi_idivmod
66; GNU: __modsi3
67; DARWIN: __modsi3
68  %add = add nsw i32 %rem, %div
69  %add2 = add nsw i32 %add, %rem1
70; EABI: add r0{{.*}}r1
71; GNU: add r0{{.*}}[[sum]]
72; DARWIN: add r0{{.*}}[[sum]]
73  ret i32 %add2
74}
75
76define i32 @uf(i32 %a, i32 %b) {
77; EABI-LABEL: uf:
78; GNU-LABEL: uf:
79; DARWIN-LABEL: uf:
80entry:
81  %div = udiv i32 %a, %b
82  %rem = urem i32 %a, %b
83; EABI: __aeabi_uidivmod
84; GNU: __aeabi_uidiv
85; GNU: mov [[sum:r[0-9]+]], r0
86; GNU: __umodsi3
87; GNU: add [[sum]]{{.*}}r0
88; DARWIN: ___udivsi3
89; DARWIN: mov [[sum:r[0-9]+]], r0
90; DARWIN: __umodsi3
91; DARWIN: add [[sum]]{{.*}}r0
92  %rem1 = urem i32 %b, %a
93; EABI: __aeabi_uidivmod
94; GNU: __umodsi3
95; DARWIN: __umodsi3
96  %add = add nuw i32 %rem, %div
97  %add2 = add nuw i32 %add, %rem1
98; EABI: add r0{{.*}}r1
99; GNU: add r0{{.*}}[[sum]]
100; DARWIN: add r0{{.*}}[[sum]]
101  ret i32 %add2
102}
103
104; FIXME: AEABI is not lowering long u/srem into u/ldivmod
105define i64 @longf(i64 %a, i64 %b) {
106; EABI-LABEL: longf:
107; GNU-LABEL: longf:
108; DARWIN-LABEL: longf:
109entry:
110  %div = sdiv i64 %a, %b
111  %rem = srem i64 %a, %b
112; EABI: __aeabi_ldivmod
113; GNU: __aeabi_ldivmod
114; GNU: mov [[div1:r[0-9]+]], r0
115; GNU: mov [[div2:r[0-9]+]], r1
116; DARWIN: ___divdi3
117; DARWIN: mov [[div1:r[0-9]+]], r0
118; DARWIN: mov [[div2:r[0-9]+]], r1
119; DARWIN: __moddi3
120  %add = add nsw i64 %rem, %div
121; GNU: adds r0{{.*}}[[div1]]
122; GNU: adc r1{{.*}}[[div2]]
123; DARWIN: adds r0{{.*}}[[div1]]
124; DARWIN: adc r1{{.*}}[[div2]]
125  ret i64 %add
126}
127
128define i32 @g1(i32 %a, i32 %b) {
129; EABI-LABEL: g1:
130; GNU-LABEL: g1:
131; DARWIN-LABEL: g1:
132entry:
133  %div = sdiv i32 %a, %b
134  %rem = srem i32 %a, %b
135; EABI: __aeabi_idivmod
136; GNU: __aeabi_idiv
137; GNU: mov [[sum:r[0-9]+]], r0
138; GNU: __modsi3
139; DARWIN: ___divsi3
140; DARWIN: mov [[sum:r[0-9]+]], r0
141; DARWIN: __modsi3
142  %add = add nsw i32 %rem, %div
143; EABI: add     r0{{.*}}r1
144; GNU: add r0{{.*}}[[sum]]
145; DARWIN: add r0{{.*}}[[sum]]
146  ret i32 %add
147}
148
149; On both Darwin and Gnu, this is just a call to __modsi3
150define i32 @g2(i32 %a, i32 %b) {
151; EABI-LABEL: g2:
152; GNU-LABEL: g2:
153; DARWIN-LABEL: g2:
154entry:
155  %rem = srem i32 %a, %b
156; EABI: __aeabi_idivmod
157; GNU: __modsi3
158; DARWIN: __modsi3
159  ret i32 %rem
160; EABI: mov     r0, r1
161}
162
163define i32 @g3(i32 %a, i32 %b) {
164; EABI-LABEL: g3:
165; GNU-LABEL: g3:
166; DARWIN-LABEL: g3:
167entry:
168  %rem = srem i32 %a, %b
169; EABI: __aeabi_idivmod
170; EABI: mov [[mod:r[0-9]+]], r1
171; GNU: __modsi3
172; GNU: mov [[sum:r[0-9]+]], r0
173; DARWIN: __modsi3
174; DARWIN: mov [[sum:r[0-9]+]], r0
175  %rem1 = srem i32 %b, %rem
176; EABI: __aeabi_idivmod
177; GNU: __modsi3
178; DARWIN: __modsi3
179  %add = add nsw i32 %rem1, %rem
180; EABI: add r0, r1, [[mod]]
181; GNU: add r0{{.*}}[[sum]]
182; DARWIN: add r0{{.*}}[[sum]]
183  ret i32 %add
184}
185
186define i32 @g4(i32 %a, i32 %b) {
187; EABI-LABEL: g4:
188; GNU-LABEL: g4:
189; DARWIN-LABEL: g4:
190entry:
191  %div = sdiv i32 %a, %b
192; EABI: __aeabi_idiv{{$}}
193; EABI: mov [[div:r[0-9]+]], r0
194; GNU: __aeabi_idiv
195; GNU: mov [[sum:r[0-9]+]], r0
196; DARWIN: ___divsi3
197; DARWIN: mov [[sum:r[0-9]+]], r0
198  %rem = srem i32 %b, %div
199; EABI: __aeabi_idivmod
200; GNU: __modsi3
201; DARWIN: __modsi3
202  %add = add nsw i32 %rem, %div
203; EABI: add r0, r1, [[div]]
204; GNU: add r0{{.*}}[[sum]]
205; DARWIN: add r0{{.*}}[[sum]]
206  ret i32 %add
207}
Note: See TracBrowser for help on using the repository browser.