1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -target-abi ilp32f -mattr=+zfa < %s \
4 ; RUN: llc -mtriple=riscv64 -target-abi lp64f -mattr=+zfa < %s \
7 define float @loadfpimm1() {
8 ; CHECK-LABEL: loadfpimm1:
10 ; CHECK-NEXT: fli.s fa0, 0.0625
15 define float @loadfpimm2() {
16 ; CHECK-LABEL: loadfpimm2:
18 ; CHECK-NEXT: fli.s fa0, 0.75
23 define float @loadfpimm3() {
24 ; CHECK-LABEL: loadfpimm3:
26 ; CHECK-NEXT: fli.s fa0, 1.25
31 define float @loadfpimm4() {
32 ; CHECK-LABEL: loadfpimm4:
34 ; CHECK-NEXT: fli.s fa0, 3.0
39 define float @loadfpimm5() {
40 ; CHECK-LABEL: loadfpimm5:
42 ; CHECK-NEXT: fli.s fa0, 256.0
47 define float @loadfpimm6() {
48 ; CHECK-LABEL: loadfpimm6:
50 ; CHECK-NEXT: fli.s fa0, inf
52 ret float 0x7FF0000000000000
55 define float @loadfpimm7() {
56 ; CHECK-LABEL: loadfpimm7:
58 ; CHECK-NEXT: fli.s fa0, nan
60 ret float 0x7FF8000000000000
63 define float @loadfpimm8() {
64 ; CHECK-LABEL: loadfpimm8:
66 ; CHECK-NEXT: fli.s fa0, min
68 ret float 0x3810000000000000
71 define float @loadfpimm9() {
72 ; CHECK-LABEL: loadfpimm9:
74 ; CHECK-NEXT: lui a0, 276464
75 ; CHECK-NEXT: fmv.w.x fa0, a0
80 ; This is the f16 minimum value. Make sure we don't use fli.s.
81 define float @loadfpimm10() {
82 ; CHECK-LABEL: loadfpimm10:
84 ; CHECK-NEXT: lui a0, 231424
85 ; CHECK-NEXT: fmv.w.x fa0, a0
87 ret float 0.00006103515625
90 define float @loadfpimm11() {
91 ; CHECK-LABEL: loadfpimm11:
93 ; CHECK-NEXT: fli.s fa0, -1.0
98 ; Ensure fli isn't directly used for negated versions of numbers in the fli
100 define float @loadfpimm12() {
101 ; CHECK-LABEL: loadfpimm12:
103 ; CHECK-NEXT: fli.s fa5, 2.0
104 ; CHECK-NEXT: fneg.s fa0, fa5
109 ; Ensure fli isn't directly used for negative min normal value.
110 define float @loadfpimm13() {
111 ; CHECK-LABEL: loadfpimm13:
113 ; CHECK-NEXT: fli.s fa5, min
114 ; CHECK-NEXT: fneg.s fa0, fa5
116 ret float 0xb810000000000000
119 declare float @llvm.minimum.f32(float, float)
121 define float @fminm_s(float %a, float %b) nounwind {
122 ; CHECK-LABEL: fminm_s:
124 ; CHECK-NEXT: fminm.s fa0, fa0, fa1
126 %1 = call float @llvm.minimum.f32(float %a, float %b)
130 declare float @llvm.maximum.f32(float, float)
132 define float @fmaxm_s(float %a, float %b) nounwind {
133 ; CHECK-LABEL: fmaxm_s:
135 ; CHECK-NEXT: fmaxm.s fa0, fa0, fa1
137 %1 = call float @llvm.maximum.f32(float %a, float %b)
142 define float @fround_s_1(float %a) nounwind {
143 ; CHECK-LABEL: fround_s_1:
145 ; CHECK-NEXT: fround.s fa0, fa0, rmm
147 %call = tail call float @roundf(float %a) nounwind readnone
151 declare float @roundf(float) nounwind readnone
154 define float @fround_s_2(float %a) nounwind {
155 ; CHECK-LABEL: fround_s_2:
157 ; CHECK-NEXT: fround.s fa0, fa0, rdn
159 %call = tail call float @floorf(float %a) nounwind readnone
163 declare float @floorf(float) nounwind readnone
166 define float @fround_s_3(float %a) nounwind {
167 ; CHECK-LABEL: fround_s_3:
169 ; CHECK-NEXT: fround.s fa0, fa0, rup
171 %call = tail call float @ceilf(float %a) nounwind readnone
175 declare float @ceilf(float) nounwind readnone
178 define float @fround_s_4(float %a) nounwind {
179 ; CHECK-LABEL: fround_s_4:
181 ; CHECK-NEXT: fround.s fa0, fa0, rtz
183 %call = tail call float @truncf(float %a) nounwind readnone
187 declare float @truncf(float) nounwind readnone
190 define float @fround_s_5(float %a) nounwind {
191 ; CHECK-LABEL: fround_s_5:
193 ; CHECK-NEXT: fround.s fa0, fa0
195 %call = tail call float @nearbyintf(float %a) nounwind readnone
199 declare float @nearbyintf(float) nounwind readnone
202 define float @froundnx_s(float %a) nounwind {
203 ; CHECK-LABEL: froundnx_s:
205 ; CHECK-NEXT: froundnx.s fa0, fa0
207 %call = tail call float @rintf(float %a) nounwind readnone
211 declare float @rintf(float) nounwind readnone
213 declare i1 @llvm.experimental.constrained.fcmp.f32(float, float, metadata, metadata)
215 define i32 @fcmp_olt_q(float %a, float %b) nounwind strictfp {
216 ; CHECK-LABEL: fcmp_olt_q:
218 ; CHECK-NEXT: fltq.s a0, fa0, fa1
220 %1 = call i1 @llvm.experimental.constrained.fcmp.f32(float %a, float %b, metadata !"olt", metadata !"fpexcept.strict") strictfp
221 %2 = zext i1 %1 to i32
225 define i32 @fcmp_ole_q(float %a, float %b) nounwind strictfp {
226 ; CHECK-LABEL: fcmp_ole_q:
228 ; CHECK-NEXT: fleq.s a0, fa0, fa1
230 %1 = call i1 @llvm.experimental.constrained.fcmp.f32(float %a, float %b, metadata !"ole", metadata !"fpexcept.strict") strictfp
231 %2 = zext i1 %1 to i32
235 define i32 @fcmp_one_q(float %a, float %b) nounwind strictfp {
236 ; CHECK-LABEL: fcmp_one_q:
238 ; CHECK-NEXT: fltq.s a0, fa0, fa1
239 ; CHECK-NEXT: fltq.s a1, fa1, fa0
240 ; CHECK-NEXT: or a0, a1, a0
242 %1 = call i1 @llvm.experimental.constrained.fcmp.f32(float %a, float %b, metadata !"one", metadata !"fpexcept.strict") strictfp
243 %2 = zext i1 %1 to i32
247 define i32 @fcmp_ueq_q(float %a, float %b) nounwind strictfp {
248 ; CHECK-LABEL: fcmp_ueq_q:
250 ; CHECK-NEXT: fltq.s a0, fa0, fa1
251 ; CHECK-NEXT: fltq.s a1, fa1, fa0
252 ; CHECK-NEXT: or a0, a1, a0
253 ; CHECK-NEXT: xori a0, a0, 1
255 %1 = call i1 @llvm.experimental.constrained.fcmp.f32(float %a, float %b, metadata !"ueq", metadata !"fpexcept.strict") strictfp
256 %2 = zext i1 %1 to i32
260 declare void @foo(float, float)
262 ; Make sure we use two fli instructions instead of copying.
263 define void @fli_remat() {
264 ; CHECK-LABEL: fli_remat:
266 ; CHECK-NEXT: fli.s fa0, 1.0
267 ; CHECK-NEXT: fli.s fa1, 1.0
268 ; CHECK-NEXT: tail foo
269 tail call void @foo(float 1.000000e+00, float 1.000000e+00)
273 define float @fadd_neg_0p5(float %x) {
274 ; CHECK-LABEL: fadd_neg_0p5:
276 ; CHECK-NEXT: fli.s fa5, 0.5
277 ; CHECK-NEXT: fsub.s fa0, fa0, fa5
279 %a = fadd float %x, -0.5
283 define float @fma_neg_addend(float %x, float %y) nounwind {
284 ; CHECK-LABEL: fma_neg_addend:
286 ; CHECK-NEXT: fli.s fa5, 0.5
287 ; CHECK-NEXT: fmsub.s fa0, fa0, fa1, fa5
289 %a = call float @llvm.fma.f32(float %x, float %y, float -0.5)
293 define float @fma_neg_multiplicand(float %x, float %y) nounwind {
294 ; CHECK-LABEL: fma_neg_multiplicand:
296 ; CHECK-NEXT: fli.s fa5, 0.125
297 ; CHECK-NEXT: fnmsub.s fa0, fa5, fa0, fa1
299 %a = call float @llvm.fma.f32(float %x, float -0.125, float %y)
303 define float @fma_neg_addend_multiplicand(float %x) nounwind {
304 ; CHECK-LABEL: fma_neg_addend_multiplicand:
306 ; CHECK-NEXT: fli.s fa5, 0.25
307 ; CHECK-NEXT: fli.s fa4, 0.5
308 ; CHECK-NEXT: fnmadd.s fa0, fa4, fa0, fa5
310 %a = call float @llvm.fma.f32(float %x, float -0.5, float -0.25)
314 define float @select_loadfpimm(float %x) nounwind {
315 ; CHECK-LABEL: select_loadfpimm:
316 ; CHECK: # %bb.0: # %entry
317 ; CHECK-NEXT: fmv.w.x fa5, zero
318 ; CHECK-NEXT: fle.s a0, fa5, fa0
319 ; CHECK-NEXT: fli.s fa0, 0.5
320 ; CHECK-NEXT: bnez a0, .LBB30_2
321 ; CHECK-NEXT: # %bb.1:
322 ; CHECK-NEXT: fneg.s fa0, fa0
323 ; CHECK-NEXT: .LBB30_2: # %entry
326 %cmp = fcmp ult float %x, 0.000000e+00
327 %sel = select i1 %cmp, float -5.000000e-01, float 5.000000e-01