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 float @i64tof32(i64 signext %a) {
6 ; MIPS32-LABEL: i64tof32:
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 __floatdisf
14 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
15 ; MIPS32-NEXT: addiu $sp, $sp, 24
19 %conv = sitofp i64 %a to float
23 define float @i32tof32(i32 signext %a) {
24 ; MIPS32-LABEL: i32tof32:
25 ; MIPS32: # %bb.0: # %entry
26 ; MIPS32-NEXT: mtc1 $4, $f0
27 ; MIPS32-NEXT: cvt.s.w $f0, $f0
31 %conv = sitofp i32 %a to float
35 define float @i16tof32(i16 signext %a) {
36 ; MIPS32-LABEL: i16tof32:
37 ; MIPS32: # %bb.0: # %entry
38 ; MIPS32-NEXT: sll $1, $4, 16
39 ; MIPS32-NEXT: sra $1, $1, 16
40 ; MIPS32-NEXT: mtc1 $1, $f0
41 ; MIPS32-NEXT: cvt.s.w $f0, $f0
45 %conv = sitofp i16 %a to float
49 define float @i8tof32(i8 signext %a) {
50 ; MIPS32-LABEL: i8tof32:
51 ; MIPS32: # %bb.0: # %entry
52 ; MIPS32-NEXT: sll $1, $4, 24
53 ; MIPS32-NEXT: sra $1, $1, 24
54 ; MIPS32-NEXT: mtc1 $1, $f0
55 ; MIPS32-NEXT: cvt.s.w $f0, $f0
59 %conv = sitofp i8 %a to float
63 define double @i64tof64(i64 signext %a) {
64 ; MIPS32-LABEL: i64tof64:
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 __floatdidf
72 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
73 ; MIPS32-NEXT: addiu $sp, $sp, 24
77 %conv = sitofp i64 %a to double
81 define double @i32tof64(i32 signext %a) {
82 ; MIPS32-LABEL: i32tof64:
83 ; MIPS32: # %bb.0: # %entry
84 ; MIPS32-NEXT: mtc1 $4, $f0
85 ; MIPS32-NEXT: cvt.d.w $f0, $f0
89 %conv = sitofp i32 %a to double
93 define double @i16tof64(i16 signext %a) {
94 ; MIPS32-LABEL: i16tof64:
95 ; MIPS32: # %bb.0: # %entry
96 ; MIPS32-NEXT: sll $1, $4, 16
97 ; MIPS32-NEXT: sra $1, $1, 16
98 ; MIPS32-NEXT: mtc1 $1, $f0
99 ; MIPS32-NEXT: cvt.d.w $f0, $f0
100 ; MIPS32-NEXT: jr $ra
103 %conv = sitofp i16 %a to double
107 define double @i8tof64(i8 signext %a) {
108 ; MIPS32-LABEL: i8tof64:
109 ; MIPS32: # %bb.0: # %entry
110 ; MIPS32-NEXT: sll $1, $4, 24
111 ; MIPS32-NEXT: sra $1, $1, 24
112 ; MIPS32-NEXT: mtc1 $1, $f0
113 ; MIPS32-NEXT: cvt.d.w $f0, $f0
114 ; MIPS32-NEXT: jr $ra
117 %conv = sitofp i8 %a to double
121 define float @u64tof32(i64 zeroext %a) {
122 ; MIPS32-LABEL: u64tof32:
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 __floatundisf
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 = uitofp i64 %a to float
140 define float @u32tof32(i32 zeroext %a) {
141 ; FP32-LABEL: u32tof32:
142 ; FP32: # %bb.0: # %entry
143 ; FP32-NEXT: lui $1, 17200
144 ; FP32-NEXT: mtc1 $4, $f0
145 ; FP32-NEXT: mtc1 $1, $f1
146 ; FP32-NEXT: lui $1, 17200
147 ; FP32-NEXT: ori $2, $zero, 0
148 ; FP32-NEXT: mtc1 $2, $f2
149 ; FP32-NEXT: mtc1 $1, $f3
150 ; FP32-NEXT: sub.d $f0, $f0, $f2
151 ; FP32-NEXT: cvt.s.d $f0, $f0
155 ; FP64-LABEL: u32tof32:
156 ; FP64: # %bb.0: # %entry
157 ; FP64-NEXT: lui $1, 17200
158 ; FP64-NEXT: mtc1 $4, $f0
159 ; FP64-NEXT: mthc1 $1, $f0
160 ; FP64-NEXT: lui $1, 17200
161 ; FP64-NEXT: ori $2, $zero, 0
162 ; FP64-NEXT: mtc1 $2, $f1
163 ; FP64-NEXT: mthc1 $1, $f1
164 ; FP64-NEXT: sub.d $f0, $f0, $f1
165 ; FP64-NEXT: cvt.s.d $f0, $f0
169 %conv = uitofp i32 %a to float
173 define float @u16tof32(i16 zeroext %a) {
174 ; FP32-LABEL: u16tof32:
175 ; FP32: # %bb.0: # %entry
176 ; FP32-NEXT: ori $1, $zero, 65535
177 ; FP32-NEXT: and $1, $4, $1
178 ; FP32-NEXT: lui $2, 17200
179 ; FP32-NEXT: mtc1 $1, $f0
180 ; FP32-NEXT: mtc1 $2, $f1
181 ; FP32-NEXT: lui $1, 17200
182 ; FP32-NEXT: ori $2, $zero, 0
183 ; FP32-NEXT: mtc1 $2, $f2
184 ; FP32-NEXT: mtc1 $1, $f3
185 ; FP32-NEXT: sub.d $f0, $f0, $f2
186 ; FP32-NEXT: cvt.s.d $f0, $f0
190 ; FP64-LABEL: u16tof32:
191 ; FP64: # %bb.0: # %entry
192 ; FP64-NEXT: ori $1, $zero, 65535
193 ; FP64-NEXT: and $1, $4, $1
194 ; FP64-NEXT: lui $2, 17200
195 ; FP64-NEXT: mtc1 $1, $f0
196 ; FP64-NEXT: mthc1 $2, $f0
197 ; FP64-NEXT: lui $1, 17200
198 ; FP64-NEXT: ori $2, $zero, 0
199 ; FP64-NEXT: mtc1 $2, $f1
200 ; FP64-NEXT: mthc1 $1, $f1
201 ; FP64-NEXT: sub.d $f0, $f0, $f1
202 ; FP64-NEXT: cvt.s.d $f0, $f0
206 %conv = uitofp i16 %a to float
210 define float @u8tof32(i8 zeroext %a) {
211 ; FP32-LABEL: u8tof32:
212 ; FP32: # %bb.0: # %entry
213 ; FP32-NEXT: ori $1, $zero, 255
214 ; FP32-NEXT: and $1, $4, $1
215 ; FP32-NEXT: lui $2, 17200
216 ; FP32-NEXT: mtc1 $1, $f0
217 ; FP32-NEXT: mtc1 $2, $f1
218 ; FP32-NEXT: lui $1, 17200
219 ; FP32-NEXT: ori $2, $zero, 0
220 ; FP32-NEXT: mtc1 $2, $f2
221 ; FP32-NEXT: mtc1 $1, $f3
222 ; FP32-NEXT: sub.d $f0, $f0, $f2
223 ; FP32-NEXT: cvt.s.d $f0, $f0
227 ; FP64-LABEL: u8tof32:
228 ; FP64: # %bb.0: # %entry
229 ; FP64-NEXT: ori $1, $zero, 255
230 ; FP64-NEXT: and $1, $4, $1
231 ; FP64-NEXT: lui $2, 17200
232 ; FP64-NEXT: mtc1 $1, $f0
233 ; FP64-NEXT: mthc1 $2, $f0
234 ; FP64-NEXT: lui $1, 17200
235 ; FP64-NEXT: ori $2, $zero, 0
236 ; FP64-NEXT: mtc1 $2, $f1
237 ; FP64-NEXT: mthc1 $1, $f1
238 ; FP64-NEXT: sub.d $f0, $f0, $f1
239 ; FP64-NEXT: cvt.s.d $f0, $f0
243 %conv = uitofp i8 %a to float
247 define double @u64tof64(i64 zeroext %a) {
248 ; MIPS32-LABEL: u64tof64:
249 ; MIPS32: # %bb.0: # %entry
250 ; MIPS32-NEXT: addiu $sp, $sp, -24
251 ; MIPS32-NEXT: .cfi_def_cfa_offset 24
252 ; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill
253 ; MIPS32-NEXT: .cfi_offset 31, -4
254 ; MIPS32-NEXT: jal __floatundidf
256 ; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload
257 ; MIPS32-NEXT: addiu $sp, $sp, 24
258 ; MIPS32-NEXT: jr $ra
261 %conv = uitofp i64 %a to double
265 define double @u32tof64(i32 zeroext %a) {
266 ; FP32-LABEL: u32tof64:
267 ; FP32: # %bb.0: # %entry
268 ; FP32-NEXT: lui $1, 17200
269 ; FP32-NEXT: mtc1 $4, $f0
270 ; FP32-NEXT: mtc1 $1, $f1
271 ; FP32-NEXT: lui $1, 17200
272 ; FP32-NEXT: ori $2, $zero, 0
273 ; FP32-NEXT: mtc1 $2, $f2
274 ; FP32-NEXT: mtc1 $1, $f3
275 ; FP32-NEXT: sub.d $f0, $f0, $f2
279 ; FP64-LABEL: u32tof64:
280 ; FP64: # %bb.0: # %entry
281 ; FP64-NEXT: lui $1, 17200
282 ; FP64-NEXT: mtc1 $4, $f0
283 ; FP64-NEXT: mthc1 $1, $f0
284 ; FP64-NEXT: lui $1, 17200
285 ; FP64-NEXT: ori $2, $zero, 0
286 ; FP64-NEXT: mtc1 $2, $f1
287 ; FP64-NEXT: mthc1 $1, $f1
288 ; FP64-NEXT: sub.d $f0, $f0, $f1
292 %conv = uitofp i32 %a to double
296 define double @u16tof64(i16 zeroext %a) {
297 ; FP32-LABEL: u16tof64:
298 ; FP32: # %bb.0: # %entry
299 ; FP32-NEXT: ori $1, $zero, 65535
300 ; FP32-NEXT: and $1, $4, $1
301 ; FP32-NEXT: lui $2, 17200
302 ; FP32-NEXT: mtc1 $1, $f0
303 ; FP32-NEXT: mtc1 $2, $f1
304 ; FP32-NEXT: lui $1, 17200
305 ; FP32-NEXT: ori $2, $zero, 0
306 ; FP32-NEXT: mtc1 $2, $f2
307 ; FP32-NEXT: mtc1 $1, $f3
308 ; FP32-NEXT: sub.d $f0, $f0, $f2
312 ; FP64-LABEL: u16tof64:
313 ; FP64: # %bb.0: # %entry
314 ; FP64-NEXT: ori $1, $zero, 65535
315 ; FP64-NEXT: and $1, $4, $1
316 ; FP64-NEXT: lui $2, 17200
317 ; FP64-NEXT: mtc1 $1, $f0
318 ; FP64-NEXT: mthc1 $2, $f0
319 ; FP64-NEXT: lui $1, 17200
320 ; FP64-NEXT: ori $2, $zero, 0
321 ; FP64-NEXT: mtc1 $2, $f1
322 ; FP64-NEXT: mthc1 $1, $f1
323 ; FP64-NEXT: sub.d $f0, $f0, $f1
327 %conv = uitofp i16 %a to double
331 define double @u8tof64(i8 zeroext %a) {
332 ; FP32-LABEL: u8tof64:
333 ; FP32: # %bb.0: # %entry
334 ; FP32-NEXT: ori $1, $zero, 255
335 ; FP32-NEXT: and $1, $4, $1
336 ; FP32-NEXT: lui $2, 17200
337 ; FP32-NEXT: mtc1 $1, $f0
338 ; FP32-NEXT: mtc1 $2, $f1
339 ; FP32-NEXT: lui $1, 17200
340 ; FP32-NEXT: ori $2, $zero, 0
341 ; FP32-NEXT: mtc1 $2, $f2
342 ; FP32-NEXT: mtc1 $1, $f3
343 ; FP32-NEXT: sub.d $f0, $f0, $f2
347 ; FP64-LABEL: u8tof64:
348 ; FP64: # %bb.0: # %entry
349 ; FP64-NEXT: ori $1, $zero, 255
350 ; FP64-NEXT: and $1, $4, $1
351 ; FP64-NEXT: lui $2, 17200
352 ; FP64-NEXT: mtc1 $1, $f0
353 ; FP64-NEXT: mthc1 $2, $f0
354 ; FP64-NEXT: lui $1, 17200
355 ; FP64-NEXT: ori $2, $zero, 0
356 ; FP64-NEXT: mtc1 $2, $f1
357 ; FP64-NEXT: mthc1 $1, $f1
358 ; FP64-NEXT: sub.d $f0, $f0, $f1
362 %conv = uitofp i8 %a to double