blob: 301642c76ce074a18ac3d7f6d60b15a972fb57f0 [file] [log] [blame]
Petar Jovanovice578e972016-04-11 15:24:23 +00001; RUN: llc < %s -march=mips -mcpu=mips2 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00002; RUN: -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00003; RUN: llc < %s -march=mips -mcpu=mips32 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +00004; RUN: -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00005; RUN: llc < %s -march=mips -mcpu=mips32r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +00006; RUN: -check-prefix=NOT-R6 -check-prefix=R2-R5 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00007; RUN: llc < %s -march=mips -mcpu=mips32r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +00008; RUN: -check-prefix=NOT-R6 -check-prefix=R2-R5 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +00009; RUN: llc < %s -march=mips -mcpu=mips32r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000010; RUN: -check-prefix=NOT-R6 -check-prefix=R2-R5 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +000011; RUN: llc < %s -march=mips -mcpu=mips32r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000012; RUN: -check-prefix=R6 -check-prefix=GP32
Petar Jovanovice578e972016-04-11 15:24:23 +000013; RUN: llc < %s -march=mips64 -mcpu=mips3 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000014; RUN: -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000015; RUN: llc < %s -march=mips64 -mcpu=mips4 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000016; RUN: -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000017; RUN: llc < %s -march=mips64 -mcpu=mips64 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000018; RUN: -check-prefix=NOT-R6 -check-prefix=NOT-R2-R6 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000019; RUN: llc < %s -march=mips64 -mcpu=mips64r2 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000020; RUN: -check-prefix=NOT-R6 -check-prefix=R2-R5 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000021; RUN: llc < %s -march=mips64 -mcpu=mips64r3 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000022; RUN: -check-prefix=NOT-R6 -check-prefix=R2-R5 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000023; RUN: llc < %s -march=mips64 -mcpu=mips64r5 -relocation-model=pic | FileCheck %s \
Daniel Sanders17793142015-02-18 16:24:50 +000024; RUN: -check-prefix=NOT-R6 -check-prefix=R2-R5 -check-prefix=GP64-NOT-R6
Petar Jovanovice578e972016-04-11 15:24:23 +000025; RUN: llc < %s -march=mips64 -mcpu=mips64r6 -relocation-model=pic | FileCheck %s \
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000026; RUN: -check-prefix=R6 -check-prefix=64R6
Zlatko Buljan58d6a952016-04-13 08:02:26 +000027; RUN: llc < %s -march=mips -mcpu=mips32r3 -mattr=+micromips -relocation-model=pic | FileCheck %s \
28; RUN: -check-prefix=MM -check-prefix=MMR3 -check-prefix=MM32
29; RUN: llc < %s -march=mips -mcpu=mips32r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
30; RUN: -check-prefix=MM -check-prefix=MMR6 -check-prefix=MM32
31; RUN: llc < %s -march=mips -mcpu=mips64r6 -mattr=+micromips -relocation-model=pic | FileCheck %s \
32; RUN: -check-prefix=MM -check-prefix=MMR6 -check-prefix=MM64
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000033
34define signext i1 @sdiv_i1(i1 signext %a, i1 signext %b) {
35entry:
36; ALL-LABEL: sdiv_i1:
37
38 ; NOT-R6: div $zero, $4, $5
39 ; NOT-R6: teq $5, $zero, 7
40 ; NOT-R6: mflo $[[T0:[0-9]+]]
41 ; FIXME: The sll/sra instructions are redundant since div is signed.
42 ; NOT-R6: sll $[[T1:[0-9]+]], $[[T0]], 31
43 ; NOT-R6: sra $2, $[[T1]], 31
44
45 ; R6: div $[[T0:[0-9]+]], $4, $5
46 ; R6: teq $5, $zero, 7
47 ; FIXME: The sll/sra instructions are redundant since div is signed.
48 ; R6: sll $[[T1:[0-9]+]], $[[T0]], 31
49 ; R6: sra $2, $[[T1]], 31
50
Zlatko Buljan58d6a952016-04-13 08:02:26 +000051 ; MMR3: div $zero, $4, $5
52 ; MMR3: teq $5, $zero, 7
53 ; MMR3: mflo $[[T0:[0-9]+]]
54 ; MMR3: sll $[[T1:[0-9]+]], $[[T0]], 31
55 ; MMR3: sra $2, $[[T1]], 31
56
57 ; MMR6: div $[[T0:[0-9]+]], $4, $5
58 ; MMR6: teq $5, $zero, 7
59 ; MMR6: sll $[[T1:[0-9]+]], $[[T0]], 31
60 ; MMR6: sra $2, $[[T1]], 31
61
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000062 %r = sdiv i1 %a, %b
63 ret i1 %r
64}
65
66define signext i8 @sdiv_i8(i8 signext %a, i8 signext %b) {
67entry:
68; ALL-LABEL: sdiv_i8:
69
70 ; NOT-R2-R6: div $zero, $4, $5
71 ; NOT-R2-R6: teq $5, $zero, 7
72 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
73 ; FIXME: The sll/sra instructions are redundant since div is signed.
74 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 24
75 ; NOT-R2-R6: sra $2, $[[T1]], 24
76
Daniel Sanders17793142015-02-18 16:24:50 +000077 ; R2-R5: div $zero, $4, $5
78 ; R2-R5: teq $5, $zero, 7
79 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000080 ; FIXME: This instruction is redundant.
Daniel Sanders17793142015-02-18 16:24:50 +000081 ; R2-R5: seb $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000082
83 ; R6: div $[[T0:[0-9]+]], $4, $5
84 ; R6: teq $5, $zero, 7
85 ; FIXME: This instruction is redundant.
86 ; R6: seb $2, $[[T0]]
87
Zlatko Buljan58d6a952016-04-13 08:02:26 +000088 ; MMR3: div $zero, $4, $5
89 ; MMR3: teq $5, $zero, 7
90 ; MMR3: mflo $[[T0:[0-9]+]]
91 ; MMR3: seb $2, $[[T0]]
92
93 ; MMR6: div $[[T0:[0-9]+]], $4, $5
94 ; MMR6: teq $5, $zero, 7
95 ; MMR6: seb $2, $[[T0]]
96
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +000097 %r = sdiv i8 %a, %b
98 ret i8 %r
99}
100
101define signext i16 @sdiv_i16(i16 signext %a, i16 signext %b) {
102entry:
103; ALL-LABEL: sdiv_i16:
104
105 ; NOT-R2-R6: div $zero, $4, $5
106 ; NOT-R2-R6: teq $5, $zero, 7
107 ; NOT-R2-R6: mflo $[[T0:[0-9]+]]
108 ; FIXME: The sll/sra instructions are redundant since div is signed.
109 ; NOT-R2-R6: sll $[[T1:[0-9]+]], $[[T0]], 16
110 ; NOT-R2-R6: sra $2, $[[T1]], 16
111
Daniel Sanders17793142015-02-18 16:24:50 +0000112 ; R2-R5: div $zero, $4, $5
113 ; R2-R5: teq $5, $zero, 7
114 ; R2-R5: mflo $[[T0:[0-9]+]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000115 ; FIXME: This is instruction is redundant since div is signed.
Daniel Sanders17793142015-02-18 16:24:50 +0000116 ; R2-R5: seh $2, $[[T0]]
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000117
118 ; R6: div $[[T0:[0-9]+]], $4, $5
119 ; R6: teq $5, $zero, 7
120 ; FIXME: This is instruction is redundant since div is signed.
121 ; R6: seh $2, $[[T0]]
122
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000123 ; MMR3: div $zero, $4, $5
124 ; MMR3: teq $5, $zero, 7
125 ; MMR3: mflo $[[T0:[0-9]+]]
126 ; MMR3: seh $2, $[[T0]]
127
128 ; MMR6: div $[[T0:[0-9]+]], $4, $5
129 ; MMR6: teq $5, $zero, 7
130 ; MMR6: seh $2, $[[T0]]
131
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000132 %r = sdiv i16 %a, %b
133 ret i16 %r
134}
135
136define signext i32 @sdiv_i32(i32 signext %a, i32 signext %b) {
137entry:
138; ALL-LABEL: sdiv_i32:
139
140 ; NOT-R6: div $zero, $4, $5
141 ; NOT-R6: teq $5, $zero, 7
142 ; NOT-R6: mflo $2
143
144 ; R6: div $2, $4, $5
145 ; R6: teq $5, $zero, 7
146
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000147 ; MMR3: div $zero, $4, $5
148 ; MMR3: teq $5, $zero, 7
149 ; MMR3: mflo $2
150
151 ; MMR6: div $2, $4, $5
152 ; MMR6: teq $5, $zero, 7
153
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000154 %r = sdiv i32 %a, %b
155 ret i32 %r
156}
157
158define signext i64 @sdiv_i64(i64 signext %a, i64 signext %b) {
159entry:
160; ALL-LABEL: sdiv_i64:
161
162 ; GP32: lw $25, %call16(__divdi3)($gp)
163
164 ; GP64-NOT-R6: ddiv $zero, $4, $5
165 ; GP64-NOT-R6: teq $5, $zero, 7
166 ; GP64-NOT-R6: mflo $2
167
168 ; 64R6: ddiv $2, $4, $5
169 ; 64R6: teq $5, $zero, 7
170
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000171 ; MM32: lw $25, %call16(__divdi3)($2)
172
173 ; MM64: ddiv $2, $4, $5
174 ; MM64: teq $5, $zero, 7
175
Vasileios Kalintiris2ed214f2015-01-26 12:04:40 +0000176 %r = sdiv i64 %a, %b
177 ret i64 %r
178}
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000179
180define signext i128 @sdiv_i128(i128 signext %a, i128 signext %b) {
181entry:
182 ; ALL-LABEL: sdiv_i128:
183
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000184 ; GP32: lw $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000185
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000186 ; GP64-NOT-R6: ld $25, %call16(__divti3)($gp)
187 ; 64R6: ld $25, %call16(__divti3)($gp)
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000188
Zlatko Buljan58d6a952016-04-13 08:02:26 +0000189 ; MM32: lw $25, %call16(__divti3)($2)
190
191 ; MM64: ld $25, %call16(__divti3)($2)
192
193 %r = sdiv i128 %a, %b
194 ret i128 %r
195}
196
197define signext i1 @sdiv_0_i1(i1 signext %a) {
198entry:
199; ALL-LABEL: sdiv_0_i8:
200
201 ; NOT-R6: addiu $[[T0:[0-9]+]], $zero, 0
202 ; NOT-R6: div $zero, $4, $[[T0]]
203 ; NOT-R6: teq $[[T0]], $zero, 7
204 ; NOT-R6: mflo $[[T1:[0-9]+]]
205 ; NOT-R6: sll $[[T2:[0-9]+]], $[[T1]], 31
206 ; NOT-R6: sra $2, $[[T2]], 31
207
208 ; R6: div $[[T0:[0-9]+]], $4, $zero
209 ; R6: teq $zero, $zero, 7
210 ; R6: sll $[[T1:[0-9]+]], $[[T0]], 31
211 ; R6: sra $2, $[[T1]], 31
212
213 ; MMR3: lui $[[T0:[0-9]+]], 0
214 ; MMR3: div $zero, $4, $[[T0]]
215 ; MMR3: teq $[[T0]], $zero, 7
216 ; MMR3: mflo $[[T1:[0-9]+]]
217 ; MMR3: sll $[[T2:[0-9]+]], $[[T1]], 31
218 ; MMR3: sra $2, $[[T2]], 31
219
220 ; MMR6: lui $[[T0:[0-9]+]], 0
221 ; MMR6: div $[[T1:[0-9]+]], $4, $[[T0]]
222 ; MMR6: teq $[[T0]], $zero, 7
223 ; MMR6: sll $[[T2:[0-9]+]], $[[T1]], 31
224 ; MMR6: sra $2, $[[T2]], 31
225
226 %r = sdiv i1 %a, 0
227 ret i1 %r
228}
229
230define signext i8 @sdiv_0_i8(i8 signext %a) {
231entry:
232; ALL-LABEL: sdiv_0_i8:
233
234 ; NOT-R2-R6: addiu $[[T0:[0-9]+]], $zero, 0
235 ; NOT-R2-R6: div $zero, $4, $[[T0]]
236 ; NOT-R2-R6: teq $[[T0]], $zero, 7
237 ; NOT-R2-R6: mflo $[[T1:[0-9]+]]
238 ; NOT-R2-R6: sll $[[T2:[0-9]+]], $[[T1]], 24
239 ; NOT-R2-R6: sra $2, $[[T2]], 24
240
241 ; R2-R5: addiu $[[T0:[0-9]+]], $zero, 0
242 ; R2-R5: div $zero, $4, $[[T0]]
243 ; R2-R5: teq $[[T0]], $zero, 7
244 ; R2-R5: mflo $[[T1:[0-9]+]]
245 ; R2-R5: seb $2, $[[T1]]
246
247 ; R6: div $[[T0:[0-9]+]], $4, $zero
248 ; R6: teq $zero, $zero, 7
249 ; R6: seb $2, $[[T0]]
250
251 ; MMR3: lui $[[T0:[0-9]+]], 0
252 ; MMR3: div $zero, $4, $[[T0]]
253 ; MMR3: teq $[[T0]], $zero, 7
254 ; MMR3: mflo $[[T1:[0-9]+]]
255 ; MMR3: seb $2, $[[T1]]
256
257 ; MMR6: lui $[[T0:[0-9]+]], 0
258 ; MMR6: div $[[T1:[0-9]+]], $4, $[[T0]]
259 ; MMR6: teq $[[T0]], $zero, 7
260 ; MMR6: seb $2, $[[T1]]
261
262 %r = sdiv i8 %a, 0
263 ret i8 %r
264}
265
266define signext i16 @sdiv_0_i16(i16 signext %a) {
267entry:
268; ALL-LABEL: sdiv_0_i16:
269
270 ; NOT-R2-R6: addiu $[[T0:[0-9]+]], $zero, 0
271 ; NOT-R2-R6: div $zero, $4, $[[T0]]
272 ; NOT-R2-R6: teq $[[T0]], $zero, 7
273 ; NOT-R2-R6: mflo $[[T1:[0-9]+]]
274 ; NOT-R2-R6: sll $[[T2:[0-9]+]], $[[T1]], 16
275 ; NOT-R2-R6: sra $2, $[[T2]], 16
276
277 ; R2-R5: addiu $[[T0:[0-9]+]], $zero, 0
278 ; R2-R5: div $zero, $4, $[[T0]]
279 ; R2-R5: teq $[[T0]], $zero, 7
280 ; R2-R5: mflo $[[T1:[0-9]+]]
281 ; R2-R5: seh $2, $[[T1]]
282
283 ; R6: div $[[T0:[0-9]+]], $4, $zero
284 ; R6: teq $zero, $zero, 7
285 ; R6: seh $2, $[[T0]]
286
287 ; MMR3: lui $[[T0:[0-9]+]], 0
288 ; MMR3: div $zero, $4, $[[T0]]
289 ; MMR3: teq $[[T0]], $zero, 7
290 ; MMR3: mflo $[[T1:[0-9]+]]
291 ; MMR3: seh $2, $[[T1]]
292
293 ; MMR6: lui $[[T0:[0-9]+]], 0
294 ; MMR6: div $[[T1:[0-9]+]], $4, $[[T0]]
295 ; MMR6: teq $[[T0]], $zero, 7
296 ; MMR6: seh $2, $[[T1]]
297
298 %r = sdiv i16 %a, 0
299 ret i16 %r
300}
301
302define signext i32 @sdiv_0_i32(i32 signext %a) {
303entry:
304; ALL-LABEL: sdiv_0_i32:
305
306 ; NOT-R6: addiu $[[T0:[0-9]+]], $zero, 0
307 ; NOT-R6: div $zero, $4, $[[T0]]
308 ; NOT-R6: teq $[[T0]], $zero, 7
309 ; NOT-R6: mflo $2
310
311 ; R6: div $2, $4, $zero
312 ; R6: teq $zero, $zero, 7
313
314 ; MMR3: lui $[[T0:[0-9]+]], 0
315 ; MMR3: div $zero, $4, $[[T0]]
316 ; MMR3: teq $[[T0]], $zero, 7
317 ; MMR3: mflo $2
318
319 ; MMR6: lui $[[T0:[0-9]+]], 0
320 ; MMR6: div $2, $4, $[[T0]]
321 ; MMR6: teq $[[T0]], $zero, 7
322
323 %r = sdiv i32 %a, 0
324 ret i32 %r
325}
326
327define signext i64 @sdiv_0_i64(i64 signext %a) {
328entry:
329; ALL-LABEL: sdiv_0_i64:
330
331 ; GP32: lw $25, %call16(__divdi3)($gp)
332
333 ; GP64-NOT-R6: daddiu $[[T0:[0-9]+]], $zero, 0
334 ; GP64-NOT-R6: ddiv $zero, $4, $[[T0]]
335 ; GP64-NOT-R6: teq $[[T0]], $zero, 7
336 ; GP64-NOT-R6: mflo $2
337
338 ; 64R6: ddiv $2, $4, $zero
339 ; 64R6: teq $zero, $zero, 7
340
341 ; MM32: lw $25, %call16(__divdi3)($2)
342
343 ; MM64: ddiv $2, $4, $zero
344 ; MM64: teq $zero, $zero, 7
345
346 %r = sdiv i64 %a, 0
347 ret i64 %r
348}
349
350define signext i128 @sdiv_0_i128(i128 signext %a) {
351entry:
352; ALL-LABEL: sdiv_0_i128:
353
354 ; GP32: lw $25, %call16(__divti3)($gp)
355
356 ; GP64-NOT-R6: ld $25, %call16(__divti3)($gp)
357 ; 64R6: ld $25, %call16(__divti3)($gp)
358
359 ; MM32: lw $25, %call16(__divti3)($2)
360
361 ; MM64: ld $25, %call16(__divti3)($2)
362
363 %r = sdiv i128 %a, 0
364 ret i128 %r
Vasileios Kalintirisef96a8e2015-01-26 12:33:22 +0000365}