1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32,FP32
3 ; RUN: llc -O0 -mtriple=mipsel-linux-gnu -mattr=+fp64,+mips32r2 -global-isel -verify-machineinstrs %s -o -| FileCheck %s -check-prefixes=MIPS32,FP64
5 define i64 @f32toi64(float %a) {
6 ; MIPS32-LABEL: f32toi64:
7 ; MIPS32: # %bb.0: # %entry
8 ; MIPS32-NEXT: addiu $sp, $sp, -24
9 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
10 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
11 ; MIPS32-NEXT: .cfi_offset 31, -4
12 ; MIPS32-NEXT: jal __fixsfdi
14 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
15 ; MIPS32-NEXT: addiu $sp, $sp, 24
19 %conv = fptosi float %a to i64
23 define i32 @f32toi32(float %a) {
24 ; MIPS32-LABEL: f32toi32:
25 ; MIPS32: # %bb.0: # %entry
26 ; MIPS32-NEXT: trunc.w.s $f0, $f12
27 ; MIPS32-NEXT: mfc1 $2, $f0
31 %conv = fptosi float %a to i32
35 define signext i16 @f32toi16(float %a) {
36 ; MIPS32-LABEL: f32toi16:
37 ; MIPS32: # %bb.0: # %entry
38 ; MIPS32-NEXT: trunc.w.s $f0, $f12
39 ; MIPS32-NEXT: mfc1 $1, $f0
40 ; MIPS32-NEXT: sll $1, $1, 16
41 ; MIPS32-NEXT: sra $2, $1, 16
45 %conv = fptosi float %a to i16
49 define signext i8 @f32toi8(float %a) {
50 ; MIPS32-LABEL: f32toi8:
51 ; MIPS32: # %bb.0: # %entry
52 ; MIPS32-NEXT: trunc.w.s $f0, $f12
53 ; MIPS32-NEXT: mfc1 $1, $f0
54 ; MIPS32-NEXT: sll $1, $1, 24
55 ; MIPS32-NEXT: sra $2, $1, 24
59 %conv = fptosi float %a to i8
63 define i64 @f64toi64(double %a) {
64 ; MIPS32-LABEL: f64toi64:
65 ; MIPS32: # %bb.0: # %entry
66 ; MIPS32-NEXT: addiu $sp, $sp, -24
67 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
68 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
69 ; MIPS32-NEXT: .cfi_offset 31, -4
70 ; MIPS32-NEXT: jal __fixdfdi
72 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
73 ; MIPS32-NEXT: addiu $sp, $sp, 24
77 %conv = fptosi double %a to i64
81 define i32 @f64toi32(double %a) {
82 ; MIPS32-LABEL: f64toi32:
83 ; MIPS32: # %bb.0: # %entry
84 ; MIPS32-NEXT: trunc.w.d $f0, $f12
85 ; MIPS32-NEXT: mfc1 $2, $f0
89 %conv = fptosi double %a to i32
93 define signext i16 @f64toi16(double %a) {
94 ; MIPS32-LABEL: f64toi16:
95 ; MIPS32: # %bb.0: # %entry
96 ; MIPS32-NEXT: trunc.w.d $f0, $f12
97 ; MIPS32-NEXT: mfc1 $1, $f0
98 ; MIPS32-NEXT: sll $1, $1, 16
99 ; MIPS32-NEXT: sra $2, $1, 16
100 ; MIPS32-NEXT: jr $ra
103 %conv = fptosi double %a to i16
107 define signext i8 @f64toi8(double %a) {
108 ; MIPS32-LABEL: f64toi8:
109 ; MIPS32: # %bb.0: # %entry
110 ; MIPS32-NEXT: trunc.w.d $f0, $f12
111 ; MIPS32-NEXT: mfc1 $1, $f0
112 ; MIPS32-NEXT: sll $1, $1, 24
113 ; MIPS32-NEXT: sra $2, $1, 24
114 ; MIPS32-NEXT: jr $ra
117 %conv = fptosi double %a to i8
121 define i64 @f32tou64(float %a) {
122 ; MIPS32-LABEL: f32tou64:
123 ; MIPS32: # %bb.0: # %entry
124 ; MIPS32-NEXT: addiu $sp, $sp, -24
125 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
126 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
127 ; MIPS32-NEXT: .cfi_offset 31, -4
128 ; MIPS32-NEXT: jal __fixunssfdi
130 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
131 ; MIPS32-NEXT: addiu $sp, $sp, 24
132 ; MIPS32-NEXT: jr $ra
135 %conv = fptoui float %a to i64
139 define i32 @f32tou32(float %a) {
140 ; MIPS32-LABEL: f32tou32:
141 ; MIPS32: # %bb.0: # %entry
142 ; MIPS32-NEXT: trunc.w.s $f0, $f12
143 ; MIPS32-NEXT: mfc1 $1, $f0
144 ; MIPS32-NEXT: lui $2, 20224
145 ; MIPS32-NEXT: mtc1 $2, $f0
146 ; MIPS32-NEXT: sub.s $f1, $f12, $f0
147 ; MIPS32-NEXT: trunc.w.s $f1, $f1
148 ; MIPS32-NEXT: mfc1 $2, $f1
149 ; MIPS32-NEXT: lui $3, 32768
150 ; MIPS32-NEXT: xor $2, $2, $3
151 ; MIPS32-NEXT: addiu $3, $zero, 1
152 ; MIPS32-NEXT: c.ult.s $f12, $f0
153 ; MIPS32-NEXT: movf $3, $zero, $fcc0
154 ; MIPS32-NEXT: andi $3, $3, 1
155 ; MIPS32-NEXT: movn $2, $1, $3
156 ; MIPS32-NEXT: jr $ra
159 %conv = fptoui float %a to i32
163 define zeroext i16 @f32tou16(float %a) {
164 ; MIPS32-LABEL: f32tou16:
165 ; MIPS32: # %bb.0: # %entry
166 ; MIPS32-NEXT: trunc.w.s $f0, $f12
167 ; MIPS32-NEXT: mfc1 $2, $f0
168 ; MIPS32-NEXT: lui $1, 20224
169 ; MIPS32-NEXT: mtc1 $1, $f0
170 ; MIPS32-NEXT: sub.s $f1, $f12, $f0
171 ; MIPS32-NEXT: trunc.w.s $f1, $f1
172 ; MIPS32-NEXT: mfc1 $1, $f1
173 ; MIPS32-NEXT: lui $3, 32768
174 ; MIPS32-NEXT: xor $1, $1, $3
175 ; MIPS32-NEXT: addiu $3, $zero, 1
176 ; MIPS32-NEXT: c.ult.s $f12, $f0
177 ; MIPS32-NEXT: movf $3, $zero, $fcc0
178 ; MIPS32-NEXT: andi $3, $3, 1
179 ; MIPS32-NEXT: movn $1, $2, $3
180 ; MIPS32-NEXT: andi $2, $1, 65535
181 ; MIPS32-NEXT: jr $ra
184 %conv = fptoui float %a to i16
188 define zeroext i8 @f32tou8(float %a) {
189 ; MIPS32-LABEL: f32tou8:
190 ; MIPS32: # %bb.0: # %entry
191 ; MIPS32-NEXT: trunc.w.s $f0, $f12
192 ; MIPS32-NEXT: mfc1 $2, $f0
193 ; MIPS32-NEXT: lui $1, 20224
194 ; MIPS32-NEXT: mtc1 $1, $f0
195 ; MIPS32-NEXT: sub.s $f1, $f12, $f0
196 ; MIPS32-NEXT: trunc.w.s $f1, $f1
197 ; MIPS32-NEXT: mfc1 $1, $f1
198 ; MIPS32-NEXT: lui $3, 32768
199 ; MIPS32-NEXT: xor $1, $1, $3
200 ; MIPS32-NEXT: addiu $3, $zero, 1
201 ; MIPS32-NEXT: c.ult.s $f12, $f0
202 ; MIPS32-NEXT: movf $3, $zero, $fcc0
203 ; MIPS32-NEXT: andi $3, $3, 1
204 ; MIPS32-NEXT: movn $1, $2, $3
205 ; MIPS32-NEXT: andi $2, $1, 255
206 ; MIPS32-NEXT: jr $ra
209 %conv = fptoui float %a to i8
213 define i64 @f64tou64(double %a) {
214 ; MIPS32-LABEL: f64tou64:
215 ; MIPS32: # %bb.0: # %entry
216 ; MIPS32-NEXT: addiu $sp, $sp, -24
217 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
218 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
219 ; MIPS32-NEXT: .cfi_offset 31, -4
220 ; MIPS32-NEXT: jal __fixunsdfdi
222 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
223 ; MIPS32-NEXT: addiu $sp, $sp, 24
224 ; MIPS32-NEXT: jr $ra
227 %conv = fptoui double %a to i64
231 define i32 @f64tou32(double %a) {
232 ; FP32-LABEL: f64tou32:
233 ; FP32: # %bb.0: # %entry
234 ; FP32-NEXT: trunc.w.d $f0, $f12
235 ; FP32-NEXT: mfc1 $1, $f0
236 ; FP32-NEXT: lui $3, 16864
237 ; FP32-NEXT: ori $2, $zero, 0
238 ; FP32-NEXT: mtc1 $2, $f0
239 ; FP32-NEXT: mtc1 $3, $f1
240 ; FP32-NEXT: sub.d $f2, $f12, $f0
241 ; FP32-NEXT: trunc.w.d $f2, $f2
242 ; FP32-NEXT: mfc1 $2, $f2
243 ; FP32-NEXT: lui $3, 32768
244 ; FP32-NEXT: xor $2, $2, $3
245 ; FP32-NEXT: addiu $3, $zero, 1
246 ; FP32-NEXT: c.ult.d $f12, $f0
247 ; FP32-NEXT: movf $3, $zero, $fcc0
248 ; FP32-NEXT: andi $3, $3, 1
249 ; FP32-NEXT: movn $2, $1, $3
253 ; FP64-LABEL: f64tou32:
254 ; FP64: # %bb.0: # %entry
255 ; FP64-NEXT: trunc.w.d $f0, $f12
256 ; FP64-NEXT: mfc1 $1, $f0
257 ; FP64-NEXT: lui $3, 16864
258 ; FP64-NEXT: ori $2, $zero, 0
259 ; FP64-NEXT: mtc1 $2, $f0
260 ; FP64-NEXT: mthc1 $3, $f0
261 ; FP64-NEXT: sub.d $f1, $f12, $f0
262 ; FP64-NEXT: trunc.w.d $f1, $f1
263 ; FP64-NEXT: mfc1 $2, $f1
264 ; FP64-NEXT: lui $3, 32768
265 ; FP64-NEXT: xor $2, $2, $3
266 ; FP64-NEXT: addiu $3, $zero, 1
267 ; FP64-NEXT: c.ult.d $f12, $f0
268 ; FP64-NEXT: movf $3, $zero, $fcc0
269 ; FP64-NEXT: andi $3, $3, 1
270 ; FP64-NEXT: movn $2, $1, $3
274 %conv = fptoui double %a to i32
278 define zeroext i16 @f64tou16(double %a) {
279 ; FP32-LABEL: f64tou16:
280 ; FP32: # %bb.0: # %entry
281 ; FP32-NEXT: trunc.w.d $f0, $f12
282 ; FP32-NEXT: mfc1 $2, $f0
283 ; FP32-NEXT: lui $3, 16864
284 ; FP32-NEXT: ori $1, $zero, 0
285 ; FP32-NEXT: mtc1 $1, $f0
286 ; FP32-NEXT: mtc1 $3, $f1
287 ; FP32-NEXT: sub.d $f2, $f12, $f0
288 ; FP32-NEXT: trunc.w.d $f2, $f2
289 ; FP32-NEXT: mfc1 $1, $f2
290 ; FP32-NEXT: lui $3, 32768
291 ; FP32-NEXT: xor $1, $1, $3
292 ; FP32-NEXT: addiu $3, $zero, 1
293 ; FP32-NEXT: c.ult.d $f12, $f0
294 ; FP32-NEXT: movf $3, $zero, $fcc0
295 ; FP32-NEXT: andi $3, $3, 1
296 ; FP32-NEXT: movn $1, $2, $3
297 ; FP32-NEXT: andi $2, $1, 65535
301 ; FP64-LABEL: f64tou16:
302 ; FP64: # %bb.0: # %entry
303 ; FP64-NEXT: trunc.w.d $f0, $f12
304 ; FP64-NEXT: mfc1 $2, $f0
305 ; FP64-NEXT: lui $3, 16864
306 ; FP64-NEXT: ori $1, $zero, 0
307 ; FP64-NEXT: mtc1 $1, $f0
308 ; FP64-NEXT: mthc1 $3, $f0
309 ; FP64-NEXT: sub.d $f1, $f12, $f0
310 ; FP64-NEXT: trunc.w.d $f1, $f1
311 ; FP64-NEXT: mfc1 $1, $f1
312 ; FP64-NEXT: lui $3, 32768
313 ; FP64-NEXT: xor $1, $1, $3
314 ; FP64-NEXT: addiu $3, $zero, 1
315 ; FP64-NEXT: c.ult.d $f12, $f0
316 ; FP64-NEXT: movf $3, $zero, $fcc0
317 ; FP64-NEXT: andi $3, $3, 1
318 ; FP64-NEXT: movn $1, $2, $3
319 ; FP64-NEXT: andi $2, $1, 65535
323 %conv = fptoui double %a to i16
327 define zeroext i8 @f64tou8(double %a) {
328 ; FP32-LABEL: f64tou8:
329 ; FP32: # %bb.0: # %entry
330 ; FP32-NEXT: trunc.w.d $f0, $f12
331 ; FP32-NEXT: mfc1 $2, $f0
332 ; FP32-NEXT: lui $3, 16864
333 ; FP32-NEXT: ori $1, $zero, 0
334 ; FP32-NEXT: mtc1 $1, $f0
335 ; FP32-NEXT: mtc1 $3, $f1
336 ; FP32-NEXT: sub.d $f2, $f12, $f0
337 ; FP32-NEXT: trunc.w.d $f2, $f2
338 ; FP32-NEXT: mfc1 $1, $f2
339 ; FP32-NEXT: lui $3, 32768
340 ; FP32-NEXT: xor $1, $1, $3
341 ; FP32-NEXT: addiu $3, $zero, 1
342 ; FP32-NEXT: c.ult.d $f12, $f0
343 ; FP32-NEXT: movf $3, $zero, $fcc0
344 ; FP32-NEXT: andi $3, $3, 1
345 ; FP32-NEXT: movn $1, $2, $3
346 ; FP32-NEXT: andi $2, $1, 255
350 ; FP64-LABEL: f64tou8:
351 ; FP64: # %bb.0: # %entry
352 ; FP64-NEXT: trunc.w.d $f0, $f12
353 ; FP64-NEXT: mfc1 $2, $f0
354 ; FP64-NEXT: lui $3, 16864
355 ; FP64-NEXT: ori $1, $zero, 0
356 ; FP64-NEXT: mtc1 $1, $f0
357 ; FP64-NEXT: mthc1 $3, $f0
358 ; FP64-NEXT: sub.d $f1, $f12, $f0
359 ; FP64-NEXT: trunc.w.d $f1, $f1
360 ; FP64-NEXT: mfc1 $1, $f1
361 ; FP64-NEXT: lui $3, 32768
362 ; FP64-NEXT: xor $1, $1, $3
363 ; FP64-NEXT: addiu $3, $zero, 1
364 ; FP64-NEXT: c.ult.d $f12, $f0
365 ; FP64-NEXT: movf $3, $zero, $fcc0
366 ; FP64-NEXT: andi $3, $3, 1
367 ; FP64-NEXT: movn $1, $2, $3
368 ; FP64-NEXT: andi $2, $1, 255
372 %conv = fptoui double %a to i8