1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -target-abi ilp32d -mattr=+zfa,+d < %s \
3 ; RUN: | FileCheck --check-prefixes=CHECK,RV32IDZFA %s
4 ; RUN: llc -mtriple=riscv64 -target-abi lp64d -mattr=+zfa,+d < %s \
5 ; RUN: | FileCheck --check-prefixes=CHECK,RV64DZFA %s
7 define double @loadfpimm1() {
8 ; CHECK-LABEL: loadfpimm1:
10 ; CHECK-NEXT: fli.d fa0, 0.0625
15 define double @loadfpimm2() {
16 ; CHECK-LABEL: loadfpimm2:
18 ; CHECK-NEXT: fli.d fa0, 0.75
23 define double @loadfpimm3() {
24 ; CHECK-LABEL: loadfpimm3:
26 ; CHECK-NEXT: fli.d fa0, 1.25
31 define double @loadfpimm4() {
32 ; CHECK-LABEL: loadfpimm4:
34 ; CHECK-NEXT: fli.d fa0, 3.0
39 define double @loadfpimm5() {
40 ; CHECK-LABEL: loadfpimm5:
42 ; CHECK-NEXT: fli.d fa0, 256.0
47 define double @loadfpimm6() {
48 ; CHECK-LABEL: loadfpimm6:
50 ; CHECK-NEXT: fli.d fa0, inf
52 ret double 0x7FF0000000000000
55 define double @loadfpimm7() {
56 ; CHECK-LABEL: loadfpimm7:
58 ; CHECK-NEXT: fli.d fa0, nan
60 ret double 0x7FF8000000000000
63 define double @loadfpimm8() {
64 ; CHECK-LABEL: loadfpimm8:
66 ; CHECK-NEXT: fli.d fa0, min
68 ret double 0x0010000000000000
71 define double @loadfpimm9() {
72 ; CHECK-LABEL: loadfpimm9:
74 ; CHECK-NEXT: lui a0, %hi(.LCPI8_0)
75 ; CHECK-NEXT: fld fa0, %lo(.LCPI8_0)(a0)
80 ; Negative test. This is 1 * 2^256.
81 define double @loadfpimm10() {
82 ; CHECK-LABEL: loadfpimm10:
84 ; CHECK-NEXT: lui a0, %hi(.LCPI9_0)
85 ; CHECK-NEXT: fld fa0, %lo(.LCPI9_0)(a0)
87 ret double 0x1000000000000000
90 ; Negative test. This is a qnan with payload of 1.
91 define double @loadfpimm11() {
92 ; CHECK-LABEL: loadfpimm11:
94 ; CHECK-NEXT: lui a0, %hi(.LCPI10_0)
95 ; CHECK-NEXT: fld fa0, %lo(.LCPI10_0)(a0)
97 ret double 0x7ff8000000000001
100 ; Negative test. This is an snan with payload of 1.
101 define double @loadfpimm12() {
102 ; CHECK-LABEL: loadfpimm12:
104 ; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
105 ; CHECK-NEXT: fld fa0, %lo(.LCPI11_0)(a0)
107 ret double 0x7ff0000000000001
110 ; Negative test. This is the smallest denormal.
111 define double @loadfpimm13() {
112 ; RV32IDZFA-LABEL: loadfpimm13:
113 ; RV32IDZFA: # %bb.0:
114 ; RV32IDZFA-NEXT: lui a0, %hi(.LCPI12_0)
115 ; RV32IDZFA-NEXT: fld fa0, %lo(.LCPI12_0)(a0)
116 ; RV32IDZFA-NEXT: ret
118 ; RV64DZFA-LABEL: loadfpimm13:
120 ; RV64DZFA-NEXT: li a0, 1
121 ; RV64DZFA-NEXT: fmv.d.x fa0, a0
123 ret double 0x0000000000000001
126 ; Negative test. This is 2^-1023, a denormal.
127 define double @loadfpimm15() {
128 ; CHECK-LABEL: loadfpimm15:
130 ; CHECK-NEXT: lui a0, %hi(.LCPI13_0)
131 ; CHECK-NEXT: fld fa0, %lo(.LCPI13_0)(a0)
133 ret double 0x0008000000000000
136 define double @loadfpimm16() {
137 ; CHECK-LABEL: loadfpimm16:
139 ; CHECK-NEXT: fli.d fa0, -1.0
144 ; Ensure fli isn't directly used for negated versions of numbers in the fli
146 define double @loadfpimm17() {
147 ; CHECK-LABEL: loadfpimm17:
149 ; CHECK-NEXT: fli.d fa5, 2.0
150 ; CHECK-NEXT: fneg.d fa0, fa5
155 ; Ensure fli isn't directly used for negative min normal value.
156 define double @loadfpimm18() {
157 ; CHECK-LABEL: loadfpimm18:
159 ; CHECK-NEXT: fli.d fa5, min
160 ; CHECK-NEXT: fneg.d fa0, fa5
162 ret double 0x8010000000000000
165 declare double @llvm.minimum.f64(double, double)
167 define double @fminm_d(double %a, double %b) nounwind {
168 ; CHECK-LABEL: fminm_d:
170 ; CHECK-NEXT: fminm.d fa0, fa0, fa1
172 %1 = call double @llvm.minimum.f64(double %a, double %b)
176 declare double @llvm.maximum.f64(double, double)
178 define double @fmaxm_d(double %a, double %b) nounwind {
179 ; CHECK-LABEL: fmaxm_d:
181 ; CHECK-NEXT: fmaxm.d fa0, fa0, fa1
183 %1 = call double @llvm.maximum.f64(double %a, double %b)
187 define double @fround_d_1(double %a) nounwind {
188 ; CHECK-LABEL: fround_d_1:
190 ; CHECK-NEXT: fround.d fa0, fa0, rmm
192 %call = tail call double @round(double %a) nounwind readnone
196 declare double @round(double) nounwind readnone
199 define double @fround_d_2(double %a) nounwind {
200 ; CHECK-LABEL: fround_d_2:
202 ; CHECK-NEXT: fround.d fa0, fa0, rdn
204 %call = tail call double @floor(double %a) nounwind readnone
208 declare double @floor(double) nounwind readnone
211 define double @fround_d_3(double %a) nounwind {
212 ; CHECK-LABEL: fround_d_3:
214 ; CHECK-NEXT: fround.d fa0, fa0, rup
216 %call = tail call double @ceil(double %a) nounwind readnone
220 declare double @ceil(double) nounwind readnone
223 define double @fround_d_4(double %a) nounwind {
224 ; CHECK-LABEL: fround_d_4:
226 ; CHECK-NEXT: fround.d fa0, fa0, rtz
228 %call = tail call double @trunc(double %a) nounwind readnone
232 declare double @trunc(double) nounwind readnone
235 define double @fround_d_5(double %a) nounwind {
236 ; CHECK-LABEL: fround_d_5:
238 ; CHECK-NEXT: fround.d fa0, fa0
240 %call = tail call double @nearbyint(double %a) nounwind readnone
244 declare double @nearbyint(double) nounwind readnone
247 define double @froundnx_d(double %a) nounwind {
248 ; CHECK-LABEL: froundnx_d:
250 ; CHECK-NEXT: froundnx.d fa0, fa0
252 %call = tail call double @rint(double %a) nounwind readnone
256 declare double @rint(double) nounwind readnone
258 declare i1 @llvm.experimental.constrained.fcmp.f64(double, double, metadata, metadata)
260 define i32 @fcmp_olt_q(double %a, double %b) nounwind strictfp {
261 ; CHECK-LABEL: fcmp_olt_q:
263 ; CHECK-NEXT: fltq.d a0, fa0, fa1
265 %1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"olt", metadata !"fpexcept.strict") strictfp
266 %2 = zext i1 %1 to i32
270 define i32 @fcmp_ole_q(double %a, double %b) nounwind strictfp {
271 ; CHECK-LABEL: fcmp_ole_q:
273 ; CHECK-NEXT: fleq.d a0, fa0, fa1
275 %1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"ole", metadata !"fpexcept.strict") strictfp
276 %2 = zext i1 %1 to i32
280 define i32 @fcmp_one_q(double %a, double %b) nounwind strictfp {
281 ; CHECK-LABEL: fcmp_one_q:
283 ; CHECK-NEXT: fltq.d a0, fa0, fa1
284 ; CHECK-NEXT: fltq.d a1, fa1, fa0
285 ; CHECK-NEXT: or a0, a1, a0
287 %1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"one", metadata !"fpexcept.strict") strictfp
288 %2 = zext i1 %1 to i32
292 define i32 @fcmp_ueq_q(double %a, double %b) nounwind strictfp {
293 ; CHECK-LABEL: fcmp_ueq_q:
295 ; CHECK-NEXT: fltq.d a0, fa0, fa1
296 ; CHECK-NEXT: fltq.d a1, fa1, fa0
297 ; CHECK-NEXT: or a0, a1, a0
298 ; CHECK-NEXT: xori a0, a0, 1
300 %1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"ueq", metadata !"fpexcept.strict") strictfp
301 %2 = zext i1 %1 to i32
305 define i64 @fmvh_x_d(double %fa) {
306 ; RV32IDZFA-LABEL: fmvh_x_d:
307 ; RV32IDZFA: # %bb.0:
308 ; RV32IDZFA-NEXT: fmv.x.w a0, fa0
309 ; RV32IDZFA-NEXT: fmvh.x.d a1, fa0
310 ; RV32IDZFA-NEXT: ret
312 ; RV64DZFA-LABEL: fmvh_x_d:
314 ; RV64DZFA-NEXT: fmv.x.d a0, fa0
316 %i = bitcast double %fa to i64
320 define double @fmvp_d_x(i64 %a) {
321 ; RV32IDZFA-LABEL: fmvp_d_x:
322 ; RV32IDZFA: # %bb.0:
323 ; RV32IDZFA-NEXT: fmvp.d.x fa0, a0, a1
324 ; RV32IDZFA-NEXT: ret
326 ; RV64DZFA-LABEL: fmvp_d_x:
328 ; RV64DZFA-NEXT: fmv.d.x fa0, a0
330 %or = bitcast i64 %a to double