1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
3 ; RUN: -target-abi=ilp32f | FileCheck -check-prefixes=CHECKIF,RV32IF %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
5 ; RUN: -target-abi=lp64f | FileCheck -check-prefixes=CHECKIF,RV64IF %s
6 ; RUN: llc -mtriple=riscv32 -mattr=+zfinx -verify-machineinstrs < %s \
7 ; RUN: -target-abi=ilp32 | FileCheck -check-prefixes=CHECKIZFINX,RV32IZFINX %s
8 ; RUN: llc -mtriple=riscv64 -mattr=+zfinx -verify-machineinstrs < %s \
9 ; RUN: -target-abi=lp64 | FileCheck -check-prefixes=CHECKIZFINX,RV64IZFINX %s
10 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
11 ; RUN: | FileCheck -check-prefix=RV32I %s
12 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
13 ; RUN: | FileCheck -check-prefix=RV64I %s
15 define i32 @fcvt_w_s(float %a) nounwind {
16 ; CHECKIF-LABEL: fcvt_w_s:
18 ; CHECKIF-NEXT: fcvt.w.s a0, fa0, rtz
21 ; CHECKIZFINX-LABEL: fcvt_w_s:
22 ; CHECKIZFINX: # %bb.0:
23 ; CHECKIZFINX-NEXT: fcvt.w.s a0, a0, rtz
24 ; CHECKIZFINX-NEXT: ret
26 ; RV32I-LABEL: fcvt_w_s:
28 ; RV32I-NEXT: addi sp, sp, -16
29 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
30 ; RV32I-NEXT: call __fixsfsi@plt
31 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
32 ; RV32I-NEXT: addi sp, sp, 16
35 ; RV64I-LABEL: fcvt_w_s:
37 ; RV64I-NEXT: addi sp, sp, -16
38 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
39 ; RV64I-NEXT: call __fixsfsi@plt
40 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
41 ; RV64I-NEXT: addi sp, sp, 16
43 %1 = fptosi float %a to i32
47 define i32 @fcvt_w_s_sat(float %a) nounwind {
48 ; CHECKIF-LABEL: fcvt_w_s_sat:
49 ; CHECKIF: # %bb.0: # %start
50 ; CHECKIF-NEXT: fcvt.w.s a0, fa0, rtz
51 ; CHECKIF-NEXT: feq.s a1, fa0, fa0
52 ; CHECKIF-NEXT: seqz a1, a1
53 ; CHECKIF-NEXT: addi a1, a1, -1
54 ; CHECKIF-NEXT: and a0, a1, a0
57 ; CHECKIZFINX-LABEL: fcvt_w_s_sat:
58 ; CHECKIZFINX: # %bb.0: # %start
59 ; CHECKIZFINX-NEXT: fcvt.w.s a1, a0, rtz
60 ; CHECKIZFINX-NEXT: feq.s a0, a0, a0
61 ; CHECKIZFINX-NEXT: seqz a0, a0
62 ; CHECKIZFINX-NEXT: addi a0, a0, -1
63 ; CHECKIZFINX-NEXT: and a0, a0, a1
64 ; CHECKIZFINX-NEXT: ret
66 ; RV32I-LABEL: fcvt_w_s_sat:
67 ; RV32I: # %bb.0: # %start
68 ; RV32I-NEXT: addi sp, sp, -32
69 ; RV32I-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
70 ; RV32I-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
71 ; RV32I-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
72 ; RV32I-NEXT: sw s2, 16(sp) # 4-byte Folded Spill
73 ; RV32I-NEXT: sw s3, 12(sp) # 4-byte Folded Spill
74 ; RV32I-NEXT: mv s0, a0
75 ; RV32I-NEXT: lui a1, 847872
76 ; RV32I-NEXT: call __gesf2@plt
77 ; RV32I-NEXT: mv s2, a0
78 ; RV32I-NEXT: mv a0, s0
79 ; RV32I-NEXT: call __fixsfsi@plt
80 ; RV32I-NEXT: mv s1, a0
81 ; RV32I-NEXT: lui s3, 524288
82 ; RV32I-NEXT: bgez s2, .LBB1_2
83 ; RV32I-NEXT: # %bb.1: # %start
84 ; RV32I-NEXT: lui s1, 524288
85 ; RV32I-NEXT: .LBB1_2: # %start
86 ; RV32I-NEXT: lui a1, 323584
87 ; RV32I-NEXT: addi a1, a1, -1
88 ; RV32I-NEXT: mv a0, s0
89 ; RV32I-NEXT: call __gtsf2@plt
90 ; RV32I-NEXT: blez a0, .LBB1_4
91 ; RV32I-NEXT: # %bb.3: # %start
92 ; RV32I-NEXT: addi s1, s3, -1
93 ; RV32I-NEXT: .LBB1_4: # %start
94 ; RV32I-NEXT: mv a0, s0
95 ; RV32I-NEXT: mv a1, s0
96 ; RV32I-NEXT: call __unordsf2@plt
97 ; RV32I-NEXT: snez a0, a0
98 ; RV32I-NEXT: addi a0, a0, -1
99 ; RV32I-NEXT: and a0, a0, s1
100 ; RV32I-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
101 ; RV32I-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
102 ; RV32I-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
103 ; RV32I-NEXT: lw s2, 16(sp) # 4-byte Folded Reload
104 ; RV32I-NEXT: lw s3, 12(sp) # 4-byte Folded Reload
105 ; RV32I-NEXT: addi sp, sp, 32
108 ; RV64I-LABEL: fcvt_w_s_sat:
109 ; RV64I: # %bb.0: # %start
110 ; RV64I-NEXT: addi sp, sp, -48
111 ; RV64I-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
112 ; RV64I-NEXT: sd s0, 32(sp) # 8-byte Folded Spill
113 ; RV64I-NEXT: sd s1, 24(sp) # 8-byte Folded Spill
114 ; RV64I-NEXT: sd s2, 16(sp) # 8-byte Folded Spill
115 ; RV64I-NEXT: sd s3, 8(sp) # 8-byte Folded Spill
116 ; RV64I-NEXT: mv s0, a0
117 ; RV64I-NEXT: lui a1, 847872
118 ; RV64I-NEXT: call __gesf2@plt
119 ; RV64I-NEXT: mv s2, a0
120 ; RV64I-NEXT: mv a0, s0
121 ; RV64I-NEXT: call __fixsfdi@plt
122 ; RV64I-NEXT: mv s1, a0
123 ; RV64I-NEXT: lui s3, 524288
124 ; RV64I-NEXT: bgez s2, .LBB1_2
125 ; RV64I-NEXT: # %bb.1: # %start
126 ; RV64I-NEXT: lui s1, 524288
127 ; RV64I-NEXT: .LBB1_2: # %start
128 ; RV64I-NEXT: lui a1, 323584
129 ; RV64I-NEXT: addiw a1, a1, -1
130 ; RV64I-NEXT: mv a0, s0
131 ; RV64I-NEXT: call __gtsf2@plt
132 ; RV64I-NEXT: blez a0, .LBB1_4
133 ; RV64I-NEXT: # %bb.3: # %start
134 ; RV64I-NEXT: addiw s1, s3, -1
135 ; RV64I-NEXT: .LBB1_4: # %start
136 ; RV64I-NEXT: mv a0, s0
137 ; RV64I-NEXT: mv a1, s0
138 ; RV64I-NEXT: call __unordsf2@plt
139 ; RV64I-NEXT: snez a0, a0
140 ; RV64I-NEXT: addi a0, a0, -1
141 ; RV64I-NEXT: and a0, a0, s1
142 ; RV64I-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
143 ; RV64I-NEXT: ld s0, 32(sp) # 8-byte Folded Reload
144 ; RV64I-NEXT: ld s1, 24(sp) # 8-byte Folded Reload
145 ; RV64I-NEXT: ld s2, 16(sp) # 8-byte Folded Reload
146 ; RV64I-NEXT: ld s3, 8(sp) # 8-byte Folded Reload
147 ; RV64I-NEXT: addi sp, sp, 48
150 %0 = tail call i32 @llvm.fptosi.sat.i32.f32(float %a)
153 declare i32 @llvm.fptosi.sat.i32.f32(float)
155 define i32 @fcvt_wu_s(float %a) nounwind {
156 ; CHECKIF-LABEL: fcvt_wu_s:
158 ; CHECKIF-NEXT: fcvt.wu.s a0, fa0, rtz
161 ; CHECKIZFINX-LABEL: fcvt_wu_s:
162 ; CHECKIZFINX: # %bb.0:
163 ; CHECKIZFINX-NEXT: fcvt.wu.s a0, a0, rtz
164 ; CHECKIZFINX-NEXT: ret
166 ; RV32I-LABEL: fcvt_wu_s:
168 ; RV32I-NEXT: addi sp, sp, -16
169 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
170 ; RV32I-NEXT: call __fixunssfsi@plt
171 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
172 ; RV32I-NEXT: addi sp, sp, 16
175 ; RV64I-LABEL: fcvt_wu_s:
177 ; RV64I-NEXT: addi sp, sp, -16
178 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
179 ; RV64I-NEXT: call __fixunssfsi@plt
180 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
181 ; RV64I-NEXT: addi sp, sp, 16
183 %1 = fptoui float %a to i32
187 ; Test where the fptoui has multiple uses, one of which causes a sext to be
189 define i32 @fcvt_wu_s_multiple_use(float %x, ptr %y) nounwind {
190 ; CHECKIF-LABEL: fcvt_wu_s_multiple_use:
192 ; CHECKIF-NEXT: fcvt.wu.s a0, fa0, rtz
193 ; CHECKIF-NEXT: seqz a1, a0
194 ; CHECKIF-NEXT: add a0, a0, a1
197 ; CHECKIZFINX-LABEL: fcvt_wu_s_multiple_use:
198 ; CHECKIZFINX: # %bb.0:
199 ; CHECKIZFINX-NEXT: fcvt.wu.s a0, a0, rtz
200 ; CHECKIZFINX-NEXT: seqz a1, a0
201 ; CHECKIZFINX-NEXT: add a0, a0, a1
202 ; CHECKIZFINX-NEXT: ret
204 ; RV32I-LABEL: fcvt_wu_s_multiple_use:
206 ; RV32I-NEXT: addi sp, sp, -16
207 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
208 ; RV32I-NEXT: call __fixunssfsi@plt
209 ; RV32I-NEXT: seqz a1, a0
210 ; RV32I-NEXT: add a0, a0, a1
211 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
212 ; RV32I-NEXT: addi sp, sp, 16
215 ; RV64I-LABEL: fcvt_wu_s_multiple_use:
217 ; RV64I-NEXT: addi sp, sp, -16
218 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
219 ; RV64I-NEXT: call __fixunssfsi@plt
220 ; RV64I-NEXT: seqz a1, a0
221 ; RV64I-NEXT: add a0, a0, a1
222 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
223 ; RV64I-NEXT: addi sp, sp, 16
225 %a = fptoui float %x to i32
226 %b = icmp eq i32 %a, 0
227 %c = select i1 %b, i32 1, i32 %a
231 define i32 @fcvt_wu_s_sat(float %a) nounwind {
232 ; RV32IF-LABEL: fcvt_wu_s_sat:
233 ; RV32IF: # %bb.0: # %start
234 ; RV32IF-NEXT: fcvt.wu.s a0, fa0, rtz
235 ; RV32IF-NEXT: feq.s a1, fa0, fa0
236 ; RV32IF-NEXT: seqz a1, a1
237 ; RV32IF-NEXT: addi a1, a1, -1
238 ; RV32IF-NEXT: and a0, a1, a0
241 ; RV64IF-LABEL: fcvt_wu_s_sat:
242 ; RV64IF: # %bb.0: # %start
243 ; RV64IF-NEXT: fcvt.wu.s a0, fa0, rtz
244 ; RV64IF-NEXT: feq.s a1, fa0, fa0
245 ; RV64IF-NEXT: seqz a1, a1
246 ; RV64IF-NEXT: addi a1, a1, -1
247 ; RV64IF-NEXT: and a0, a0, a1
248 ; RV64IF-NEXT: slli a0, a0, 32
249 ; RV64IF-NEXT: srli a0, a0, 32
252 ; RV32IZFINX-LABEL: fcvt_wu_s_sat:
253 ; RV32IZFINX: # %bb.0: # %start
254 ; RV32IZFINX-NEXT: fcvt.wu.s a1, a0, rtz
255 ; RV32IZFINX-NEXT: feq.s a0, a0, a0
256 ; RV32IZFINX-NEXT: seqz a0, a0
257 ; RV32IZFINX-NEXT: addi a0, a0, -1
258 ; RV32IZFINX-NEXT: and a0, a0, a1
259 ; RV32IZFINX-NEXT: ret
261 ; RV64IZFINX-LABEL: fcvt_wu_s_sat:
262 ; RV64IZFINX: # %bb.0: # %start
263 ; RV64IZFINX-NEXT: fcvt.wu.s a1, a0, rtz
264 ; RV64IZFINX-NEXT: feq.s a0, a0, a0
265 ; RV64IZFINX-NEXT: seqz a0, a0
266 ; RV64IZFINX-NEXT: addi a0, a0, -1
267 ; RV64IZFINX-NEXT: and a0, a1, a0
268 ; RV64IZFINX-NEXT: slli a0, a0, 32
269 ; RV64IZFINX-NEXT: srli a0, a0, 32
270 ; RV64IZFINX-NEXT: ret
272 ; RV32I-LABEL: fcvt_wu_s_sat:
273 ; RV32I: # %bb.0: # %start
274 ; RV32I-NEXT: addi sp, sp, -16
275 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
276 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
277 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
278 ; RV32I-NEXT: mv s0, a0
279 ; RV32I-NEXT: li a1, 0
280 ; RV32I-NEXT: call __gesf2@plt
281 ; RV32I-NEXT: slti a0, a0, 0
282 ; RV32I-NEXT: addi s1, a0, -1
283 ; RV32I-NEXT: mv a0, s0
284 ; RV32I-NEXT: call __fixunssfsi@plt
285 ; RV32I-NEXT: and s1, s1, a0
286 ; RV32I-NEXT: lui a1, 325632
287 ; RV32I-NEXT: addi a1, a1, -1
288 ; RV32I-NEXT: mv a0, s0
289 ; RV32I-NEXT: call __gtsf2@plt
290 ; RV32I-NEXT: sgtz a0, a0
291 ; RV32I-NEXT: neg a0, a0
292 ; RV32I-NEXT: or a0, a0, s1
293 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
294 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
295 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
296 ; RV32I-NEXT: addi sp, sp, 16
299 ; RV64I-LABEL: fcvt_wu_s_sat:
300 ; RV64I: # %bb.0: # %start
301 ; RV64I-NEXT: addi sp, sp, -32
302 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
303 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
304 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
305 ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
306 ; RV64I-NEXT: mv s2, a0
307 ; RV64I-NEXT: li a1, 0
308 ; RV64I-NEXT: call __gesf2@plt
309 ; RV64I-NEXT: mv s0, a0
310 ; RV64I-NEXT: mv a0, s2
311 ; RV64I-NEXT: call __fixunssfdi@plt
312 ; RV64I-NEXT: mv s1, a0
313 ; RV64I-NEXT: lui a1, 325632
314 ; RV64I-NEXT: addiw a1, a1, -1
315 ; RV64I-NEXT: mv a0, s2
316 ; RV64I-NEXT: call __gtsf2@plt
317 ; RV64I-NEXT: blez a0, .LBB4_2
318 ; RV64I-NEXT: # %bb.1: # %start
319 ; RV64I-NEXT: li a0, -1
320 ; RV64I-NEXT: srli a0, a0, 32
321 ; RV64I-NEXT: j .LBB4_3
322 ; RV64I-NEXT: .LBB4_2:
323 ; RV64I-NEXT: slti a0, s0, 0
324 ; RV64I-NEXT: addi a0, a0, -1
325 ; RV64I-NEXT: and a0, a0, s1
326 ; RV64I-NEXT: .LBB4_3: # %start
327 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
328 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
329 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
330 ; RV64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
331 ; RV64I-NEXT: addi sp, sp, 32
334 %0 = tail call i32 @llvm.fptoui.sat.i32.f32(float %a)
337 declare i32 @llvm.fptoui.sat.i32.f32(float)
339 define i32 @fmv_x_w(float %a, float %b) nounwind {
340 ; CHECKIF-LABEL: fmv_x_w:
342 ; CHECKIF-NEXT: fadd.s fa5, fa0, fa1
343 ; CHECKIF-NEXT: fmv.x.w a0, fa5
346 ; CHECKIZFINX-LABEL: fmv_x_w:
347 ; CHECKIZFINX: # %bb.0:
348 ; CHECKIZFINX-NEXT: fadd.s a0, a0, a1
349 ; CHECKIZFINX-NEXT: ret
351 ; RV32I-LABEL: fmv_x_w:
353 ; RV32I-NEXT: addi sp, sp, -16
354 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
355 ; RV32I-NEXT: call __addsf3@plt
356 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
357 ; RV32I-NEXT: addi sp, sp, 16
360 ; RV64I-LABEL: fmv_x_w:
362 ; RV64I-NEXT: addi sp, sp, -16
363 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
364 ; RV64I-NEXT: call __addsf3@plt
365 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
366 ; RV64I-NEXT: addi sp, sp, 16
368 ; Ensure fmv.x.w is generated even for a soft float calling convention
369 %1 = fadd float %a, %b
370 %2 = bitcast float %1 to i32
374 define float @fcvt_s_w(i32 %a) nounwind {
375 ; CHECKIF-LABEL: fcvt_s_w:
377 ; CHECKIF-NEXT: fcvt.s.w fa0, a0
380 ; CHECKIZFINX-LABEL: fcvt_s_w:
381 ; CHECKIZFINX: # %bb.0:
382 ; CHECKIZFINX-NEXT: fcvt.s.w a0, a0
383 ; CHECKIZFINX-NEXT: ret
385 ; RV32I-LABEL: fcvt_s_w:
387 ; RV32I-NEXT: addi sp, sp, -16
388 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
389 ; RV32I-NEXT: call __floatsisf@plt
390 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
391 ; RV32I-NEXT: addi sp, sp, 16
394 ; RV64I-LABEL: fcvt_s_w:
396 ; RV64I-NEXT: addi sp, sp, -16
397 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
398 ; RV64I-NEXT: sext.w a0, a0
399 ; RV64I-NEXT: call __floatsisf@plt
400 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
401 ; RV64I-NEXT: addi sp, sp, 16
403 %1 = sitofp i32 %a to float
407 define float @fcvt_s_w_load(ptr %p) nounwind {
408 ; CHECKIF-LABEL: fcvt_s_w_load:
410 ; CHECKIF-NEXT: lw a0, 0(a0)
411 ; CHECKIF-NEXT: fcvt.s.w fa0, a0
414 ; CHECKIZFINX-LABEL: fcvt_s_w_load:
415 ; CHECKIZFINX: # %bb.0:
416 ; CHECKIZFINX-NEXT: lw a0, 0(a0)
417 ; CHECKIZFINX-NEXT: fcvt.s.w a0, a0
418 ; CHECKIZFINX-NEXT: ret
420 ; RV32I-LABEL: fcvt_s_w_load:
422 ; RV32I-NEXT: addi sp, sp, -16
423 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
424 ; RV32I-NEXT: lw a0, 0(a0)
425 ; RV32I-NEXT: call __floatsisf@plt
426 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
427 ; RV32I-NEXT: addi sp, sp, 16
430 ; RV64I-LABEL: fcvt_s_w_load:
432 ; RV64I-NEXT: addi sp, sp, -16
433 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
434 ; RV64I-NEXT: lw a0, 0(a0)
435 ; RV64I-NEXT: call __floatsisf@plt
436 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
437 ; RV64I-NEXT: addi sp, sp, 16
439 %a = load i32, ptr %p
440 %1 = sitofp i32 %a to float
444 define float @fcvt_s_wu(i32 %a) nounwind {
445 ; CHECKIF-LABEL: fcvt_s_wu:
447 ; CHECKIF-NEXT: fcvt.s.wu fa0, a0
450 ; CHECKIZFINX-LABEL: fcvt_s_wu:
451 ; CHECKIZFINX: # %bb.0:
452 ; CHECKIZFINX-NEXT: fcvt.s.wu a0, a0
453 ; CHECKIZFINX-NEXT: ret
455 ; RV32I-LABEL: fcvt_s_wu:
457 ; RV32I-NEXT: addi sp, sp, -16
458 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
459 ; RV32I-NEXT: call __floatunsisf@plt
460 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
461 ; RV32I-NEXT: addi sp, sp, 16
464 ; RV64I-LABEL: fcvt_s_wu:
466 ; RV64I-NEXT: addi sp, sp, -16
467 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
468 ; RV64I-NEXT: sext.w a0, a0
469 ; RV64I-NEXT: call __floatunsisf@plt
470 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
471 ; RV64I-NEXT: addi sp, sp, 16
473 %1 = uitofp i32 %a to float
477 define float @fcvt_s_wu_load(ptr %p) nounwind {
478 ; RV32IF-LABEL: fcvt_s_wu_load:
480 ; RV32IF-NEXT: lw a0, 0(a0)
481 ; RV32IF-NEXT: fcvt.s.wu fa0, a0
484 ; RV64IF-LABEL: fcvt_s_wu_load:
486 ; RV64IF-NEXT: lwu a0, 0(a0)
487 ; RV64IF-NEXT: fcvt.s.wu fa0, a0
490 ; RV32IZFINX-LABEL: fcvt_s_wu_load:
491 ; RV32IZFINX: # %bb.0:
492 ; RV32IZFINX-NEXT: lw a0, 0(a0)
493 ; RV32IZFINX-NEXT: fcvt.s.wu a0, a0
494 ; RV32IZFINX-NEXT: ret
496 ; RV64IZFINX-LABEL: fcvt_s_wu_load:
497 ; RV64IZFINX: # %bb.0:
498 ; RV64IZFINX-NEXT: lwu a0, 0(a0)
499 ; RV64IZFINX-NEXT: fcvt.s.wu a0, a0
500 ; RV64IZFINX-NEXT: ret
502 ; RV32I-LABEL: fcvt_s_wu_load:
504 ; RV32I-NEXT: addi sp, sp, -16
505 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
506 ; RV32I-NEXT: lw a0, 0(a0)
507 ; RV32I-NEXT: call __floatunsisf@plt
508 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
509 ; RV32I-NEXT: addi sp, sp, 16
512 ; RV64I-LABEL: fcvt_s_wu_load:
514 ; RV64I-NEXT: addi sp, sp, -16
515 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
516 ; RV64I-NEXT: lw a0, 0(a0)
517 ; RV64I-NEXT: call __floatunsisf@plt
518 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
519 ; RV64I-NEXT: addi sp, sp, 16
521 %a = load i32, ptr %p
522 %1 = uitofp i32 %a to float
526 define float @fmv_w_x(i32 %a, i32 %b) nounwind {
527 ; CHECKIF-LABEL: fmv_w_x:
529 ; CHECKIF-NEXT: fmv.w.x fa5, a0
530 ; CHECKIF-NEXT: fmv.w.x fa4, a1
531 ; CHECKIF-NEXT: fadd.s fa0, fa5, fa4
534 ; CHECKIZFINX-LABEL: fmv_w_x:
535 ; CHECKIZFINX: # %bb.0:
536 ; CHECKIZFINX-NEXT: fadd.s a0, a0, a1
537 ; CHECKIZFINX-NEXT: ret
539 ; RV32I-LABEL: fmv_w_x:
541 ; RV32I-NEXT: addi sp, sp, -16
542 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
543 ; RV32I-NEXT: call __addsf3@plt
544 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
545 ; RV32I-NEXT: addi sp, sp, 16
548 ; RV64I-LABEL: fmv_w_x:
550 ; RV64I-NEXT: addi sp, sp, -16
551 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
552 ; RV64I-NEXT: call __addsf3@plt
553 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
554 ; RV64I-NEXT: addi sp, sp, 16
556 ; Ensure fmv.w.x is generated even for a soft float calling convention
557 %1 = bitcast i32 %a to float
558 %2 = bitcast i32 %b to float
559 %3 = fadd float %1, %2
563 define i64 @fcvt_l_s(float %a) nounwind {
564 ; RV32IF-LABEL: fcvt_l_s:
566 ; RV32IF-NEXT: addi sp, sp, -16
567 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
568 ; RV32IF-NEXT: call __fixsfdi@plt
569 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
570 ; RV32IF-NEXT: addi sp, sp, 16
573 ; RV64IF-LABEL: fcvt_l_s:
575 ; RV64IF-NEXT: fcvt.l.s a0, fa0, rtz
578 ; RV32IZFINX-LABEL: fcvt_l_s:
579 ; RV32IZFINX: # %bb.0:
580 ; RV32IZFINX-NEXT: addi sp, sp, -16
581 ; RV32IZFINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
582 ; RV32IZFINX-NEXT: call __fixsfdi@plt
583 ; RV32IZFINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
584 ; RV32IZFINX-NEXT: addi sp, sp, 16
585 ; RV32IZFINX-NEXT: ret
587 ; RV64IZFINX-LABEL: fcvt_l_s:
588 ; RV64IZFINX: # %bb.0:
589 ; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rtz
590 ; RV64IZFINX-NEXT: ret
592 ; RV32I-LABEL: fcvt_l_s:
594 ; RV32I-NEXT: addi sp, sp, -16
595 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
596 ; RV32I-NEXT: call __fixsfdi@plt
597 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
598 ; RV32I-NEXT: addi sp, sp, 16
601 ; RV64I-LABEL: fcvt_l_s:
603 ; RV64I-NEXT: addi sp, sp, -16
604 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
605 ; RV64I-NEXT: call __fixsfdi@plt
606 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
607 ; RV64I-NEXT: addi sp, sp, 16
609 %1 = fptosi float %a to i64
613 define i64 @fcvt_l_s_sat(float %a) nounwind {
614 ; RV32IF-LABEL: fcvt_l_s_sat:
615 ; RV32IF: # %bb.0: # %start
616 ; RV32IF-NEXT: addi sp, sp, -16
617 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
618 ; RV32IF-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
619 ; RV32IF-NEXT: fsw fs0, 4(sp) # 4-byte Folded Spill
620 ; RV32IF-NEXT: fmv.s fs0, fa0
621 ; RV32IF-NEXT: lui a0, 913408
622 ; RV32IF-NEXT: fmv.w.x fa5, a0
623 ; RV32IF-NEXT: fle.s s0, fa5, fa0
624 ; RV32IF-NEXT: call __fixsfdi@plt
625 ; RV32IF-NEXT: lui a4, 524288
626 ; RV32IF-NEXT: lui a2, 524288
627 ; RV32IF-NEXT: beqz s0, .LBB12_2
628 ; RV32IF-NEXT: # %bb.1: # %start
629 ; RV32IF-NEXT: mv a2, a1
630 ; RV32IF-NEXT: .LBB12_2: # %start
631 ; RV32IF-NEXT: lui a1, %hi(.LCPI12_0)
632 ; RV32IF-NEXT: flw fa5, %lo(.LCPI12_0)(a1)
633 ; RV32IF-NEXT: flt.s a3, fa5, fs0
634 ; RV32IF-NEXT: beqz a3, .LBB12_4
635 ; RV32IF-NEXT: # %bb.3:
636 ; RV32IF-NEXT: addi a2, a4, -1
637 ; RV32IF-NEXT: .LBB12_4: # %start
638 ; RV32IF-NEXT: feq.s a1, fs0, fs0
639 ; RV32IF-NEXT: neg a4, a1
640 ; RV32IF-NEXT: and a1, a4, a2
641 ; RV32IF-NEXT: neg a2, a3
642 ; RV32IF-NEXT: neg a3, s0
643 ; RV32IF-NEXT: and a0, a3, a0
644 ; RV32IF-NEXT: or a0, a2, a0
645 ; RV32IF-NEXT: and a0, a4, a0
646 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
647 ; RV32IF-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
648 ; RV32IF-NEXT: flw fs0, 4(sp) # 4-byte Folded Reload
649 ; RV32IF-NEXT: addi sp, sp, 16
652 ; RV64IF-LABEL: fcvt_l_s_sat:
653 ; RV64IF: # %bb.0: # %start
654 ; RV64IF-NEXT: fcvt.l.s a0, fa0, rtz
655 ; RV64IF-NEXT: feq.s a1, fa0, fa0
656 ; RV64IF-NEXT: seqz a1, a1
657 ; RV64IF-NEXT: addi a1, a1, -1
658 ; RV64IF-NEXT: and a0, a1, a0
661 ; RV32IZFINX-LABEL: fcvt_l_s_sat:
662 ; RV32IZFINX: # %bb.0: # %start
663 ; RV32IZFINX-NEXT: addi sp, sp, -16
664 ; RV32IZFINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
665 ; RV32IZFINX-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
666 ; RV32IZFINX-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
667 ; RV32IZFINX-NEXT: mv s0, a0
668 ; RV32IZFINX-NEXT: lui a0, 913408
669 ; RV32IZFINX-NEXT: fle.s s1, a0, s0
670 ; RV32IZFINX-NEXT: mv a0, s0
671 ; RV32IZFINX-NEXT: call __fixsfdi@plt
672 ; RV32IZFINX-NEXT: lui a4, 524288
673 ; RV32IZFINX-NEXT: lui a2, 524288
674 ; RV32IZFINX-NEXT: beqz s1, .LBB12_2
675 ; RV32IZFINX-NEXT: # %bb.1: # %start
676 ; RV32IZFINX-NEXT: mv a2, a1
677 ; RV32IZFINX-NEXT: .LBB12_2: # %start
678 ; RV32IZFINX-NEXT: lui a1, %hi(.LCPI12_0)
679 ; RV32IZFINX-NEXT: lw a1, %lo(.LCPI12_0)(a1)
680 ; RV32IZFINX-NEXT: flt.s a3, a1, s0
681 ; RV32IZFINX-NEXT: beqz a3, .LBB12_4
682 ; RV32IZFINX-NEXT: # %bb.3:
683 ; RV32IZFINX-NEXT: addi a2, a4, -1
684 ; RV32IZFINX-NEXT: .LBB12_4: # %start
685 ; RV32IZFINX-NEXT: feq.s a1, s0, s0
686 ; RV32IZFINX-NEXT: neg a4, a1
687 ; RV32IZFINX-NEXT: and a1, a4, a2
688 ; RV32IZFINX-NEXT: neg a2, s1
689 ; RV32IZFINX-NEXT: and a0, a2, a0
690 ; RV32IZFINX-NEXT: neg a2, a3
691 ; RV32IZFINX-NEXT: or a0, a2, a0
692 ; RV32IZFINX-NEXT: and a0, a4, a0
693 ; RV32IZFINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
694 ; RV32IZFINX-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
695 ; RV32IZFINX-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
696 ; RV32IZFINX-NEXT: addi sp, sp, 16
697 ; RV32IZFINX-NEXT: ret
699 ; RV64IZFINX-LABEL: fcvt_l_s_sat:
700 ; RV64IZFINX: # %bb.0: # %start
701 ; RV64IZFINX-NEXT: fcvt.l.s a1, a0, rtz
702 ; RV64IZFINX-NEXT: feq.s a0, a0, a0
703 ; RV64IZFINX-NEXT: seqz a0, a0
704 ; RV64IZFINX-NEXT: addi a0, a0, -1
705 ; RV64IZFINX-NEXT: and a0, a0, a1
706 ; RV64IZFINX-NEXT: ret
708 ; RV32I-LABEL: fcvt_l_s_sat:
709 ; RV32I: # %bb.0: # %start
710 ; RV32I-NEXT: addi sp, sp, -32
711 ; RV32I-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
712 ; RV32I-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
713 ; RV32I-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
714 ; RV32I-NEXT: sw s2, 16(sp) # 4-byte Folded Spill
715 ; RV32I-NEXT: sw s3, 12(sp) # 4-byte Folded Spill
716 ; RV32I-NEXT: sw s4, 8(sp) # 4-byte Folded Spill
717 ; RV32I-NEXT: sw s5, 4(sp) # 4-byte Folded Spill
718 ; RV32I-NEXT: mv s0, a0
719 ; RV32I-NEXT: lui a1, 913408
720 ; RV32I-NEXT: call __gesf2@plt
721 ; RV32I-NEXT: mv s1, a0
722 ; RV32I-NEXT: mv a0, s0
723 ; RV32I-NEXT: call __fixsfdi@plt
724 ; RV32I-NEXT: mv s2, a0
725 ; RV32I-NEXT: mv s3, a1
726 ; RV32I-NEXT: lui s5, 524288
727 ; RV32I-NEXT: bgez s1, .LBB12_2
728 ; RV32I-NEXT: # %bb.1: # %start
729 ; RV32I-NEXT: lui s3, 524288
730 ; RV32I-NEXT: .LBB12_2: # %start
731 ; RV32I-NEXT: lui a1, 389120
732 ; RV32I-NEXT: addi a1, a1, -1
733 ; RV32I-NEXT: mv a0, s0
734 ; RV32I-NEXT: call __gtsf2@plt
735 ; RV32I-NEXT: mv s4, a0
736 ; RV32I-NEXT: blez a0, .LBB12_4
737 ; RV32I-NEXT: # %bb.3: # %start
738 ; RV32I-NEXT: addi s3, s5, -1
739 ; RV32I-NEXT: .LBB12_4: # %start
740 ; RV32I-NEXT: mv a0, s0
741 ; RV32I-NEXT: mv a1, s0
742 ; RV32I-NEXT: call __unordsf2@plt
743 ; RV32I-NEXT: snez a0, a0
744 ; RV32I-NEXT: addi a0, a0, -1
745 ; RV32I-NEXT: and a1, a0, s3
746 ; RV32I-NEXT: slti a2, s1, 0
747 ; RV32I-NEXT: addi a2, a2, -1
748 ; RV32I-NEXT: and a2, a2, s2
749 ; RV32I-NEXT: sgtz a3, s4
750 ; RV32I-NEXT: neg a3, a3
751 ; RV32I-NEXT: or a2, a3, a2
752 ; RV32I-NEXT: and a0, a0, a2
753 ; RV32I-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
754 ; RV32I-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
755 ; RV32I-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
756 ; RV32I-NEXT: lw s2, 16(sp) # 4-byte Folded Reload
757 ; RV32I-NEXT: lw s3, 12(sp) # 4-byte Folded Reload
758 ; RV32I-NEXT: lw s4, 8(sp) # 4-byte Folded Reload
759 ; RV32I-NEXT: lw s5, 4(sp) # 4-byte Folded Reload
760 ; RV32I-NEXT: addi sp, sp, 32
763 ; RV64I-LABEL: fcvt_l_s_sat:
764 ; RV64I: # %bb.0: # %start
765 ; RV64I-NEXT: addi sp, sp, -48
766 ; RV64I-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
767 ; RV64I-NEXT: sd s0, 32(sp) # 8-byte Folded Spill
768 ; RV64I-NEXT: sd s1, 24(sp) # 8-byte Folded Spill
769 ; RV64I-NEXT: sd s2, 16(sp) # 8-byte Folded Spill
770 ; RV64I-NEXT: sd s3, 8(sp) # 8-byte Folded Spill
771 ; RV64I-NEXT: mv s0, a0
772 ; RV64I-NEXT: lui a1, 913408
773 ; RV64I-NEXT: call __gesf2@plt
774 ; RV64I-NEXT: mv s2, a0
775 ; RV64I-NEXT: mv a0, s0
776 ; RV64I-NEXT: call __fixsfdi@plt
777 ; RV64I-NEXT: mv s1, a0
778 ; RV64I-NEXT: li s3, -1
779 ; RV64I-NEXT: bgez s2, .LBB12_2
780 ; RV64I-NEXT: # %bb.1: # %start
781 ; RV64I-NEXT: slli s1, s3, 63
782 ; RV64I-NEXT: .LBB12_2: # %start
783 ; RV64I-NEXT: lui a1, 389120
784 ; RV64I-NEXT: addiw a1, a1, -1
785 ; RV64I-NEXT: mv a0, s0
786 ; RV64I-NEXT: call __gtsf2@plt
787 ; RV64I-NEXT: blez a0, .LBB12_4
788 ; RV64I-NEXT: # %bb.3: # %start
789 ; RV64I-NEXT: srli s1, s3, 1
790 ; RV64I-NEXT: .LBB12_4: # %start
791 ; RV64I-NEXT: mv a0, s0
792 ; RV64I-NEXT: mv a1, s0
793 ; RV64I-NEXT: call __unordsf2@plt
794 ; RV64I-NEXT: snez a0, a0
795 ; RV64I-NEXT: addi a0, a0, -1
796 ; RV64I-NEXT: and a0, a0, s1
797 ; RV64I-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
798 ; RV64I-NEXT: ld s0, 32(sp) # 8-byte Folded Reload
799 ; RV64I-NEXT: ld s1, 24(sp) # 8-byte Folded Reload
800 ; RV64I-NEXT: ld s2, 16(sp) # 8-byte Folded Reload
801 ; RV64I-NEXT: ld s3, 8(sp) # 8-byte Folded Reload
802 ; RV64I-NEXT: addi sp, sp, 48
805 %0 = tail call i64 @llvm.fptosi.sat.i64.f32(float %a)
808 declare i64 @llvm.fptosi.sat.i64.f32(float)
810 define i64 @fcvt_lu_s(float %a) nounwind {
811 ; RV32IF-LABEL: fcvt_lu_s:
813 ; RV32IF-NEXT: addi sp, sp, -16
814 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
815 ; RV32IF-NEXT: call __fixunssfdi@plt
816 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
817 ; RV32IF-NEXT: addi sp, sp, 16
820 ; RV64IF-LABEL: fcvt_lu_s:
822 ; RV64IF-NEXT: fcvt.lu.s a0, fa0, rtz
825 ; RV32IZFINX-LABEL: fcvt_lu_s:
826 ; RV32IZFINX: # %bb.0:
827 ; RV32IZFINX-NEXT: addi sp, sp, -16
828 ; RV32IZFINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
829 ; RV32IZFINX-NEXT: call __fixunssfdi@plt
830 ; RV32IZFINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
831 ; RV32IZFINX-NEXT: addi sp, sp, 16
832 ; RV32IZFINX-NEXT: ret
834 ; RV64IZFINX-LABEL: fcvt_lu_s:
835 ; RV64IZFINX: # %bb.0:
836 ; RV64IZFINX-NEXT: fcvt.lu.s a0, a0, rtz
837 ; RV64IZFINX-NEXT: ret
839 ; RV32I-LABEL: fcvt_lu_s:
841 ; RV32I-NEXT: addi sp, sp, -16
842 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
843 ; RV32I-NEXT: call __fixunssfdi@plt
844 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
845 ; RV32I-NEXT: addi sp, sp, 16
848 ; RV64I-LABEL: fcvt_lu_s:
850 ; RV64I-NEXT: addi sp, sp, -16
851 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
852 ; RV64I-NEXT: call __fixunssfdi@plt
853 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
854 ; RV64I-NEXT: addi sp, sp, 16
856 %1 = fptoui float %a to i64
860 define i64 @fcvt_lu_s_sat(float %a) nounwind {
861 ; RV32IF-LABEL: fcvt_lu_s_sat:
862 ; RV32IF: # %bb.0: # %start
863 ; RV32IF-NEXT: addi sp, sp, -16
864 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
865 ; RV32IF-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
866 ; RV32IF-NEXT: fsw fs0, 4(sp) # 4-byte Folded Spill
867 ; RV32IF-NEXT: fmv.s fs0, fa0
868 ; RV32IF-NEXT: fmv.w.x fa5, zero
869 ; RV32IF-NEXT: fle.s a0, fa5, fa0
870 ; RV32IF-NEXT: neg s0, a0
871 ; RV32IF-NEXT: call __fixunssfdi@plt
872 ; RV32IF-NEXT: lui a2, %hi(.LCPI14_0)
873 ; RV32IF-NEXT: flw fa5, %lo(.LCPI14_0)(a2)
874 ; RV32IF-NEXT: and a0, s0, a0
875 ; RV32IF-NEXT: flt.s a2, fa5, fs0
876 ; RV32IF-NEXT: neg a2, a2
877 ; RV32IF-NEXT: or a0, a2, a0
878 ; RV32IF-NEXT: and a1, s0, a1
879 ; RV32IF-NEXT: or a1, a2, a1
880 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
881 ; RV32IF-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
882 ; RV32IF-NEXT: flw fs0, 4(sp) # 4-byte Folded Reload
883 ; RV32IF-NEXT: addi sp, sp, 16
886 ; RV64IF-LABEL: fcvt_lu_s_sat:
887 ; RV64IF: # %bb.0: # %start
888 ; RV64IF-NEXT: fcvt.lu.s a0, fa0, rtz
889 ; RV64IF-NEXT: feq.s a1, fa0, fa0
890 ; RV64IF-NEXT: seqz a1, a1
891 ; RV64IF-NEXT: addi a1, a1, -1
892 ; RV64IF-NEXT: and a0, a1, a0
895 ; RV32IZFINX-LABEL: fcvt_lu_s_sat:
896 ; RV32IZFINX: # %bb.0: # %start
897 ; RV32IZFINX-NEXT: addi sp, sp, -16
898 ; RV32IZFINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
899 ; RV32IZFINX-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
900 ; RV32IZFINX-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
901 ; RV32IZFINX-NEXT: mv s0, a0
902 ; RV32IZFINX-NEXT: fle.s a0, zero, a0
903 ; RV32IZFINX-NEXT: neg s1, a0
904 ; RV32IZFINX-NEXT: mv a0, s0
905 ; RV32IZFINX-NEXT: call __fixunssfdi@plt
906 ; RV32IZFINX-NEXT: lui a2, %hi(.LCPI14_0)
907 ; RV32IZFINX-NEXT: lw a2, %lo(.LCPI14_0)(a2)
908 ; RV32IZFINX-NEXT: and a0, s1, a0
909 ; RV32IZFINX-NEXT: flt.s a2, a2, s0
910 ; RV32IZFINX-NEXT: neg a2, a2
911 ; RV32IZFINX-NEXT: or a0, a2, a0
912 ; RV32IZFINX-NEXT: and a1, s1, a1
913 ; RV32IZFINX-NEXT: or a1, a2, a1
914 ; RV32IZFINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
915 ; RV32IZFINX-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
916 ; RV32IZFINX-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
917 ; RV32IZFINX-NEXT: addi sp, sp, 16
918 ; RV32IZFINX-NEXT: ret
920 ; RV64IZFINX-LABEL: fcvt_lu_s_sat:
921 ; RV64IZFINX: # %bb.0: # %start
922 ; RV64IZFINX-NEXT: fcvt.lu.s a1, a0, rtz
923 ; RV64IZFINX-NEXT: feq.s a0, a0, a0
924 ; RV64IZFINX-NEXT: seqz a0, a0
925 ; RV64IZFINX-NEXT: addi a0, a0, -1
926 ; RV64IZFINX-NEXT: and a0, a0, a1
927 ; RV64IZFINX-NEXT: ret
929 ; RV32I-LABEL: fcvt_lu_s_sat:
930 ; RV32I: # %bb.0: # %start
931 ; RV32I-NEXT: addi sp, sp, -32
932 ; RV32I-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
933 ; RV32I-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
934 ; RV32I-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
935 ; RV32I-NEXT: sw s2, 16(sp) # 4-byte Folded Spill
936 ; RV32I-NEXT: sw s3, 12(sp) # 4-byte Folded Spill
937 ; RV32I-NEXT: mv s0, a0
938 ; RV32I-NEXT: li a1, 0
939 ; RV32I-NEXT: call __gesf2@plt
940 ; RV32I-NEXT: slti a0, a0, 0
941 ; RV32I-NEXT: addi s2, a0, -1
942 ; RV32I-NEXT: mv a0, s0
943 ; RV32I-NEXT: call __fixunssfdi@plt
944 ; RV32I-NEXT: mv s1, a1
945 ; RV32I-NEXT: and s3, s2, a0
946 ; RV32I-NEXT: lui a1, 391168
947 ; RV32I-NEXT: addi a1, a1, -1
948 ; RV32I-NEXT: mv a0, s0
949 ; RV32I-NEXT: call __gtsf2@plt
950 ; RV32I-NEXT: sgtz a0, a0
951 ; RV32I-NEXT: neg a1, a0
952 ; RV32I-NEXT: or a0, a1, s3
953 ; RV32I-NEXT: and a2, s2, s1
954 ; RV32I-NEXT: or a1, a1, a2
955 ; RV32I-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
956 ; RV32I-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
957 ; RV32I-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
958 ; RV32I-NEXT: lw s2, 16(sp) # 4-byte Folded Reload
959 ; RV32I-NEXT: lw s3, 12(sp) # 4-byte Folded Reload
960 ; RV32I-NEXT: addi sp, sp, 32
963 ; RV64I-LABEL: fcvt_lu_s_sat:
964 ; RV64I: # %bb.0: # %start
965 ; RV64I-NEXT: addi sp, sp, -32
966 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
967 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
968 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
969 ; RV64I-NEXT: mv s0, a0
970 ; RV64I-NEXT: li a1, 0
971 ; RV64I-NEXT: call __gesf2@plt
972 ; RV64I-NEXT: slti a0, a0, 0
973 ; RV64I-NEXT: addi s1, a0, -1
974 ; RV64I-NEXT: mv a0, s0
975 ; RV64I-NEXT: call __fixunssfdi@plt
976 ; RV64I-NEXT: and s1, s1, a0
977 ; RV64I-NEXT: lui a1, 391168
978 ; RV64I-NEXT: addiw a1, a1, -1
979 ; RV64I-NEXT: mv a0, s0
980 ; RV64I-NEXT: call __gtsf2@plt
981 ; RV64I-NEXT: sgtz a0, a0
982 ; RV64I-NEXT: neg a0, a0
983 ; RV64I-NEXT: or a0, a0, s1
984 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
985 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
986 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
987 ; RV64I-NEXT: addi sp, sp, 32
990 %0 = tail call i64 @llvm.fptoui.sat.i64.f32(float %a)
993 declare i64 @llvm.fptoui.sat.i64.f32(float)
995 define float @fcvt_s_l(i64 %a) nounwind {
996 ; RV32IF-LABEL: fcvt_s_l:
998 ; RV32IF-NEXT: addi sp, sp, -16
999 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1000 ; RV32IF-NEXT: call __floatdisf@plt
1001 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1002 ; RV32IF-NEXT: addi sp, sp, 16
1005 ; RV64IF-LABEL: fcvt_s_l:
1007 ; RV64IF-NEXT: fcvt.s.l fa0, a0
1010 ; RV32IZFINX-LABEL: fcvt_s_l:
1011 ; RV32IZFINX: # %bb.0:
1012 ; RV32IZFINX-NEXT: addi sp, sp, -16
1013 ; RV32IZFINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1014 ; RV32IZFINX-NEXT: call __floatdisf@plt
1015 ; RV32IZFINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1016 ; RV32IZFINX-NEXT: addi sp, sp, 16
1017 ; RV32IZFINX-NEXT: ret
1019 ; RV64IZFINX-LABEL: fcvt_s_l:
1020 ; RV64IZFINX: # %bb.0:
1021 ; RV64IZFINX-NEXT: fcvt.s.l a0, a0
1022 ; RV64IZFINX-NEXT: ret
1024 ; RV32I-LABEL: fcvt_s_l:
1026 ; RV32I-NEXT: addi sp, sp, -16
1027 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1028 ; RV32I-NEXT: call __floatdisf@plt
1029 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1030 ; RV32I-NEXT: addi sp, sp, 16
1033 ; RV64I-LABEL: fcvt_s_l:
1035 ; RV64I-NEXT: addi sp, sp, -16
1036 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1037 ; RV64I-NEXT: call __floatdisf@plt
1038 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1039 ; RV64I-NEXT: addi sp, sp, 16
1041 %1 = sitofp i64 %a to float
1045 define float @fcvt_s_lu(i64 %a) nounwind {
1046 ; RV32IF-LABEL: fcvt_s_lu:
1048 ; RV32IF-NEXT: addi sp, sp, -16
1049 ; RV32IF-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1050 ; RV32IF-NEXT: call __floatundisf@plt
1051 ; RV32IF-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1052 ; RV32IF-NEXT: addi sp, sp, 16
1055 ; RV64IF-LABEL: fcvt_s_lu:
1057 ; RV64IF-NEXT: fcvt.s.lu fa0, a0
1060 ; RV32IZFINX-LABEL: fcvt_s_lu:
1061 ; RV32IZFINX: # %bb.0:
1062 ; RV32IZFINX-NEXT: addi sp, sp, -16
1063 ; RV32IZFINX-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1064 ; RV32IZFINX-NEXT: call __floatundisf@plt
1065 ; RV32IZFINX-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1066 ; RV32IZFINX-NEXT: addi sp, sp, 16
1067 ; RV32IZFINX-NEXT: ret
1069 ; RV64IZFINX-LABEL: fcvt_s_lu:
1070 ; RV64IZFINX: # %bb.0:
1071 ; RV64IZFINX-NEXT: fcvt.s.lu a0, a0
1072 ; RV64IZFINX-NEXT: ret
1074 ; RV32I-LABEL: fcvt_s_lu:
1076 ; RV32I-NEXT: addi sp, sp, -16
1077 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1078 ; RV32I-NEXT: call __floatundisf@plt
1079 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1080 ; RV32I-NEXT: addi sp, sp, 16
1083 ; RV64I-LABEL: fcvt_s_lu:
1085 ; RV64I-NEXT: addi sp, sp, -16
1086 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1087 ; RV64I-NEXT: call __floatundisf@plt
1088 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1089 ; RV64I-NEXT: addi sp, sp, 16
1091 %1 = uitofp i64 %a to float
1095 define float @fcvt_s_w_i8(i8 signext %a) nounwind {
1096 ; CHECKIF-LABEL: fcvt_s_w_i8:
1098 ; CHECKIF-NEXT: fcvt.s.w fa0, a0
1101 ; CHECKIZFINX-LABEL: fcvt_s_w_i8:
1102 ; CHECKIZFINX: # %bb.0:
1103 ; CHECKIZFINX-NEXT: fcvt.s.w a0, a0
1104 ; CHECKIZFINX-NEXT: ret
1106 ; RV32I-LABEL: fcvt_s_w_i8:
1108 ; RV32I-NEXT: addi sp, sp, -16
1109 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1110 ; RV32I-NEXT: call __floatsisf@plt
1111 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1112 ; RV32I-NEXT: addi sp, sp, 16
1115 ; RV64I-LABEL: fcvt_s_w_i8:
1117 ; RV64I-NEXT: addi sp, sp, -16
1118 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1119 ; RV64I-NEXT: call __floatsisf@plt
1120 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1121 ; RV64I-NEXT: addi sp, sp, 16
1123 %1 = sitofp i8 %a to float
1127 define float @fcvt_s_wu_i8(i8 zeroext %a) nounwind {
1128 ; CHECKIF-LABEL: fcvt_s_wu_i8:
1130 ; CHECKIF-NEXT: fcvt.s.wu fa0, a0
1133 ; CHECKIZFINX-LABEL: fcvt_s_wu_i8:
1134 ; CHECKIZFINX: # %bb.0:
1135 ; CHECKIZFINX-NEXT: fcvt.s.wu a0, a0
1136 ; CHECKIZFINX-NEXT: ret
1138 ; RV32I-LABEL: fcvt_s_wu_i8:
1140 ; RV32I-NEXT: addi sp, sp, -16
1141 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1142 ; RV32I-NEXT: call __floatunsisf@plt
1143 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1144 ; RV32I-NEXT: addi sp, sp, 16
1147 ; RV64I-LABEL: fcvt_s_wu_i8:
1149 ; RV64I-NEXT: addi sp, sp, -16
1150 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1151 ; RV64I-NEXT: call __floatunsisf@plt
1152 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1153 ; RV64I-NEXT: addi sp, sp, 16
1155 %1 = uitofp i8 %a to float
1159 define float @fcvt_s_w_i16(i16 signext %a) nounwind {
1160 ; CHECKIF-LABEL: fcvt_s_w_i16:
1162 ; CHECKIF-NEXT: fcvt.s.w fa0, a0
1165 ; CHECKIZFINX-LABEL: fcvt_s_w_i16:
1166 ; CHECKIZFINX: # %bb.0:
1167 ; CHECKIZFINX-NEXT: fcvt.s.w a0, a0
1168 ; CHECKIZFINX-NEXT: ret
1170 ; RV32I-LABEL: fcvt_s_w_i16:
1172 ; RV32I-NEXT: addi sp, sp, -16
1173 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1174 ; RV32I-NEXT: call __floatsisf@plt
1175 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1176 ; RV32I-NEXT: addi sp, sp, 16
1179 ; RV64I-LABEL: fcvt_s_w_i16:
1181 ; RV64I-NEXT: addi sp, sp, -16
1182 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1183 ; RV64I-NEXT: call __floatsisf@plt
1184 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1185 ; RV64I-NEXT: addi sp, sp, 16
1187 %1 = sitofp i16 %a to float
1191 define float @fcvt_s_wu_i16(i16 zeroext %a) nounwind {
1192 ; CHECKIF-LABEL: fcvt_s_wu_i16:
1194 ; CHECKIF-NEXT: fcvt.s.wu fa0, a0
1197 ; CHECKIZFINX-LABEL: fcvt_s_wu_i16:
1198 ; CHECKIZFINX: # %bb.0:
1199 ; CHECKIZFINX-NEXT: fcvt.s.wu a0, a0
1200 ; CHECKIZFINX-NEXT: ret
1202 ; RV32I-LABEL: fcvt_s_wu_i16:
1204 ; RV32I-NEXT: addi sp, sp, -16
1205 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1206 ; RV32I-NEXT: call __floatunsisf@plt
1207 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1208 ; RV32I-NEXT: addi sp, sp, 16
1211 ; RV64I-LABEL: fcvt_s_wu_i16:
1213 ; RV64I-NEXT: addi sp, sp, -16
1214 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1215 ; RV64I-NEXT: call __floatunsisf@plt
1216 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1217 ; RV64I-NEXT: addi sp, sp, 16
1219 %1 = uitofp i16 %a to float
1223 ; Make sure we select W version of addi on RV64.
1224 define signext i32 @fcvt_s_w_demanded_bits(i32 signext %0, ptr %1) nounwind {
1225 ; RV32IF-LABEL: fcvt_s_w_demanded_bits:
1227 ; RV32IF-NEXT: addi a0, a0, 1
1228 ; RV32IF-NEXT: fcvt.s.w fa5, a0
1229 ; RV32IF-NEXT: fsw fa5, 0(a1)
1232 ; RV64IF-LABEL: fcvt_s_w_demanded_bits:
1234 ; RV64IF-NEXT: addiw a0, a0, 1
1235 ; RV64IF-NEXT: fcvt.s.w fa5, a0
1236 ; RV64IF-NEXT: fsw fa5, 0(a1)
1239 ; RV32IZFINX-LABEL: fcvt_s_w_demanded_bits:
1240 ; RV32IZFINX: # %bb.0:
1241 ; RV32IZFINX-NEXT: addi a0, a0, 1
1242 ; RV32IZFINX-NEXT: fcvt.s.w a2, a0
1243 ; RV32IZFINX-NEXT: sw a2, 0(a1)
1244 ; RV32IZFINX-NEXT: ret
1246 ; RV64IZFINX-LABEL: fcvt_s_w_demanded_bits:
1247 ; RV64IZFINX: # %bb.0:
1248 ; RV64IZFINX-NEXT: addiw a2, a0, 1
1249 ; RV64IZFINX-NEXT: addi a0, a0, 1
1250 ; RV64IZFINX-NEXT: fcvt.s.w a0, a0
1251 ; RV64IZFINX-NEXT: sw a0, 0(a1)
1252 ; RV64IZFINX-NEXT: mv a0, a2
1253 ; RV64IZFINX-NEXT: ret
1255 ; RV32I-LABEL: fcvt_s_w_demanded_bits:
1257 ; RV32I-NEXT: addi sp, sp, -16
1258 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1259 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
1260 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
1261 ; RV32I-NEXT: mv s0, a1
1262 ; RV32I-NEXT: addi s1, a0, 1
1263 ; RV32I-NEXT: mv a0, s1
1264 ; RV32I-NEXT: call __floatsisf@plt
1265 ; RV32I-NEXT: sw a0, 0(s0)
1266 ; RV32I-NEXT: mv a0, s1
1267 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1268 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
1269 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
1270 ; RV32I-NEXT: addi sp, sp, 16
1273 ; RV64I-LABEL: fcvt_s_w_demanded_bits:
1275 ; RV64I-NEXT: addi sp, sp, -32
1276 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
1277 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
1278 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
1279 ; RV64I-NEXT: mv s0, a1
1280 ; RV64I-NEXT: addiw s1, a0, 1
1281 ; RV64I-NEXT: mv a0, s1
1282 ; RV64I-NEXT: call __floatsisf@plt
1283 ; RV64I-NEXT: sw a0, 0(s0)
1284 ; RV64I-NEXT: mv a0, s1
1285 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
1286 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
1287 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
1288 ; RV64I-NEXT: addi sp, sp, 32
1291 %4 = sitofp i32 %3 to float
1292 store float %4, ptr %1, align 4
1296 ; Make sure we select W version of addi on RV64.
1297 define signext i32 @fcvt_s_wu_demanded_bits(i32 signext %0, ptr %1) nounwind {
1298 ; RV32IF-LABEL: fcvt_s_wu_demanded_bits:
1300 ; RV32IF-NEXT: addi a0, a0, 1
1301 ; RV32IF-NEXT: fcvt.s.wu fa5, a0
1302 ; RV32IF-NEXT: fsw fa5, 0(a1)
1305 ; RV64IF-LABEL: fcvt_s_wu_demanded_bits:
1307 ; RV64IF-NEXT: addiw a0, a0, 1
1308 ; RV64IF-NEXT: fcvt.s.wu fa5, a0
1309 ; RV64IF-NEXT: fsw fa5, 0(a1)
1312 ; RV32IZFINX-LABEL: fcvt_s_wu_demanded_bits:
1313 ; RV32IZFINX: # %bb.0:
1314 ; RV32IZFINX-NEXT: addi a0, a0, 1
1315 ; RV32IZFINX-NEXT: fcvt.s.wu a2, a0
1316 ; RV32IZFINX-NEXT: sw a2, 0(a1)
1317 ; RV32IZFINX-NEXT: ret
1319 ; RV64IZFINX-LABEL: fcvt_s_wu_demanded_bits:
1320 ; RV64IZFINX: # %bb.0:
1321 ; RV64IZFINX-NEXT: addiw a0, a0, 1
1322 ; RV64IZFINX-NEXT: fcvt.s.wu a2, a0
1323 ; RV64IZFINX-NEXT: sw a2, 0(a1)
1324 ; RV64IZFINX-NEXT: ret
1326 ; RV32I-LABEL: fcvt_s_wu_demanded_bits:
1328 ; RV32I-NEXT: addi sp, sp, -16
1329 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1330 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
1331 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
1332 ; RV32I-NEXT: mv s0, a1
1333 ; RV32I-NEXT: addi s1, a0, 1
1334 ; RV32I-NEXT: mv a0, s1
1335 ; RV32I-NEXT: call __floatunsisf@plt
1336 ; RV32I-NEXT: sw a0, 0(s0)
1337 ; RV32I-NEXT: mv a0, s1
1338 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1339 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
1340 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
1341 ; RV32I-NEXT: addi sp, sp, 16
1344 ; RV64I-LABEL: fcvt_s_wu_demanded_bits:
1346 ; RV64I-NEXT: addi sp, sp, -32
1347 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
1348 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
1349 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
1350 ; RV64I-NEXT: mv s0, a1
1351 ; RV64I-NEXT: addiw s1, a0, 1
1352 ; RV64I-NEXT: mv a0, s1
1353 ; RV64I-NEXT: call __floatunsisf@plt
1354 ; RV64I-NEXT: sw a0, 0(s0)
1355 ; RV64I-NEXT: mv a0, s1
1356 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
1357 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
1358 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
1359 ; RV64I-NEXT: addi sp, sp, 32
1362 %4 = uitofp i32 %3 to float
1363 store float %4, ptr %1, align 4
1367 define signext i16 @fcvt_w_s_i16(float %a) nounwind {
1368 ; RV32IF-LABEL: fcvt_w_s_i16:
1370 ; RV32IF-NEXT: fcvt.w.s a0, fa0, rtz
1373 ; RV64IF-LABEL: fcvt_w_s_i16:
1375 ; RV64IF-NEXT: fcvt.l.s a0, fa0, rtz
1378 ; RV32IZFINX-LABEL: fcvt_w_s_i16:
1379 ; RV32IZFINX: # %bb.0:
1380 ; RV32IZFINX-NEXT: fcvt.w.s a0, a0, rtz
1381 ; RV32IZFINX-NEXT: ret
1383 ; RV64IZFINX-LABEL: fcvt_w_s_i16:
1384 ; RV64IZFINX: # %bb.0:
1385 ; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rtz
1386 ; RV64IZFINX-NEXT: ret
1388 ; RV32I-LABEL: fcvt_w_s_i16:
1390 ; RV32I-NEXT: addi sp, sp, -16
1391 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1392 ; RV32I-NEXT: call __fixsfsi@plt
1393 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1394 ; RV32I-NEXT: addi sp, sp, 16
1397 ; RV64I-LABEL: fcvt_w_s_i16:
1399 ; RV64I-NEXT: addi sp, sp, -16
1400 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1401 ; RV64I-NEXT: call __fixsfdi@plt
1402 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1403 ; RV64I-NEXT: addi sp, sp, 16
1405 %1 = fptosi float %a to i16
1409 define signext i16 @fcvt_w_s_sat_i16(float %a) nounwind {
1410 ; RV32IF-LABEL: fcvt_w_s_sat_i16:
1411 ; RV32IF: # %bb.0: # %start
1412 ; RV32IF-NEXT: feq.s a0, fa0, fa0
1413 ; RV32IF-NEXT: neg a0, a0
1414 ; RV32IF-NEXT: lui a1, %hi(.LCPI24_0)
1415 ; RV32IF-NEXT: flw fa5, %lo(.LCPI24_0)(a1)
1416 ; RV32IF-NEXT: lui a1, 815104
1417 ; RV32IF-NEXT: fmv.w.x fa4, a1
1418 ; RV32IF-NEXT: fmax.s fa4, fa0, fa4
1419 ; RV32IF-NEXT: fmin.s fa5, fa4, fa5
1420 ; RV32IF-NEXT: fcvt.w.s a1, fa5, rtz
1421 ; RV32IF-NEXT: and a0, a0, a1
1424 ; RV64IF-LABEL: fcvt_w_s_sat_i16:
1425 ; RV64IF: # %bb.0: # %start
1426 ; RV64IF-NEXT: feq.s a0, fa0, fa0
1427 ; RV64IF-NEXT: lui a1, %hi(.LCPI24_0)
1428 ; RV64IF-NEXT: flw fa5, %lo(.LCPI24_0)(a1)
1429 ; RV64IF-NEXT: lui a1, 815104
1430 ; RV64IF-NEXT: fmv.w.x fa4, a1
1431 ; RV64IF-NEXT: fmax.s fa4, fa0, fa4
1432 ; RV64IF-NEXT: neg a0, a0
1433 ; RV64IF-NEXT: fmin.s fa5, fa4, fa5
1434 ; RV64IF-NEXT: fcvt.l.s a1, fa5, rtz
1435 ; RV64IF-NEXT: and a0, a0, a1
1438 ; RV32IZFINX-LABEL: fcvt_w_s_sat_i16:
1439 ; RV32IZFINX: # %bb.0: # %start
1440 ; RV32IZFINX-NEXT: feq.s a1, a0, a0
1441 ; RV32IZFINX-NEXT: lui a2, %hi(.LCPI24_0)
1442 ; RV32IZFINX-NEXT: lw a2, %lo(.LCPI24_0)(a2)
1443 ; RV32IZFINX-NEXT: neg a1, a1
1444 ; RV32IZFINX-NEXT: lui a3, 815104
1445 ; RV32IZFINX-NEXT: fmax.s a0, a0, a3
1446 ; RV32IZFINX-NEXT: fmin.s a0, a0, a2
1447 ; RV32IZFINX-NEXT: fcvt.w.s a0, a0, rtz
1448 ; RV32IZFINX-NEXT: and a0, a1, a0
1449 ; RV32IZFINX-NEXT: ret
1451 ; RV64IZFINX-LABEL: fcvt_w_s_sat_i16:
1452 ; RV64IZFINX: # %bb.0: # %start
1453 ; RV64IZFINX-NEXT: lui a1, 815104
1454 ; RV64IZFINX-NEXT: lui a2, %hi(.LCPI24_0)
1455 ; RV64IZFINX-NEXT: lw a2, %lo(.LCPI24_0)(a2)
1456 ; RV64IZFINX-NEXT: fmax.s a1, a0, a1
1457 ; RV64IZFINX-NEXT: feq.s a0, a0, a0
1458 ; RV64IZFINX-NEXT: neg a0, a0
1459 ; RV64IZFINX-NEXT: fmin.s a1, a1, a2
1460 ; RV64IZFINX-NEXT: fcvt.l.s a1, a1, rtz
1461 ; RV64IZFINX-NEXT: and a0, a0, a1
1462 ; RV64IZFINX-NEXT: ret
1464 ; RV32I-LABEL: fcvt_w_s_sat_i16:
1465 ; RV32I: # %bb.0: # %start
1466 ; RV32I-NEXT: addi sp, sp, -16
1467 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1468 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
1469 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
1470 ; RV32I-NEXT: sw s2, 0(sp) # 4-byte Folded Spill
1471 ; RV32I-NEXT: mv s0, a0
1472 ; RV32I-NEXT: lui a1, 815104
1473 ; RV32I-NEXT: call __gesf2@plt
1474 ; RV32I-NEXT: mv s2, a0
1475 ; RV32I-NEXT: mv a0, s0
1476 ; RV32I-NEXT: call __fixsfsi@plt
1477 ; RV32I-NEXT: mv s1, a0
1478 ; RV32I-NEXT: bgez s2, .LBB24_2
1479 ; RV32I-NEXT: # %bb.1: # %start
1480 ; RV32I-NEXT: lui s1, 1048568
1481 ; RV32I-NEXT: .LBB24_2: # %start
1482 ; RV32I-NEXT: lui a0, 290816
1483 ; RV32I-NEXT: addi a1, a0, -512
1484 ; RV32I-NEXT: mv a0, s0
1485 ; RV32I-NEXT: call __gtsf2@plt
1486 ; RV32I-NEXT: blez a0, .LBB24_4
1487 ; RV32I-NEXT: # %bb.3: # %start
1488 ; RV32I-NEXT: lui s1, 8
1489 ; RV32I-NEXT: addi s1, s1, -1
1490 ; RV32I-NEXT: .LBB24_4: # %start
1491 ; RV32I-NEXT: mv a0, s0
1492 ; RV32I-NEXT: mv a1, s0
1493 ; RV32I-NEXT: call __unordsf2@plt
1494 ; RV32I-NEXT: snez a0, a0
1495 ; RV32I-NEXT: addi a0, a0, -1
1496 ; RV32I-NEXT: and a0, a0, s1
1497 ; RV32I-NEXT: slli a0, a0, 16
1498 ; RV32I-NEXT: srai a0, a0, 16
1499 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1500 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
1501 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
1502 ; RV32I-NEXT: lw s2, 0(sp) # 4-byte Folded Reload
1503 ; RV32I-NEXT: addi sp, sp, 16
1506 ; RV64I-LABEL: fcvt_w_s_sat_i16:
1507 ; RV64I: # %bb.0: # %start
1508 ; RV64I-NEXT: addi sp, sp, -32
1509 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
1510 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
1511 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
1512 ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
1513 ; RV64I-NEXT: mv s0, a0
1514 ; RV64I-NEXT: lui a1, 815104
1515 ; RV64I-NEXT: call __gesf2@plt
1516 ; RV64I-NEXT: mv s2, a0
1517 ; RV64I-NEXT: mv a0, s0
1518 ; RV64I-NEXT: call __fixsfdi@plt
1519 ; RV64I-NEXT: mv s1, a0
1520 ; RV64I-NEXT: bgez s2, .LBB24_2
1521 ; RV64I-NEXT: # %bb.1: # %start
1522 ; RV64I-NEXT: lui s1, 1048568
1523 ; RV64I-NEXT: .LBB24_2: # %start
1524 ; RV64I-NEXT: lui a0, 290816
1525 ; RV64I-NEXT: addiw a1, a0, -512
1526 ; RV64I-NEXT: mv a0, s0
1527 ; RV64I-NEXT: call __gtsf2@plt
1528 ; RV64I-NEXT: blez a0, .LBB24_4
1529 ; RV64I-NEXT: # %bb.3: # %start
1530 ; RV64I-NEXT: lui s1, 8
1531 ; RV64I-NEXT: addi s1, s1, -1
1532 ; RV64I-NEXT: .LBB24_4: # %start
1533 ; RV64I-NEXT: mv a0, s0
1534 ; RV64I-NEXT: mv a1, s0
1535 ; RV64I-NEXT: call __unordsf2@plt
1536 ; RV64I-NEXT: snez a0, a0
1537 ; RV64I-NEXT: addi a0, a0, -1
1538 ; RV64I-NEXT: and a0, a0, s1
1539 ; RV64I-NEXT: slli a0, a0, 48
1540 ; RV64I-NEXT: srai a0, a0, 48
1541 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
1542 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
1543 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
1544 ; RV64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
1545 ; RV64I-NEXT: addi sp, sp, 32
1548 %0 = tail call i16 @llvm.fptosi.sat.i16.f32(float %a)
1551 declare i16 @llvm.fptosi.sat.i16.f32(float)
1553 define zeroext i16 @fcvt_wu_s_i16(float %a) nounwind {
1554 ; RV32IF-LABEL: fcvt_wu_s_i16:
1556 ; RV32IF-NEXT: fcvt.wu.s a0, fa0, rtz
1559 ; RV64IF-LABEL: fcvt_wu_s_i16:
1561 ; RV64IF-NEXT: fcvt.lu.s a0, fa0, rtz
1564 ; RV32IZFINX-LABEL: fcvt_wu_s_i16:
1565 ; RV32IZFINX: # %bb.0:
1566 ; RV32IZFINX-NEXT: fcvt.wu.s a0, a0, rtz
1567 ; RV32IZFINX-NEXT: ret
1569 ; RV64IZFINX-LABEL: fcvt_wu_s_i16:
1570 ; RV64IZFINX: # %bb.0:
1571 ; RV64IZFINX-NEXT: fcvt.lu.s a0, a0, rtz
1572 ; RV64IZFINX-NEXT: ret
1574 ; RV32I-LABEL: fcvt_wu_s_i16:
1576 ; RV32I-NEXT: addi sp, sp, -16
1577 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1578 ; RV32I-NEXT: call __fixunssfsi@plt
1579 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1580 ; RV32I-NEXT: addi sp, sp, 16
1583 ; RV64I-LABEL: fcvt_wu_s_i16:
1585 ; RV64I-NEXT: addi sp, sp, -16
1586 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1587 ; RV64I-NEXT: call __fixunssfdi@plt
1588 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1589 ; RV64I-NEXT: addi sp, sp, 16
1591 %1 = fptoui float %a to i16
1595 define zeroext i16 @fcvt_wu_s_sat_i16(float %a) nounwind {
1596 ; RV32IF-LABEL: fcvt_wu_s_sat_i16:
1597 ; RV32IF: # %bb.0: # %start
1598 ; RV32IF-NEXT: lui a0, %hi(.LCPI26_0)
1599 ; RV32IF-NEXT: flw fa5, %lo(.LCPI26_0)(a0)
1600 ; RV32IF-NEXT: fmv.w.x fa4, zero
1601 ; RV32IF-NEXT: fmax.s fa4, fa0, fa4
1602 ; RV32IF-NEXT: fmin.s fa5, fa4, fa5
1603 ; RV32IF-NEXT: fcvt.wu.s a0, fa5, rtz
1606 ; RV64IF-LABEL: fcvt_wu_s_sat_i16:
1607 ; RV64IF: # %bb.0: # %start
1608 ; RV64IF-NEXT: lui a0, %hi(.LCPI26_0)
1609 ; RV64IF-NEXT: flw fa5, %lo(.LCPI26_0)(a0)
1610 ; RV64IF-NEXT: fmv.w.x fa4, zero
1611 ; RV64IF-NEXT: fmax.s fa4, fa0, fa4
1612 ; RV64IF-NEXT: fmin.s fa5, fa4, fa5
1613 ; RV64IF-NEXT: fcvt.lu.s a0, fa5, rtz
1616 ; RV32IZFINX-LABEL: fcvt_wu_s_sat_i16:
1617 ; RV32IZFINX: # %bb.0: # %start
1618 ; RV32IZFINX-NEXT: lui a1, %hi(.LCPI26_0)
1619 ; RV32IZFINX-NEXT: lw a1, %lo(.LCPI26_0)(a1)
1620 ; RV32IZFINX-NEXT: fmax.s a0, a0, zero
1621 ; RV32IZFINX-NEXT: fmin.s a0, a0, a1
1622 ; RV32IZFINX-NEXT: fcvt.wu.s a0, a0, rtz
1623 ; RV32IZFINX-NEXT: ret
1625 ; RV64IZFINX-LABEL: fcvt_wu_s_sat_i16:
1626 ; RV64IZFINX: # %bb.0: # %start
1627 ; RV64IZFINX-NEXT: lui a1, %hi(.LCPI26_0)
1628 ; RV64IZFINX-NEXT: lw a1, %lo(.LCPI26_0)(a1)
1629 ; RV64IZFINX-NEXT: fmax.s a0, a0, zero
1630 ; RV64IZFINX-NEXT: fmin.s a0, a0, a1
1631 ; RV64IZFINX-NEXT: fcvt.lu.s a0, a0, rtz
1632 ; RV64IZFINX-NEXT: ret
1634 ; RV32I-LABEL: fcvt_wu_s_sat_i16:
1635 ; RV32I: # %bb.0: # %start
1636 ; RV32I-NEXT: addi sp, sp, -16
1637 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1638 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
1639 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
1640 ; RV32I-NEXT: sw s2, 0(sp) # 4-byte Folded Spill
1641 ; RV32I-NEXT: mv s2, a0
1642 ; RV32I-NEXT: li a1, 0
1643 ; RV32I-NEXT: call __gesf2@plt
1644 ; RV32I-NEXT: mv s0, a0
1645 ; RV32I-NEXT: mv a0, s2
1646 ; RV32I-NEXT: call __fixunssfsi@plt
1647 ; RV32I-NEXT: mv s1, a0
1648 ; RV32I-NEXT: lui a0, 292864
1649 ; RV32I-NEXT: addi a1, a0, -256
1650 ; RV32I-NEXT: mv a0, s2
1651 ; RV32I-NEXT: call __gtsf2@plt
1652 ; RV32I-NEXT: lui a1, 16
1653 ; RV32I-NEXT: addi a1, a1, -1
1654 ; RV32I-NEXT: blez a0, .LBB26_2
1655 ; RV32I-NEXT: # %bb.1: # %start
1656 ; RV32I-NEXT: mv a0, a1
1657 ; RV32I-NEXT: j .LBB26_3
1658 ; RV32I-NEXT: .LBB26_2:
1659 ; RV32I-NEXT: slti a0, s0, 0
1660 ; RV32I-NEXT: addi a0, a0, -1
1661 ; RV32I-NEXT: and a0, a0, s1
1662 ; RV32I-NEXT: .LBB26_3: # %start
1663 ; RV32I-NEXT: and a0, a0, a1
1664 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1665 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
1666 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
1667 ; RV32I-NEXT: lw s2, 0(sp) # 4-byte Folded Reload
1668 ; RV32I-NEXT: addi sp, sp, 16
1671 ; RV64I-LABEL: fcvt_wu_s_sat_i16:
1672 ; RV64I: # %bb.0: # %start
1673 ; RV64I-NEXT: addi sp, sp, -32
1674 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
1675 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
1676 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
1677 ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
1678 ; RV64I-NEXT: mv s2, a0
1679 ; RV64I-NEXT: li a1, 0
1680 ; RV64I-NEXT: call __gesf2@plt
1681 ; RV64I-NEXT: mv s0, a0
1682 ; RV64I-NEXT: mv a0, s2
1683 ; RV64I-NEXT: call __fixunssfdi@plt
1684 ; RV64I-NEXT: mv s1, a0
1685 ; RV64I-NEXT: lui a0, 292864
1686 ; RV64I-NEXT: addiw a1, a0, -256
1687 ; RV64I-NEXT: mv a0, s2
1688 ; RV64I-NEXT: call __gtsf2@plt
1689 ; RV64I-NEXT: lui a1, 16
1690 ; RV64I-NEXT: addiw a1, a1, -1
1691 ; RV64I-NEXT: blez a0, .LBB26_2
1692 ; RV64I-NEXT: # %bb.1: # %start
1693 ; RV64I-NEXT: mv a0, a1
1694 ; RV64I-NEXT: j .LBB26_3
1695 ; RV64I-NEXT: .LBB26_2:
1696 ; RV64I-NEXT: slti a0, s0, 0
1697 ; RV64I-NEXT: addi a0, a0, -1
1698 ; RV64I-NEXT: and a0, a0, s1
1699 ; RV64I-NEXT: .LBB26_3: # %start
1700 ; RV64I-NEXT: and a0, a0, a1
1701 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
1702 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
1703 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
1704 ; RV64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
1705 ; RV64I-NEXT: addi sp, sp, 32
1708 %0 = tail call i16 @llvm.fptoui.sat.i16.f32(float %a)
1711 declare i16 @llvm.fptoui.sat.i16.f32(float)
1713 define signext i8 @fcvt_w_s_i8(float %a) nounwind {
1714 ; RV32IF-LABEL: fcvt_w_s_i8:
1716 ; RV32IF-NEXT: fcvt.w.s a0, fa0, rtz
1719 ; RV64IF-LABEL: fcvt_w_s_i8:
1721 ; RV64IF-NEXT: fcvt.l.s a0, fa0, rtz
1724 ; RV32IZFINX-LABEL: fcvt_w_s_i8:
1725 ; RV32IZFINX: # %bb.0:
1726 ; RV32IZFINX-NEXT: fcvt.w.s a0, a0, rtz
1727 ; RV32IZFINX-NEXT: ret
1729 ; RV64IZFINX-LABEL: fcvt_w_s_i8:
1730 ; RV64IZFINX: # %bb.0:
1731 ; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rtz
1732 ; RV64IZFINX-NEXT: ret
1734 ; RV32I-LABEL: fcvt_w_s_i8:
1736 ; RV32I-NEXT: addi sp, sp, -16
1737 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1738 ; RV32I-NEXT: call __fixsfsi@plt
1739 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1740 ; RV32I-NEXT: addi sp, sp, 16
1743 ; RV64I-LABEL: fcvt_w_s_i8:
1745 ; RV64I-NEXT: addi sp, sp, -16
1746 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1747 ; RV64I-NEXT: call __fixsfdi@plt
1748 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1749 ; RV64I-NEXT: addi sp, sp, 16
1751 %1 = fptosi float %a to i8
1755 define signext i8 @fcvt_w_s_sat_i8(float %a) nounwind {
1756 ; RV32IF-LABEL: fcvt_w_s_sat_i8:
1757 ; RV32IF: # %bb.0: # %start
1758 ; RV32IF-NEXT: feq.s a0, fa0, fa0
1759 ; RV32IF-NEXT: neg a0, a0
1760 ; RV32IF-NEXT: lui a1, 798720
1761 ; RV32IF-NEXT: fmv.w.x fa5, a1
1762 ; RV32IF-NEXT: fmax.s fa5, fa0, fa5
1763 ; RV32IF-NEXT: lui a1, 274400
1764 ; RV32IF-NEXT: fmv.w.x fa4, a1
1765 ; RV32IF-NEXT: fmin.s fa5, fa5, fa4
1766 ; RV32IF-NEXT: fcvt.w.s a1, fa5, rtz
1767 ; RV32IF-NEXT: and a0, a0, a1
1770 ; RV64IF-LABEL: fcvt_w_s_sat_i8:
1771 ; RV64IF: # %bb.0: # %start
1772 ; RV64IF-NEXT: feq.s a0, fa0, fa0
1773 ; RV64IF-NEXT: neg a0, a0
1774 ; RV64IF-NEXT: lui a1, 798720
1775 ; RV64IF-NEXT: fmv.w.x fa5, a1
1776 ; RV64IF-NEXT: fmax.s fa5, fa0, fa5
1777 ; RV64IF-NEXT: lui a1, 274400
1778 ; RV64IF-NEXT: fmv.w.x fa4, a1
1779 ; RV64IF-NEXT: fmin.s fa5, fa5, fa4
1780 ; RV64IF-NEXT: fcvt.l.s a1, fa5, rtz
1781 ; RV64IF-NEXT: and a0, a0, a1
1784 ; RV32IZFINX-LABEL: fcvt_w_s_sat_i8:
1785 ; RV32IZFINX: # %bb.0: # %start
1786 ; RV32IZFINX-NEXT: feq.s a1, a0, a0
1787 ; RV32IZFINX-NEXT: neg a1, a1
1788 ; RV32IZFINX-NEXT: lui a2, 798720
1789 ; RV32IZFINX-NEXT: fmax.s a0, a0, a2
1790 ; RV32IZFINX-NEXT: lui a2, 274400
1791 ; RV32IZFINX-NEXT: fmin.s a0, a0, a2
1792 ; RV32IZFINX-NEXT: fcvt.w.s a0, a0, rtz
1793 ; RV32IZFINX-NEXT: and a0, a1, a0
1794 ; RV32IZFINX-NEXT: ret
1796 ; RV64IZFINX-LABEL: fcvt_w_s_sat_i8:
1797 ; RV64IZFINX: # %bb.0: # %start
1798 ; RV64IZFINX-NEXT: feq.s a1, a0, a0
1799 ; RV64IZFINX-NEXT: neg a1, a1
1800 ; RV64IZFINX-NEXT: lui a2, 798720
1801 ; RV64IZFINX-NEXT: fmax.s a0, a0, a2
1802 ; RV64IZFINX-NEXT: lui a2, 274400
1803 ; RV64IZFINX-NEXT: fmin.s a0, a0, a2
1804 ; RV64IZFINX-NEXT: fcvt.l.s a0, a0, rtz
1805 ; RV64IZFINX-NEXT: and a0, a1, a0
1806 ; RV64IZFINX-NEXT: ret
1808 ; RV32I-LABEL: fcvt_w_s_sat_i8:
1809 ; RV32I: # %bb.0: # %start
1810 ; RV32I-NEXT: addi sp, sp, -16
1811 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1812 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
1813 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
1814 ; RV32I-NEXT: sw s2, 0(sp) # 4-byte Folded Spill
1815 ; RV32I-NEXT: mv s0, a0
1816 ; RV32I-NEXT: lui a1, 798720
1817 ; RV32I-NEXT: call __gesf2@plt
1818 ; RV32I-NEXT: mv s2, a0
1819 ; RV32I-NEXT: mv a0, s0
1820 ; RV32I-NEXT: call __fixsfsi@plt
1821 ; RV32I-NEXT: mv s1, a0
1822 ; RV32I-NEXT: bgez s2, .LBB28_2
1823 ; RV32I-NEXT: # %bb.1: # %start
1824 ; RV32I-NEXT: li s1, -128
1825 ; RV32I-NEXT: .LBB28_2: # %start
1826 ; RV32I-NEXT: lui a1, 274400
1827 ; RV32I-NEXT: mv a0, s0
1828 ; RV32I-NEXT: call __gtsf2@plt
1829 ; RV32I-NEXT: blez a0, .LBB28_4
1830 ; RV32I-NEXT: # %bb.3: # %start
1831 ; RV32I-NEXT: li s1, 127
1832 ; RV32I-NEXT: .LBB28_4: # %start
1833 ; RV32I-NEXT: mv a0, s0
1834 ; RV32I-NEXT: mv a1, s0
1835 ; RV32I-NEXT: call __unordsf2@plt
1836 ; RV32I-NEXT: snez a0, a0
1837 ; RV32I-NEXT: addi a0, a0, -1
1838 ; RV32I-NEXT: and a0, a0, s1
1839 ; RV32I-NEXT: slli a0, a0, 24
1840 ; RV32I-NEXT: srai a0, a0, 24
1841 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1842 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
1843 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
1844 ; RV32I-NEXT: lw s2, 0(sp) # 4-byte Folded Reload
1845 ; RV32I-NEXT: addi sp, sp, 16
1848 ; RV64I-LABEL: fcvt_w_s_sat_i8:
1849 ; RV64I: # %bb.0: # %start
1850 ; RV64I-NEXT: addi sp, sp, -32
1851 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
1852 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
1853 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
1854 ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
1855 ; RV64I-NEXT: mv s0, a0
1856 ; RV64I-NEXT: lui a1, 798720
1857 ; RV64I-NEXT: call __gesf2@plt
1858 ; RV64I-NEXT: mv s2, a0
1859 ; RV64I-NEXT: mv a0, s0
1860 ; RV64I-NEXT: call __fixsfdi@plt
1861 ; RV64I-NEXT: mv s1, a0
1862 ; RV64I-NEXT: bgez s2, .LBB28_2
1863 ; RV64I-NEXT: # %bb.1: # %start
1864 ; RV64I-NEXT: li s1, -128
1865 ; RV64I-NEXT: .LBB28_2: # %start
1866 ; RV64I-NEXT: lui a1, 274400
1867 ; RV64I-NEXT: mv a0, s0
1868 ; RV64I-NEXT: call __gtsf2@plt
1869 ; RV64I-NEXT: blez a0, .LBB28_4
1870 ; RV64I-NEXT: # %bb.3: # %start
1871 ; RV64I-NEXT: li s1, 127
1872 ; RV64I-NEXT: .LBB28_4: # %start
1873 ; RV64I-NEXT: mv a0, s0
1874 ; RV64I-NEXT: mv a1, s0
1875 ; RV64I-NEXT: call __unordsf2@plt
1876 ; RV64I-NEXT: snez a0, a0
1877 ; RV64I-NEXT: addi a0, a0, -1
1878 ; RV64I-NEXT: and a0, a0, s1
1879 ; RV64I-NEXT: slli a0, a0, 56
1880 ; RV64I-NEXT: srai a0, a0, 56
1881 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
1882 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
1883 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
1884 ; RV64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
1885 ; RV64I-NEXT: addi sp, sp, 32
1888 %0 = tail call i8 @llvm.fptosi.sat.i8.f32(float %a)
1891 declare i8 @llvm.fptosi.sat.i8.f32(float)
1893 define zeroext i8 @fcvt_wu_s_i8(float %a) nounwind {
1894 ; RV32IF-LABEL: fcvt_wu_s_i8:
1896 ; RV32IF-NEXT: fcvt.wu.s a0, fa0, rtz
1899 ; RV64IF-LABEL: fcvt_wu_s_i8:
1901 ; RV64IF-NEXT: fcvt.lu.s a0, fa0, rtz
1904 ; RV32IZFINX-LABEL: fcvt_wu_s_i8:
1905 ; RV32IZFINX: # %bb.0:
1906 ; RV32IZFINX-NEXT: fcvt.wu.s a0, a0, rtz
1907 ; RV32IZFINX-NEXT: ret
1909 ; RV64IZFINX-LABEL: fcvt_wu_s_i8:
1910 ; RV64IZFINX: # %bb.0:
1911 ; RV64IZFINX-NEXT: fcvt.lu.s a0, a0, rtz
1912 ; RV64IZFINX-NEXT: ret
1914 ; RV32I-LABEL: fcvt_wu_s_i8:
1916 ; RV32I-NEXT: addi sp, sp, -16
1917 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1918 ; RV32I-NEXT: call __fixunssfsi@plt
1919 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
1920 ; RV32I-NEXT: addi sp, sp, 16
1923 ; RV64I-LABEL: fcvt_wu_s_i8:
1925 ; RV64I-NEXT: addi sp, sp, -16
1926 ; RV64I-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
1927 ; RV64I-NEXT: call __fixunssfdi@plt
1928 ; RV64I-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
1929 ; RV64I-NEXT: addi sp, sp, 16
1931 %1 = fptoui float %a to i8
1935 define zeroext i8 @fcvt_wu_s_sat_i8(float %a) nounwind {
1936 ; RV32IF-LABEL: fcvt_wu_s_sat_i8:
1937 ; RV32IF: # %bb.0: # %start
1938 ; RV32IF-NEXT: fmv.w.x fa5, zero
1939 ; RV32IF-NEXT: fmax.s fa5, fa0, fa5
1940 ; RV32IF-NEXT: lui a0, 276464
1941 ; RV32IF-NEXT: fmv.w.x fa4, a0
1942 ; RV32IF-NEXT: fmin.s fa5, fa5, fa4
1943 ; RV32IF-NEXT: fcvt.wu.s a0, fa5, rtz
1946 ; RV64IF-LABEL: fcvt_wu_s_sat_i8:
1947 ; RV64IF: # %bb.0: # %start
1948 ; RV64IF-NEXT: fmv.w.x fa5, zero
1949 ; RV64IF-NEXT: fmax.s fa5, fa0, fa5
1950 ; RV64IF-NEXT: lui a0, 276464
1951 ; RV64IF-NEXT: fmv.w.x fa4, a0
1952 ; RV64IF-NEXT: fmin.s fa5, fa5, fa4
1953 ; RV64IF-NEXT: fcvt.lu.s a0, fa5, rtz
1956 ; RV32IZFINX-LABEL: fcvt_wu_s_sat_i8:
1957 ; RV32IZFINX: # %bb.0: # %start
1958 ; RV32IZFINX-NEXT: fmax.s a0, a0, zero
1959 ; RV32IZFINX-NEXT: lui a1, 276464
1960 ; RV32IZFINX-NEXT: fmin.s a0, a0, a1
1961 ; RV32IZFINX-NEXT: fcvt.wu.s a0, a0, rtz
1962 ; RV32IZFINX-NEXT: ret
1964 ; RV64IZFINX-LABEL: fcvt_wu_s_sat_i8:
1965 ; RV64IZFINX: # %bb.0: # %start
1966 ; RV64IZFINX-NEXT: fmax.s a0, a0, zero
1967 ; RV64IZFINX-NEXT: lui a1, 276464
1968 ; RV64IZFINX-NEXT: fmin.s a0, a0, a1
1969 ; RV64IZFINX-NEXT: fcvt.lu.s a0, a0, rtz
1970 ; RV64IZFINX-NEXT: ret
1972 ; RV32I-LABEL: fcvt_wu_s_sat_i8:
1973 ; RV32I: # %bb.0: # %start
1974 ; RV32I-NEXT: addi sp, sp, -16
1975 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
1976 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
1977 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
1978 ; RV32I-NEXT: sw s2, 0(sp) # 4-byte Folded Spill
1979 ; RV32I-NEXT: mv s2, a0
1980 ; RV32I-NEXT: li a1, 0
1981 ; RV32I-NEXT: call __gesf2@plt
1982 ; RV32I-NEXT: mv s0, a0
1983 ; RV32I-NEXT: mv a0, s2
1984 ; RV32I-NEXT: call __fixunssfsi@plt
1985 ; RV32I-NEXT: mv s1, a0
1986 ; RV32I-NEXT: lui a1, 276464
1987 ; RV32I-NEXT: mv a0, s2
1988 ; RV32I-NEXT: call __gtsf2@plt
1989 ; RV32I-NEXT: blez a0, .LBB30_2
1990 ; RV32I-NEXT: # %bb.1: # %start
1991 ; RV32I-NEXT: li a0, 255
1992 ; RV32I-NEXT: j .LBB30_3
1993 ; RV32I-NEXT: .LBB30_2:
1994 ; RV32I-NEXT: slti a0, s0, 0
1995 ; RV32I-NEXT: addi a0, a0, -1
1996 ; RV32I-NEXT: and a0, a0, s1
1997 ; RV32I-NEXT: .LBB30_3: # %start
1998 ; RV32I-NEXT: andi a0, a0, 255
1999 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
2000 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
2001 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
2002 ; RV32I-NEXT: lw s2, 0(sp) # 4-byte Folded Reload
2003 ; RV32I-NEXT: addi sp, sp, 16
2006 ; RV64I-LABEL: fcvt_wu_s_sat_i8:
2007 ; RV64I: # %bb.0: # %start
2008 ; RV64I-NEXT: addi sp, sp, -32
2009 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
2010 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
2011 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
2012 ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
2013 ; RV64I-NEXT: mv s2, a0
2014 ; RV64I-NEXT: li a1, 0
2015 ; RV64I-NEXT: call __gesf2@plt
2016 ; RV64I-NEXT: mv s0, a0
2017 ; RV64I-NEXT: mv a0, s2
2018 ; RV64I-NEXT: call __fixunssfdi@plt
2019 ; RV64I-NEXT: mv s1, a0
2020 ; RV64I-NEXT: lui a1, 276464
2021 ; RV64I-NEXT: mv a0, s2
2022 ; RV64I-NEXT: call __gtsf2@plt
2023 ; RV64I-NEXT: blez a0, .LBB30_2
2024 ; RV64I-NEXT: # %bb.1: # %start
2025 ; RV64I-NEXT: li a0, 255
2026 ; RV64I-NEXT: j .LBB30_3
2027 ; RV64I-NEXT: .LBB30_2:
2028 ; RV64I-NEXT: slti a0, s0, 0
2029 ; RV64I-NEXT: addi a0, a0, -1
2030 ; RV64I-NEXT: and a0, a0, s1
2031 ; RV64I-NEXT: .LBB30_3: # %start
2032 ; RV64I-NEXT: andi a0, a0, 255
2033 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
2034 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
2035 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
2036 ; RV64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
2037 ; RV64I-NEXT: addi sp, sp, 32
2040 %0 = tail call i8 @llvm.fptoui.sat.i8.f32(float %a)
2043 declare i8 @llvm.fptoui.sat.i8.f32(float)
2045 define zeroext i32 @fcvt_wu_s_sat_zext(float %a) nounwind {
2046 ; RV32IF-LABEL: fcvt_wu_s_sat_zext:
2047 ; RV32IF: # %bb.0: # %start
2048 ; RV32IF-NEXT: fcvt.wu.s a0, fa0, rtz
2049 ; RV32IF-NEXT: feq.s a1, fa0, fa0
2050 ; RV32IF-NEXT: seqz a1, a1
2051 ; RV32IF-NEXT: addi a1, a1, -1
2052 ; RV32IF-NEXT: and a0, a1, a0
2055 ; RV64IF-LABEL: fcvt_wu_s_sat_zext:
2056 ; RV64IF: # %bb.0: # %start
2057 ; RV64IF-NEXT: fcvt.wu.s a0, fa0, rtz
2058 ; RV64IF-NEXT: feq.s a1, fa0, fa0
2059 ; RV64IF-NEXT: seqz a1, a1
2060 ; RV64IF-NEXT: addi a1, a1, -1
2061 ; RV64IF-NEXT: and a0, a0, a1
2062 ; RV64IF-NEXT: slli a0, a0, 32
2063 ; RV64IF-NEXT: srli a0, a0, 32
2066 ; RV32IZFINX-LABEL: fcvt_wu_s_sat_zext:
2067 ; RV32IZFINX: # %bb.0: # %start
2068 ; RV32IZFINX-NEXT: fcvt.wu.s a1, a0, rtz
2069 ; RV32IZFINX-NEXT: feq.s a0, a0, a0
2070 ; RV32IZFINX-NEXT: seqz a0, a0
2071 ; RV32IZFINX-NEXT: addi a0, a0, -1
2072 ; RV32IZFINX-NEXT: and a0, a0, a1
2073 ; RV32IZFINX-NEXT: ret
2075 ; RV64IZFINX-LABEL: fcvt_wu_s_sat_zext:
2076 ; RV64IZFINX: # %bb.0: # %start
2077 ; RV64IZFINX-NEXT: fcvt.wu.s a1, a0, rtz
2078 ; RV64IZFINX-NEXT: feq.s a0, a0, a0
2079 ; RV64IZFINX-NEXT: seqz a0, a0
2080 ; RV64IZFINX-NEXT: addi a0, a0, -1
2081 ; RV64IZFINX-NEXT: and a0, a1, a0
2082 ; RV64IZFINX-NEXT: slli a0, a0, 32
2083 ; RV64IZFINX-NEXT: srli a0, a0, 32
2084 ; RV64IZFINX-NEXT: ret
2086 ; RV32I-LABEL: fcvt_wu_s_sat_zext:
2087 ; RV32I: # %bb.0: # %start
2088 ; RV32I-NEXT: addi sp, sp, -16
2089 ; RV32I-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
2090 ; RV32I-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
2091 ; RV32I-NEXT: sw s1, 4(sp) # 4-byte Folded Spill
2092 ; RV32I-NEXT: mv s0, a0
2093 ; RV32I-NEXT: li a1, 0
2094 ; RV32I-NEXT: call __gesf2@plt
2095 ; RV32I-NEXT: slti a0, a0, 0
2096 ; RV32I-NEXT: addi s1, a0, -1
2097 ; RV32I-NEXT: mv a0, s0
2098 ; RV32I-NEXT: call __fixunssfsi@plt
2099 ; RV32I-NEXT: and s1, s1, a0
2100 ; RV32I-NEXT: lui a1, 325632
2101 ; RV32I-NEXT: addi a1, a1, -1
2102 ; RV32I-NEXT: mv a0, s0
2103 ; RV32I-NEXT: call __gtsf2@plt
2104 ; RV32I-NEXT: sgtz a0, a0
2105 ; RV32I-NEXT: neg a0, a0
2106 ; RV32I-NEXT: or a0, a0, s1
2107 ; RV32I-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
2108 ; RV32I-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
2109 ; RV32I-NEXT: lw s1, 4(sp) # 4-byte Folded Reload
2110 ; RV32I-NEXT: addi sp, sp, 16
2113 ; RV64I-LABEL: fcvt_wu_s_sat_zext:
2114 ; RV64I: # %bb.0: # %start
2115 ; RV64I-NEXT: addi sp, sp, -32
2116 ; RV64I-NEXT: sd ra, 24(sp) # 8-byte Folded Spill
2117 ; RV64I-NEXT: sd s0, 16(sp) # 8-byte Folded Spill
2118 ; RV64I-NEXT: sd s1, 8(sp) # 8-byte Folded Spill
2119 ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill
2120 ; RV64I-NEXT: mv s2, a0
2121 ; RV64I-NEXT: li a1, 0
2122 ; RV64I-NEXT: call __gesf2@plt
2123 ; RV64I-NEXT: mv s0, a0
2124 ; RV64I-NEXT: mv a0, s2
2125 ; RV64I-NEXT: call __fixunssfdi@plt
2126 ; RV64I-NEXT: mv s1, a0
2127 ; RV64I-NEXT: lui a1, 325632
2128 ; RV64I-NEXT: addiw a1, a1, -1
2129 ; RV64I-NEXT: mv a0, s2
2130 ; RV64I-NEXT: call __gtsf2@plt
2131 ; RV64I-NEXT: blez a0, .LBB31_2
2132 ; RV64I-NEXT: # %bb.1: # %start
2133 ; RV64I-NEXT: li a0, -1
2134 ; RV64I-NEXT: srli a0, a0, 32
2135 ; RV64I-NEXT: j .LBB31_3
2136 ; RV64I-NEXT: .LBB31_2:
2137 ; RV64I-NEXT: slti a0, s0, 0
2138 ; RV64I-NEXT: addi a0, a0, -1
2139 ; RV64I-NEXT: and a0, a0, s1
2140 ; RV64I-NEXT: .LBB31_3: # %start
2141 ; RV64I-NEXT: slli a0, a0, 32
2142 ; RV64I-NEXT: srli a0, a0, 32
2143 ; RV64I-NEXT: ld ra, 24(sp) # 8-byte Folded Reload
2144 ; RV64I-NEXT: ld s0, 16(sp) # 8-byte Folded Reload
2145 ; RV64I-NEXT: ld s1, 8(sp) # 8-byte Folded Reload
2146 ; RV64I-NEXT: ld s2, 0(sp) # 8-byte Folded Reload
2147 ; RV64I-NEXT: addi sp, sp, 32
2150 %0 = tail call i32 @llvm.fptoui.sat.i32.f32(float %a)
2154 define signext i32 @fcvt_w_s_sat_sext(float %a) nounwind {
2155 ; CHECKIF-LABEL: fcvt_w_s_sat_sext:
2156 ; CHECKIF: # %bb.0: # %start
2157 ; CHECKIF-NEXT: fcvt.w.s a0, fa0, rtz
2158 ; CHECKIF-NEXT: feq.s a1, fa0, fa0
2159 ; CHECKIF-NEXT: seqz a1, a1
2160 ; CHECKIF-NEXT: addi a1, a1, -1
2161 ; CHECKIF-NEXT: and a0, a1, a0
2164 ; CHECKIZFINX-LABEL: fcvt_w_s_sat_sext:
2165 ; CHECKIZFINX: # %bb.0: # %start
2166 ; CHECKIZFINX-NEXT: fcvt.w.s a1, a0, rtz
2167 ; CHECKIZFINX-NEXT: feq.s a0, a0, a0
2168 ; CHECKIZFINX-NEXT: seqz a0, a0
2169 ; CHECKIZFINX-NEXT: addi a0, a0, -1
2170 ; CHECKIZFINX-NEXT: and a0, a0, a1
2171 ; CHECKIZFINX-NEXT: ret
2173 ; RV32I-LABEL: fcvt_w_s_sat_sext:
2174 ; RV32I: # %bb.0: # %start
2175 ; RV32I-NEXT: addi sp, sp, -32
2176 ; RV32I-NEXT: sw ra, 28(sp) # 4-byte Folded Spill
2177 ; RV32I-NEXT: sw s0, 24(sp) # 4-byte Folded Spill
2178 ; RV32I-NEXT: sw s1, 20(sp) # 4-byte Folded Spill
2179 ; RV32I-NEXT: sw s2, 16(sp) # 4-byte Folded Spill
2180 ; RV32I-NEXT: sw s3, 12(sp) # 4-byte Folded Spill
2181 ; RV32I-NEXT: mv s0, a0
2182 ; RV32I-NEXT: lui a1, 847872
2183 ; RV32I-NEXT: call __gesf2@plt
2184 ; RV32I-NEXT: mv s2, a0
2185 ; RV32I-NEXT: mv a0, s0
2186 ; RV32I-NEXT: call __fixsfsi@plt
2187 ; RV32I-NEXT: mv s1, a0
2188 ; RV32I-NEXT: lui s3, 524288
2189 ; RV32I-NEXT: bgez s2, .LBB32_2
2190 ; RV32I-NEXT: # %bb.1: # %start
2191 ; RV32I-NEXT: lui s1, 524288
2192 ; RV32I-NEXT: .LBB32_2: # %start
2193 ; RV32I-NEXT: lui a1, 323584
2194 ; RV32I-NEXT: addi a1, a1, -1
2195 ; RV32I-NEXT: mv a0, s0
2196 ; RV32I-NEXT: call __gtsf2@plt
2197 ; RV32I-NEXT: blez a0, .LBB32_4
2198 ; RV32I-NEXT: # %bb.3: # %start
2199 ; RV32I-NEXT: addi s1, s3, -1
2200 ; RV32I-NEXT: .LBB32_4: # %start
2201 ; RV32I-NEXT: mv a0, s0
2202 ; RV32I-NEXT: mv a1, s0
2203 ; RV32I-NEXT: call __unordsf2@plt
2204 ; RV32I-NEXT: snez a0, a0
2205 ; RV32I-NEXT: addi a0, a0, -1
2206 ; RV32I-NEXT: and a0, a0, s1
2207 ; RV32I-NEXT: lw ra, 28(sp) # 4-byte Folded Reload
2208 ; RV32I-NEXT: lw s0, 24(sp) # 4-byte Folded Reload
2209 ; RV32I-NEXT: lw s1, 20(sp) # 4-byte Folded Reload
2210 ; RV32I-NEXT: lw s2, 16(sp) # 4-byte Folded Reload
2211 ; RV32I-NEXT: lw s3, 12(sp) # 4-byte Folded Reload
2212 ; RV32I-NEXT: addi sp, sp, 32
2215 ; RV64I-LABEL: fcvt_w_s_sat_sext:
2216 ; RV64I: # %bb.0: # %start
2217 ; RV64I-NEXT: addi sp, sp, -48
2218 ; RV64I-NEXT: sd ra, 40(sp) # 8-byte Folded Spill
2219 ; RV64I-NEXT: sd s0, 32(sp) # 8-byte Folded Spill
2220 ; RV64I-NEXT: sd s1, 24(sp) # 8-byte Folded Spill
2221 ; RV64I-NEXT: sd s2, 16(sp) # 8-byte Folded Spill
2222 ; RV64I-NEXT: sd s3, 8(sp) # 8-byte Folded Spill
2223 ; RV64I-NEXT: mv s0, a0
2224 ; RV64I-NEXT: lui a1, 847872
2225 ; RV64I-NEXT: call __gesf2@plt
2226 ; RV64I-NEXT: mv s2, a0
2227 ; RV64I-NEXT: mv a0, s0
2228 ; RV64I-NEXT: call __fixsfdi@plt
2229 ; RV64I-NEXT: mv s1, a0
2230 ; RV64I-NEXT: lui s3, 524288
2231 ; RV64I-NEXT: bgez s2, .LBB32_2
2232 ; RV64I-NEXT: # %bb.1: # %start
2233 ; RV64I-NEXT: lui s1, 524288
2234 ; RV64I-NEXT: .LBB32_2: # %start
2235 ; RV64I-NEXT: lui a1, 323584
2236 ; RV64I-NEXT: addiw a1, a1, -1
2237 ; RV64I-NEXT: mv a0, s0
2238 ; RV64I-NEXT: call __gtsf2@plt
2239 ; RV64I-NEXT: blez a0, .LBB32_4
2240 ; RV64I-NEXT: # %bb.3: # %start
2241 ; RV64I-NEXT: addi s1, s3, -1
2242 ; RV64I-NEXT: .LBB32_4: # %start
2243 ; RV64I-NEXT: mv a0, s0
2244 ; RV64I-NEXT: mv a1, s0
2245 ; RV64I-NEXT: call __unordsf2@plt
2246 ; RV64I-NEXT: snez a0, a0
2247 ; RV64I-NEXT: addi a0, a0, -1
2248 ; RV64I-NEXT: and a0, a0, s1
2249 ; RV64I-NEXT: sext.w a0, a0
2250 ; RV64I-NEXT: ld ra, 40(sp) # 8-byte Folded Reload
2251 ; RV64I-NEXT: ld s0, 32(sp) # 8-byte Folded Reload
2252 ; RV64I-NEXT: ld s1, 24(sp) # 8-byte Folded Reload
2253 ; RV64I-NEXT: ld s2, 16(sp) # 8-byte Folded Reload
2254 ; RV64I-NEXT: ld s3, 8(sp) # 8-byte Folded Reload
2255 ; RV64I-NEXT: addi sp, sp, 48
2258 %0 = tail call i32 @llvm.fptosi.sat.i32.f32(float %a)