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)