1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=riscv32 -target-abi ilp32d -mattr=+zfa,+d < %s \
; RUN: | FileCheck --check-prefixes=CHECK,RV32IDZFA %s
; RUN: llc -mtriple=riscv64 -target-abi lp64d -mattr=+zfa,+d < %s \
; RUN: | FileCheck --check-prefixes=CHECK,RV64DZFA %s
define double @loadfpimm1() {
; CHECK-LABEL: loadfpimm1:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, 0.0625
; CHECK-NEXT: ret
ret double 0.0625
}
define double @loadfpimm2() {
; CHECK-LABEL: loadfpimm2:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, 0.75
; CHECK-NEXT: ret
ret double 0.75
}
define double @loadfpimm3() {
; CHECK-LABEL: loadfpimm3:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, 1.25
; CHECK-NEXT: ret
ret double 1.25
}
define double @loadfpimm4() {
; CHECK-LABEL: loadfpimm4:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, 3.0
; CHECK-NEXT: ret
ret double 3.0
}
define double @loadfpimm5() {
; CHECK-LABEL: loadfpimm5:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, 256.0
; CHECK-NEXT: ret
ret double 256.0
}
define double @loadfpimm6() {
; CHECK-LABEL: loadfpimm6:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, inf
; CHECK-NEXT: ret
ret double 0x7FF0000000000000
}
define double @loadfpimm7() {
; CHECK-LABEL: loadfpimm7:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, nan
; CHECK-NEXT: ret
ret double 0x7FF8000000000000
}
define double @loadfpimm8() {
; CHECK-LABEL: loadfpimm8:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, min
; CHECK-NEXT: ret
ret double 0x0010000000000000
}
define double @loadfpimm9() {
; CHECK-LABEL: loadfpimm9:
; CHECK: # %bb.0:
; CHECK-NEXT: lui a0, %hi(.LCPI8_0)
; CHECK-NEXT: fld fa0, %lo(.LCPI8_0)(a0)
; CHECK-NEXT: ret
ret double 255.0
}
; Negative test. This is 1 * 2^256.
define double @loadfpimm10() {
; CHECK-LABEL: loadfpimm10:
; CHECK: # %bb.0:
; CHECK-NEXT: lui a0, %hi(.LCPI9_0)
; CHECK-NEXT: fld fa0, %lo(.LCPI9_0)(a0)
; CHECK-NEXT: ret
ret double 0x1000000000000000
}
; Negative test. This is a qnan with payload of 1.
define double @loadfpimm11() {
; CHECK-LABEL: loadfpimm11:
; CHECK: # %bb.0:
; CHECK-NEXT: lui a0, %hi(.LCPI10_0)
; CHECK-NEXT: fld fa0, %lo(.LCPI10_0)(a0)
; CHECK-NEXT: ret
ret double 0x7ff8000000000001
}
; Negative test. This is an snan with payload of 1.
define double @loadfpimm12() {
; CHECK-LABEL: loadfpimm12:
; CHECK: # %bb.0:
; CHECK-NEXT: lui a0, %hi(.LCPI11_0)
; CHECK-NEXT: fld fa0, %lo(.LCPI11_0)(a0)
; CHECK-NEXT: ret
ret double 0x7ff0000000000001
}
; Negative test. This is the smallest denormal.
define double @loadfpimm13() {
; RV32IDZFA-LABEL: loadfpimm13:
; RV32IDZFA: # %bb.0:
; RV32IDZFA-NEXT: lui a0, %hi(.LCPI12_0)
; RV32IDZFA-NEXT: fld fa0, %lo(.LCPI12_0)(a0)
; RV32IDZFA-NEXT: ret
;
; RV64DZFA-LABEL: loadfpimm13:
; RV64DZFA: # %bb.0:
; RV64DZFA-NEXT: li a0, 1
; RV64DZFA-NEXT: fmv.d.x fa0, a0
; RV64DZFA-NEXT: ret
ret double 0x0000000000000001
}
; Negative test. This is 2^-1023, a denormal.
define double @loadfpimm15() {
; CHECK-LABEL: loadfpimm15:
; CHECK: # %bb.0:
; CHECK-NEXT: lui a0, %hi(.LCPI13_0)
; CHECK-NEXT: fld fa0, %lo(.LCPI13_0)(a0)
; CHECK-NEXT: ret
ret double 0x0008000000000000
}
define double @loadfpimm16() {
; CHECK-LABEL: loadfpimm16:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa0, -1.0
; CHECK-NEXT: ret
ret double -1.0
}
; Ensure fli isn't directly used for negated versions of numbers in the fli
; table.
define double @loadfpimm17() {
; CHECK-LABEL: loadfpimm17:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa5, 2.0
; CHECK-NEXT: fneg.d fa0, fa5
; CHECK-NEXT: ret
ret double -2.0
}
; Ensure fli isn't directly used for negative min normal value.
define double @loadfpimm18() {
; CHECK-LABEL: loadfpimm18:
; CHECK: # %bb.0:
; CHECK-NEXT: fli.d fa5, min
; CHECK-NEXT: fneg.d fa0, fa5
; CHECK-NEXT: ret
ret double 0x8010000000000000
}
declare double @llvm.minimum.f64(double, double)
define double @fminm_d(double %a, double %b) nounwind {
; CHECK-LABEL: fminm_d:
; CHECK: # %bb.0:
; CHECK-NEXT: fminm.d fa0, fa0, fa1
; CHECK-NEXT: ret
%1 = call double @llvm.minimum.f64(double %a, double %b)
ret double %1
}
declare double @llvm.maximum.f64(double, double)
define double @fmaxm_d(double %a, double %b) nounwind {
; CHECK-LABEL: fmaxm_d:
; CHECK: # %bb.0:
; CHECK-NEXT: fmaxm.d fa0, fa0, fa1
; CHECK-NEXT: ret
%1 = call double @llvm.maximum.f64(double %a, double %b)
ret double %1
}
define double @fround_d_1(double %a) nounwind {
; CHECK-LABEL: fround_d_1:
; CHECK: # %bb.0:
; CHECK-NEXT: fround.d fa0, fa0, rmm
; CHECK-NEXT: ret
%call = tail call double @round(double %a) nounwind readnone
ret double %call
}
declare double @round(double) nounwind readnone
define double @fround_d_2(double %a) nounwind {
; CHECK-LABEL: fround_d_2:
; CHECK: # %bb.0:
; CHECK-NEXT: fround.d fa0, fa0, rdn
; CHECK-NEXT: ret
%call = tail call double @floor(double %a) nounwind readnone
ret double %call
}
declare double @floor(double) nounwind readnone
define double @fround_d_3(double %a) nounwind {
; CHECK-LABEL: fround_d_3:
; CHECK: # %bb.0:
; CHECK-NEXT: fround.d fa0, fa0, rup
; CHECK-NEXT: ret
%call = tail call double @ceil(double %a) nounwind readnone
ret double %call
}
declare double @ceil(double) nounwind readnone
define double @fround_d_4(double %a) nounwind {
; CHECK-LABEL: fround_d_4:
; CHECK: # %bb.0:
; CHECK-NEXT: fround.d fa0, fa0, rtz
; CHECK-NEXT: ret
%call = tail call double @trunc(double %a) nounwind readnone
ret double %call
}
declare double @trunc(double) nounwind readnone
define double @fround_d_5(double %a) nounwind {
; CHECK-LABEL: fround_d_5:
; CHECK: # %bb.0:
; CHECK-NEXT: fround.d fa0, fa0
; CHECK-NEXT: ret
%call = tail call double @nearbyint(double %a) nounwind readnone
ret double %call
}
declare double @nearbyint(double) nounwind readnone
define double @froundnx_d(double %a) nounwind {
; CHECK-LABEL: froundnx_d:
; CHECK: # %bb.0:
; CHECK-NEXT: froundnx.d fa0, fa0
; CHECK-NEXT: ret
%call = tail call double @rint(double %a) nounwind readnone
ret double %call
}
declare double @rint(double) nounwind readnone
declare i1 @llvm.experimental.constrained.fcmp.f64(double, double, metadata, metadata)
define i32 @fcmp_olt_q(double %a, double %b) nounwind strictfp {
; CHECK-LABEL: fcmp_olt_q:
; CHECK: # %bb.0:
; CHECK-NEXT: fltq.d a0, fa0, fa1
; CHECK-NEXT: ret
%1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"olt", metadata !"fpexcept.strict") strictfp
%2 = zext i1 %1 to i32
ret i32 %2
}
define i32 @fcmp_ole_q(double %a, double %b) nounwind strictfp {
; CHECK-LABEL: fcmp_ole_q:
; CHECK: # %bb.0:
; CHECK-NEXT: fleq.d a0, fa0, fa1
; CHECK-NEXT: ret
%1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"ole", metadata !"fpexcept.strict") strictfp
%2 = zext i1 %1 to i32
ret i32 %2
}
define i32 @fcmp_one_q(double %a, double %b) nounwind strictfp {
; CHECK-LABEL: fcmp_one_q:
; CHECK: # %bb.0:
; CHECK-NEXT: fltq.d a0, fa0, fa1
; CHECK-NEXT: fltq.d a1, fa1, fa0
; CHECK-NEXT: or a0, a1, a0
; CHECK-NEXT: ret
%1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"one", metadata !"fpexcept.strict") strictfp
%2 = zext i1 %1 to i32
ret i32 %2
}
define i32 @fcmp_ueq_q(double %a, double %b) nounwind strictfp {
; CHECK-LABEL: fcmp_ueq_q:
; CHECK: # %bb.0:
; CHECK-NEXT: fltq.d a0, fa0, fa1
; CHECK-NEXT: fltq.d a1, fa1, fa0
; CHECK-NEXT: or a0, a1, a0
; CHECK-NEXT: xori a0, a0, 1
; CHECK-NEXT: ret
%1 = call i1 @llvm.experimental.constrained.fcmp.f64(double %a, double %b, metadata !"ueq", metadata !"fpexcept.strict") strictfp
%2 = zext i1 %1 to i32
ret i32 %2
}
define i64 @fmvh_x_d(double %fa) {
; RV32IDZFA-LABEL: fmvh_x_d:
; RV32IDZFA: # %bb.0:
; RV32IDZFA-NEXT: fmv.x.w a0, fa0
; RV32IDZFA-NEXT: fmvh.x.d a1, fa0
; RV32IDZFA-NEXT: ret
;
; RV64DZFA-LABEL: fmvh_x_d:
; RV64DZFA: # %bb.0:
; RV64DZFA-NEXT: fmv.x.d a0, fa0
; RV64DZFA-NEXT: ret
%i = bitcast double %fa to i64
ret i64 %i
}
define double @fmvp_d_x(i64 %a) {
; RV32IDZFA-LABEL: fmvp_d_x:
; RV32IDZFA: # %bb.0:
; RV32IDZFA-NEXT: fmvp.d.x fa0, a0, a1
; RV32IDZFA-NEXT: ret
;
; RV64DZFA-LABEL: fmvp_d_x:
; RV64DZFA: # %bb.0:
; RV64DZFA-NEXT: fmv.d.x fa0, a0
; RV64DZFA-NEXT: ret
%or = bitcast i64 %a to double
ret double %or
}
|