1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32I-ILP32
3 ; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64I-LP64
4 ; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi=ilp32 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32ID-ILP32
5 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi=lp64 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64ID-LP64
6 ; RUN: llc -mtriple=riscv32 -mattr=+d -target-abi=ilp32d -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32ID-ILP32D
7 ; RUN: llc -mtriple=riscv64 -mattr=+d -target-abi=lp64d -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64ID-LP64D
9 define bfloat @float_to_bfloat(float %a) nounwind {
10 ; RV32I-ILP32-LABEL: float_to_bfloat:
11 ; RV32I-ILP32: # %bb.0:
12 ; RV32I-ILP32-NEXT: addi sp, sp, -16
13 ; RV32I-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
14 ; RV32I-ILP32-NEXT: call __truncsfbf2@plt
15 ; RV32I-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
16 ; RV32I-ILP32-NEXT: addi sp, sp, 16
17 ; RV32I-ILP32-NEXT: ret
19 ; RV64I-LP64-LABEL: float_to_bfloat:
20 ; RV64I-LP64: # %bb.0:
21 ; RV64I-LP64-NEXT: addi sp, sp, -16
22 ; RV64I-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
23 ; RV64I-LP64-NEXT: call __truncsfbf2@plt
24 ; RV64I-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
25 ; RV64I-LP64-NEXT: addi sp, sp, 16
26 ; RV64I-LP64-NEXT: ret
28 ; RV32ID-ILP32-LABEL: float_to_bfloat:
29 ; RV32ID-ILP32: # %bb.0:
30 ; RV32ID-ILP32-NEXT: addi sp, sp, -16
31 ; RV32ID-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
32 ; RV32ID-ILP32-NEXT: call __truncsfbf2@plt
33 ; RV32ID-ILP32-NEXT: lui a1, 1048560
34 ; RV32ID-ILP32-NEXT: or a0, a0, a1
35 ; RV32ID-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
36 ; RV32ID-ILP32-NEXT: addi sp, sp, 16
37 ; RV32ID-ILP32-NEXT: ret
39 ; RV64ID-LP64-LABEL: float_to_bfloat:
40 ; RV64ID-LP64: # %bb.0:
41 ; RV64ID-LP64-NEXT: addi sp, sp, -16
42 ; RV64ID-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
43 ; RV64ID-LP64-NEXT: call __truncsfbf2@plt
44 ; RV64ID-LP64-NEXT: lui a1, 1048560
45 ; RV64ID-LP64-NEXT: or a0, a0, a1
46 ; RV64ID-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
47 ; RV64ID-LP64-NEXT: addi sp, sp, 16
48 ; RV64ID-LP64-NEXT: ret
50 ; RV32ID-ILP32D-LABEL: float_to_bfloat:
51 ; RV32ID-ILP32D: # %bb.0:
52 ; RV32ID-ILP32D-NEXT: addi sp, sp, -16
53 ; RV32ID-ILP32D-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
54 ; RV32ID-ILP32D-NEXT: call __truncsfbf2@plt
55 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
56 ; RV32ID-ILP32D-NEXT: lui a1, 1048560
57 ; RV32ID-ILP32D-NEXT: or a0, a0, a1
58 ; RV32ID-ILP32D-NEXT: fmv.w.x fa0, a0
59 ; RV32ID-ILP32D-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
60 ; RV32ID-ILP32D-NEXT: addi sp, sp, 16
61 ; RV32ID-ILP32D-NEXT: ret
63 ; RV64ID-LP64D-LABEL: float_to_bfloat:
64 ; RV64ID-LP64D: # %bb.0:
65 ; RV64ID-LP64D-NEXT: addi sp, sp, -16
66 ; RV64ID-LP64D-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
67 ; RV64ID-LP64D-NEXT: call __truncsfbf2@plt
68 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
69 ; RV64ID-LP64D-NEXT: lui a1, 1048560
70 ; RV64ID-LP64D-NEXT: or a0, a0, a1
71 ; RV64ID-LP64D-NEXT: fmv.w.x fa0, a0
72 ; RV64ID-LP64D-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
73 ; RV64ID-LP64D-NEXT: addi sp, sp, 16
74 ; RV64ID-LP64D-NEXT: ret
75 %1 = fptrunc float %a to bfloat
79 define bfloat @double_to_bfloat(double %a) nounwind {
80 ; RV32I-ILP32-LABEL: double_to_bfloat:
81 ; RV32I-ILP32: # %bb.0:
82 ; RV32I-ILP32-NEXT: addi sp, sp, -16
83 ; RV32I-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
84 ; RV32I-ILP32-NEXT: call __truncdfbf2@plt
85 ; RV32I-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
86 ; RV32I-ILP32-NEXT: addi sp, sp, 16
87 ; RV32I-ILP32-NEXT: ret
89 ; RV64I-LP64-LABEL: double_to_bfloat:
90 ; RV64I-LP64: # %bb.0:
91 ; RV64I-LP64-NEXT: addi sp, sp, -16
92 ; RV64I-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
93 ; RV64I-LP64-NEXT: call __truncdfbf2@plt
94 ; RV64I-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
95 ; RV64I-LP64-NEXT: addi sp, sp, 16
96 ; RV64I-LP64-NEXT: ret
98 ; RV32ID-ILP32-LABEL: double_to_bfloat:
99 ; RV32ID-ILP32: # %bb.0:
100 ; RV32ID-ILP32-NEXT: addi sp, sp, -16
101 ; RV32ID-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
102 ; RV32ID-ILP32-NEXT: call __truncdfbf2@plt
103 ; RV32ID-ILP32-NEXT: lui a1, 1048560
104 ; RV32ID-ILP32-NEXT: or a0, a0, a1
105 ; RV32ID-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
106 ; RV32ID-ILP32-NEXT: addi sp, sp, 16
107 ; RV32ID-ILP32-NEXT: ret
109 ; RV64ID-LP64-LABEL: double_to_bfloat:
110 ; RV64ID-LP64: # %bb.0:
111 ; RV64ID-LP64-NEXT: addi sp, sp, -16
112 ; RV64ID-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
113 ; RV64ID-LP64-NEXT: call __truncdfbf2@plt
114 ; RV64ID-LP64-NEXT: lui a1, 1048560
115 ; RV64ID-LP64-NEXT: or a0, a0, a1
116 ; RV64ID-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
117 ; RV64ID-LP64-NEXT: addi sp, sp, 16
118 ; RV64ID-LP64-NEXT: ret
120 ; RV32ID-ILP32D-LABEL: double_to_bfloat:
121 ; RV32ID-ILP32D: # %bb.0:
122 ; RV32ID-ILP32D-NEXT: addi sp, sp, -16
123 ; RV32ID-ILP32D-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
124 ; RV32ID-ILP32D-NEXT: call __truncdfbf2@plt
125 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
126 ; RV32ID-ILP32D-NEXT: lui a1, 1048560
127 ; RV32ID-ILP32D-NEXT: or a0, a0, a1
128 ; RV32ID-ILP32D-NEXT: fmv.w.x fa0, a0
129 ; RV32ID-ILP32D-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
130 ; RV32ID-ILP32D-NEXT: addi sp, sp, 16
131 ; RV32ID-ILP32D-NEXT: ret
133 ; RV64ID-LP64D-LABEL: double_to_bfloat:
134 ; RV64ID-LP64D: # %bb.0:
135 ; RV64ID-LP64D-NEXT: addi sp, sp, -16
136 ; RV64ID-LP64D-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
137 ; RV64ID-LP64D-NEXT: call __truncdfbf2@plt
138 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
139 ; RV64ID-LP64D-NEXT: lui a1, 1048560
140 ; RV64ID-LP64D-NEXT: or a0, a0, a1
141 ; RV64ID-LP64D-NEXT: fmv.w.x fa0, a0
142 ; RV64ID-LP64D-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
143 ; RV64ID-LP64D-NEXT: addi sp, sp, 16
144 ; RV64ID-LP64D-NEXT: ret
145 %1 = fptrunc double %a to bfloat
149 define float @bfloat_to_float(bfloat %a) nounwind {
150 ; RV32I-ILP32-LABEL: bfloat_to_float:
151 ; RV32I-ILP32: # %bb.0:
152 ; RV32I-ILP32-NEXT: slli a0, a0, 16
153 ; RV32I-ILP32-NEXT: ret
155 ; RV64I-LP64-LABEL: bfloat_to_float:
156 ; RV64I-LP64: # %bb.0:
157 ; RV64I-LP64-NEXT: slliw a0, a0, 16
158 ; RV64I-LP64-NEXT: ret
160 ; RV32ID-ILP32-LABEL: bfloat_to_float:
161 ; RV32ID-ILP32: # %bb.0:
162 ; RV32ID-ILP32-NEXT: slli a0, a0, 16
163 ; RV32ID-ILP32-NEXT: ret
165 ; RV64ID-LP64-LABEL: bfloat_to_float:
166 ; RV64ID-LP64: # %bb.0:
167 ; RV64ID-LP64-NEXT: slli a0, a0, 48
168 ; RV64ID-LP64-NEXT: srli a0, a0, 48
169 ; RV64ID-LP64-NEXT: slli a0, a0, 16
170 ; RV64ID-LP64-NEXT: ret
172 ; RV32ID-ILP32D-LABEL: bfloat_to_float:
173 ; RV32ID-ILP32D: # %bb.0:
174 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
175 ; RV32ID-ILP32D-NEXT: slli a0, a0, 16
176 ; RV32ID-ILP32D-NEXT: fmv.w.x fa0, a0
177 ; RV32ID-ILP32D-NEXT: ret
179 ; RV64ID-LP64D-LABEL: bfloat_to_float:
180 ; RV64ID-LP64D: # %bb.0:
181 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
182 ; RV64ID-LP64D-NEXT: slli a0, a0, 48
183 ; RV64ID-LP64D-NEXT: srli a0, a0, 48
184 ; RV64ID-LP64D-NEXT: slli a0, a0, 16
185 ; RV64ID-LP64D-NEXT: fmv.w.x fa0, a0
186 ; RV64ID-LP64D-NEXT: ret
187 %1 = fpext bfloat %a to float
191 define double @bfloat_to_double(bfloat %a) nounwind {
192 ; RV32I-ILP32-LABEL: bfloat_to_double:
193 ; RV32I-ILP32: # %bb.0:
194 ; RV32I-ILP32-NEXT: addi sp, sp, -16
195 ; RV32I-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
196 ; RV32I-ILP32-NEXT: slli a0, a0, 16
197 ; RV32I-ILP32-NEXT: call __extendsfdf2@plt
198 ; RV32I-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
199 ; RV32I-ILP32-NEXT: addi sp, sp, 16
200 ; RV32I-ILP32-NEXT: ret
202 ; RV64I-LP64-LABEL: bfloat_to_double:
203 ; RV64I-LP64: # %bb.0:
204 ; RV64I-LP64-NEXT: addi sp, sp, -16
205 ; RV64I-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
206 ; RV64I-LP64-NEXT: slliw a0, a0, 16
207 ; RV64I-LP64-NEXT: call __extendsfdf2@plt
208 ; RV64I-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
209 ; RV64I-LP64-NEXT: addi sp, sp, 16
210 ; RV64I-LP64-NEXT: ret
212 ; RV32ID-ILP32-LABEL: bfloat_to_double:
213 ; RV32ID-ILP32: # %bb.0:
214 ; RV32ID-ILP32-NEXT: addi sp, sp, -16
215 ; RV32ID-ILP32-NEXT: slli a0, a0, 16
216 ; RV32ID-ILP32-NEXT: fmv.w.x fa5, a0
217 ; RV32ID-ILP32-NEXT: fcvt.d.s fa5, fa5
218 ; RV32ID-ILP32-NEXT: fsd fa5, 8(sp)
219 ; RV32ID-ILP32-NEXT: lw a0, 8(sp)
220 ; RV32ID-ILP32-NEXT: lw a1, 12(sp)
221 ; RV32ID-ILP32-NEXT: addi sp, sp, 16
222 ; RV32ID-ILP32-NEXT: ret
224 ; RV64ID-LP64-LABEL: bfloat_to_double:
225 ; RV64ID-LP64: # %bb.0:
226 ; RV64ID-LP64-NEXT: slli a0, a0, 48
227 ; RV64ID-LP64-NEXT: srli a0, a0, 48
228 ; RV64ID-LP64-NEXT: slli a0, a0, 16
229 ; RV64ID-LP64-NEXT: fmv.w.x fa5, a0
230 ; RV64ID-LP64-NEXT: fcvt.d.s fa5, fa5
231 ; RV64ID-LP64-NEXT: fmv.x.d a0, fa5
232 ; RV64ID-LP64-NEXT: ret
234 ; RV32ID-ILP32D-LABEL: bfloat_to_double:
235 ; RV32ID-ILP32D: # %bb.0:
236 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
237 ; RV32ID-ILP32D-NEXT: slli a0, a0, 16
238 ; RV32ID-ILP32D-NEXT: fmv.w.x fa5, a0
239 ; RV32ID-ILP32D-NEXT: fcvt.d.s fa0, fa5
240 ; RV32ID-ILP32D-NEXT: ret
242 ; RV64ID-LP64D-LABEL: bfloat_to_double:
243 ; RV64ID-LP64D: # %bb.0:
244 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
245 ; RV64ID-LP64D-NEXT: slli a0, a0, 48
246 ; RV64ID-LP64D-NEXT: srli a0, a0, 48
247 ; RV64ID-LP64D-NEXT: slli a0, a0, 16
248 ; RV64ID-LP64D-NEXT: fmv.w.x fa5, a0
249 ; RV64ID-LP64D-NEXT: fcvt.d.s fa0, fa5
250 ; RV64ID-LP64D-NEXT: ret
251 %1 = fpext bfloat %a to double
255 define bfloat @i16_to_bfloat(i16 %a) nounwind {
256 ; RV32I-ILP32-LABEL: i16_to_bfloat:
257 ; RV32I-ILP32: # %bb.0:
258 ; RV32I-ILP32-NEXT: ret
260 ; RV64I-LP64-LABEL: i16_to_bfloat:
261 ; RV64I-LP64: # %bb.0:
262 ; RV64I-LP64-NEXT: ret
264 ; RV32ID-ILP32-LABEL: i16_to_bfloat:
265 ; RV32ID-ILP32: # %bb.0:
266 ; RV32ID-ILP32-NEXT: lui a1, 1048560
267 ; RV32ID-ILP32-NEXT: or a0, a0, a1
268 ; RV32ID-ILP32-NEXT: ret
270 ; RV64ID-LP64-LABEL: i16_to_bfloat:
271 ; RV64ID-LP64: # %bb.0:
272 ; RV64ID-LP64-NEXT: lui a1, 1048560
273 ; RV64ID-LP64-NEXT: or a0, a0, a1
274 ; RV64ID-LP64-NEXT: ret
276 ; RV32ID-ILP32D-LABEL: i16_to_bfloat:
277 ; RV32ID-ILP32D: # %bb.0:
278 ; RV32ID-ILP32D-NEXT: lui a1, 1048560
279 ; RV32ID-ILP32D-NEXT: or a0, a0, a1
280 ; RV32ID-ILP32D-NEXT: fmv.w.x fa0, a0
281 ; RV32ID-ILP32D-NEXT: ret
283 ; RV64ID-LP64D-LABEL: i16_to_bfloat:
284 ; RV64ID-LP64D: # %bb.0:
285 ; RV64ID-LP64D-NEXT: lui a1, 1048560
286 ; RV64ID-LP64D-NEXT: or a0, a0, a1
287 ; RV64ID-LP64D-NEXT: fmv.w.x fa0, a0
288 ; RV64ID-LP64D-NEXT: ret
289 %1 = bitcast i16 %a to bfloat
293 define i16 @bfloat_to_i16(bfloat %a) nounwind {
294 ; RV32I-ILP32-LABEL: bfloat_to_i16:
295 ; RV32I-ILP32: # %bb.0:
296 ; RV32I-ILP32-NEXT: ret
298 ; RV64I-LP64-LABEL: bfloat_to_i16:
299 ; RV64I-LP64: # %bb.0:
300 ; RV64I-LP64-NEXT: ret
302 ; RV32ID-ILP32-LABEL: bfloat_to_i16:
303 ; RV32ID-ILP32: # %bb.0:
304 ; RV32ID-ILP32-NEXT: ret
306 ; RV64ID-LP64-LABEL: bfloat_to_i16:
307 ; RV64ID-LP64: # %bb.0:
308 ; RV64ID-LP64-NEXT: ret
310 ; RV32ID-ILP32D-LABEL: bfloat_to_i16:
311 ; RV32ID-ILP32D: # %bb.0:
312 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
313 ; RV32ID-ILP32D-NEXT: ret
315 ; RV64ID-LP64D-LABEL: bfloat_to_i16:
316 ; RV64ID-LP64D: # %bb.0:
317 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
318 ; RV64ID-LP64D-NEXT: ret
319 %1 = bitcast bfloat %a to i16
323 define bfloat @bfloat_add(bfloat %a, bfloat %b) nounwind {
324 ; RV32I-ILP32-LABEL: bfloat_add:
325 ; RV32I-ILP32: # %bb.0:
326 ; RV32I-ILP32-NEXT: addi sp, sp, -16
327 ; RV32I-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
328 ; RV32I-ILP32-NEXT: slli a0, a0, 16
329 ; RV32I-ILP32-NEXT: slli a1, a1, 16
330 ; RV32I-ILP32-NEXT: call __addsf3@plt
331 ; RV32I-ILP32-NEXT: call __truncsfbf2@plt
332 ; RV32I-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
333 ; RV32I-ILP32-NEXT: addi sp, sp, 16
334 ; RV32I-ILP32-NEXT: ret
336 ; RV64I-LP64-LABEL: bfloat_add:
337 ; RV64I-LP64: # %bb.0:
338 ; RV64I-LP64-NEXT: addi sp, sp, -16
339 ; RV64I-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
340 ; RV64I-LP64-NEXT: slliw a0, a0, 16
341 ; RV64I-LP64-NEXT: slliw a1, a1, 16
342 ; RV64I-LP64-NEXT: call __addsf3@plt
343 ; RV64I-LP64-NEXT: call __truncsfbf2@plt
344 ; RV64I-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
345 ; RV64I-LP64-NEXT: addi sp, sp, 16
346 ; RV64I-LP64-NEXT: ret
348 ; RV32ID-ILP32-LABEL: bfloat_add:
349 ; RV32ID-ILP32: # %bb.0:
350 ; RV32ID-ILP32-NEXT: addi sp, sp, -16
351 ; RV32ID-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
352 ; RV32ID-ILP32-NEXT: slli a1, a1, 16
353 ; RV32ID-ILP32-NEXT: fmv.w.x fa5, a1
354 ; RV32ID-ILP32-NEXT: slli a0, a0, 16
355 ; RV32ID-ILP32-NEXT: fmv.w.x fa4, a0
356 ; RV32ID-ILP32-NEXT: fadd.s fa5, fa4, fa5
357 ; RV32ID-ILP32-NEXT: fmv.x.w a0, fa5
358 ; RV32ID-ILP32-NEXT: call __truncsfbf2@plt
359 ; RV32ID-ILP32-NEXT: lui a1, 1048560
360 ; RV32ID-ILP32-NEXT: or a0, a0, a1
361 ; RV32ID-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
362 ; RV32ID-ILP32-NEXT: addi sp, sp, 16
363 ; RV32ID-ILP32-NEXT: ret
365 ; RV64ID-LP64-LABEL: bfloat_add:
366 ; RV64ID-LP64: # %bb.0:
367 ; RV64ID-LP64-NEXT: addi sp, sp, -16
368 ; RV64ID-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
369 ; RV64ID-LP64-NEXT: lui a2, 16
370 ; RV64ID-LP64-NEXT: addi a2, a2, -1
371 ; RV64ID-LP64-NEXT: and a0, a0, a2
372 ; RV64ID-LP64-NEXT: and a1, a1, a2
373 ; RV64ID-LP64-NEXT: slli a1, a1, 16
374 ; RV64ID-LP64-NEXT: fmv.w.x fa5, a1
375 ; RV64ID-LP64-NEXT: slli a0, a0, 16
376 ; RV64ID-LP64-NEXT: fmv.w.x fa4, a0
377 ; RV64ID-LP64-NEXT: fadd.s fa5, fa4, fa5
378 ; RV64ID-LP64-NEXT: fmv.x.w a0, fa5
379 ; RV64ID-LP64-NEXT: call __truncsfbf2@plt
380 ; RV64ID-LP64-NEXT: lui a1, 1048560
381 ; RV64ID-LP64-NEXT: or a0, a0, a1
382 ; RV64ID-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
383 ; RV64ID-LP64-NEXT: addi sp, sp, 16
384 ; RV64ID-LP64-NEXT: ret
386 ; RV32ID-ILP32D-LABEL: bfloat_add:
387 ; RV32ID-ILP32D: # %bb.0:
388 ; RV32ID-ILP32D-NEXT: addi sp, sp, -16
389 ; RV32ID-ILP32D-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
390 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
391 ; RV32ID-ILP32D-NEXT: fmv.x.w a1, fa1
392 ; RV32ID-ILP32D-NEXT: slli a1, a1, 16
393 ; RV32ID-ILP32D-NEXT: fmv.w.x fa5, a1
394 ; RV32ID-ILP32D-NEXT: slli a0, a0, 16
395 ; RV32ID-ILP32D-NEXT: fmv.w.x fa4, a0
396 ; RV32ID-ILP32D-NEXT: fadd.s fa0, fa4, fa5
397 ; RV32ID-ILP32D-NEXT: call __truncsfbf2@plt
398 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
399 ; RV32ID-ILP32D-NEXT: lui a1, 1048560
400 ; RV32ID-ILP32D-NEXT: or a0, a0, a1
401 ; RV32ID-ILP32D-NEXT: fmv.w.x fa0, a0
402 ; RV32ID-ILP32D-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
403 ; RV32ID-ILP32D-NEXT: addi sp, sp, 16
404 ; RV32ID-ILP32D-NEXT: ret
406 ; RV64ID-LP64D-LABEL: bfloat_add:
407 ; RV64ID-LP64D: # %bb.0:
408 ; RV64ID-LP64D-NEXT: addi sp, sp, -16
409 ; RV64ID-LP64D-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
410 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
411 ; RV64ID-LP64D-NEXT: lui a1, 16
412 ; RV64ID-LP64D-NEXT: addi a1, a1, -1
413 ; RV64ID-LP64D-NEXT: and a0, a0, a1
414 ; RV64ID-LP64D-NEXT: fmv.x.w a2, fa1
415 ; RV64ID-LP64D-NEXT: and a1, a2, a1
416 ; RV64ID-LP64D-NEXT: slli a1, a1, 16
417 ; RV64ID-LP64D-NEXT: fmv.w.x fa5, a1
418 ; RV64ID-LP64D-NEXT: slli a0, a0, 16
419 ; RV64ID-LP64D-NEXT: fmv.w.x fa4, a0
420 ; RV64ID-LP64D-NEXT: fadd.s fa0, fa4, fa5
421 ; RV64ID-LP64D-NEXT: call __truncsfbf2@plt
422 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
423 ; RV64ID-LP64D-NEXT: lui a1, 1048560
424 ; RV64ID-LP64D-NEXT: or a0, a0, a1
425 ; RV64ID-LP64D-NEXT: fmv.w.x fa0, a0
426 ; RV64ID-LP64D-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
427 ; RV64ID-LP64D-NEXT: addi sp, sp, 16
428 ; RV64ID-LP64D-NEXT: ret
429 %1 = fadd bfloat %a, %b
433 define bfloat @bfloat_load(ptr %a) nounwind {
434 ; RV32I-ILP32-LABEL: bfloat_load:
435 ; RV32I-ILP32: # %bb.0:
436 ; RV32I-ILP32-NEXT: addi sp, sp, -16
437 ; RV32I-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
438 ; RV32I-ILP32-NEXT: lh a1, 0(a0)
439 ; RV32I-ILP32-NEXT: lh a2, 6(a0)
440 ; RV32I-ILP32-NEXT: slli a0, a1, 16
441 ; RV32I-ILP32-NEXT: slli a1, a2, 16
442 ; RV32I-ILP32-NEXT: call __addsf3@plt
443 ; RV32I-ILP32-NEXT: call __truncsfbf2@plt
444 ; RV32I-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
445 ; RV32I-ILP32-NEXT: addi sp, sp, 16
446 ; RV32I-ILP32-NEXT: ret
448 ; RV64I-LP64-LABEL: bfloat_load:
449 ; RV64I-LP64: # %bb.0:
450 ; RV64I-LP64-NEXT: addi sp, sp, -16
451 ; RV64I-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
452 ; RV64I-LP64-NEXT: lh a1, 0(a0)
453 ; RV64I-LP64-NEXT: lh a2, 6(a0)
454 ; RV64I-LP64-NEXT: slliw a0, a1, 16
455 ; RV64I-LP64-NEXT: slliw a1, a2, 16
456 ; RV64I-LP64-NEXT: call __addsf3@plt
457 ; RV64I-LP64-NEXT: call __truncsfbf2@plt
458 ; RV64I-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
459 ; RV64I-LP64-NEXT: addi sp, sp, 16
460 ; RV64I-LP64-NEXT: ret
462 ; RV32ID-ILP32-LABEL: bfloat_load:
463 ; RV32ID-ILP32: # %bb.0:
464 ; RV32ID-ILP32-NEXT: addi sp, sp, -16
465 ; RV32ID-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
466 ; RV32ID-ILP32-NEXT: lhu a1, 6(a0)
467 ; RV32ID-ILP32-NEXT: lhu a0, 0(a0)
468 ; RV32ID-ILP32-NEXT: slli a1, a1, 16
469 ; RV32ID-ILP32-NEXT: fmv.w.x fa5, a1
470 ; RV32ID-ILP32-NEXT: slli a0, a0, 16
471 ; RV32ID-ILP32-NEXT: fmv.w.x fa4, a0
472 ; RV32ID-ILP32-NEXT: fadd.s fa5, fa4, fa5
473 ; RV32ID-ILP32-NEXT: fmv.x.w a0, fa5
474 ; RV32ID-ILP32-NEXT: call __truncsfbf2@plt
475 ; RV32ID-ILP32-NEXT: lui a1, 1048560
476 ; RV32ID-ILP32-NEXT: or a0, a0, a1
477 ; RV32ID-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
478 ; RV32ID-ILP32-NEXT: addi sp, sp, 16
479 ; RV32ID-ILP32-NEXT: ret
481 ; RV64ID-LP64-LABEL: bfloat_load:
482 ; RV64ID-LP64: # %bb.0:
483 ; RV64ID-LP64-NEXT: addi sp, sp, -16
484 ; RV64ID-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
485 ; RV64ID-LP64-NEXT: lhu a1, 6(a0)
486 ; RV64ID-LP64-NEXT: lhu a0, 0(a0)
487 ; RV64ID-LP64-NEXT: slli a1, a1, 16
488 ; RV64ID-LP64-NEXT: fmv.w.x fa5, a1
489 ; RV64ID-LP64-NEXT: slli a0, a0, 16
490 ; RV64ID-LP64-NEXT: fmv.w.x fa4, a0
491 ; RV64ID-LP64-NEXT: fadd.s fa5, fa4, fa5
492 ; RV64ID-LP64-NEXT: fmv.x.w a0, fa5
493 ; RV64ID-LP64-NEXT: call __truncsfbf2@plt
494 ; RV64ID-LP64-NEXT: lui a1, 1048560
495 ; RV64ID-LP64-NEXT: or a0, a0, a1
496 ; RV64ID-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
497 ; RV64ID-LP64-NEXT: addi sp, sp, 16
498 ; RV64ID-LP64-NEXT: ret
500 ; RV32ID-ILP32D-LABEL: bfloat_load:
501 ; RV32ID-ILP32D: # %bb.0:
502 ; RV32ID-ILP32D-NEXT: addi sp, sp, -16
503 ; RV32ID-ILP32D-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
504 ; RV32ID-ILP32D-NEXT: lhu a1, 6(a0)
505 ; RV32ID-ILP32D-NEXT: lhu a0, 0(a0)
506 ; RV32ID-ILP32D-NEXT: slli a1, a1, 16
507 ; RV32ID-ILP32D-NEXT: fmv.w.x fa5, a1
508 ; RV32ID-ILP32D-NEXT: slli a0, a0, 16
509 ; RV32ID-ILP32D-NEXT: fmv.w.x fa4, a0
510 ; RV32ID-ILP32D-NEXT: fadd.s fa0, fa4, fa5
511 ; RV32ID-ILP32D-NEXT: call __truncsfbf2@plt
512 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
513 ; RV32ID-ILP32D-NEXT: lui a1, 1048560
514 ; RV32ID-ILP32D-NEXT: or a0, a0, a1
515 ; RV32ID-ILP32D-NEXT: fmv.w.x fa0, a0
516 ; RV32ID-ILP32D-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
517 ; RV32ID-ILP32D-NEXT: addi sp, sp, 16
518 ; RV32ID-ILP32D-NEXT: ret
520 ; RV64ID-LP64D-LABEL: bfloat_load:
521 ; RV64ID-LP64D: # %bb.0:
522 ; RV64ID-LP64D-NEXT: addi sp, sp, -16
523 ; RV64ID-LP64D-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
524 ; RV64ID-LP64D-NEXT: lhu a1, 6(a0)
525 ; RV64ID-LP64D-NEXT: lhu a0, 0(a0)
526 ; RV64ID-LP64D-NEXT: slli a1, a1, 16
527 ; RV64ID-LP64D-NEXT: fmv.w.x fa5, a1
528 ; RV64ID-LP64D-NEXT: slli a0, a0, 16
529 ; RV64ID-LP64D-NEXT: fmv.w.x fa4, a0
530 ; RV64ID-LP64D-NEXT: fadd.s fa0, fa4, fa5
531 ; RV64ID-LP64D-NEXT: call __truncsfbf2@plt
532 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
533 ; RV64ID-LP64D-NEXT: lui a1, 1048560
534 ; RV64ID-LP64D-NEXT: or a0, a0, a1
535 ; RV64ID-LP64D-NEXT: fmv.w.x fa0, a0
536 ; RV64ID-LP64D-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
537 ; RV64ID-LP64D-NEXT: addi sp, sp, 16
538 ; RV64ID-LP64D-NEXT: ret
539 %1 = load bfloat, ptr %a
540 %2 = getelementptr bfloat, ptr %a, i32 3
541 %3 = load bfloat, ptr %2
542 %4 = fadd bfloat %1, %3
546 define void @bfloat_store(ptr %a, bfloat %b, bfloat %c) nounwind {
547 ; RV32I-ILP32-LABEL: bfloat_store:
548 ; RV32I-ILP32: # %bb.0:
549 ; RV32I-ILP32-NEXT: addi sp, sp, -16
550 ; RV32I-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
551 ; RV32I-ILP32-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
552 ; RV32I-ILP32-NEXT: mv s0, a0
553 ; RV32I-ILP32-NEXT: slli a0, a1, 16
554 ; RV32I-ILP32-NEXT: slli a1, a2, 16
555 ; RV32I-ILP32-NEXT: call __addsf3@plt
556 ; RV32I-ILP32-NEXT: call __truncsfbf2@plt
557 ; RV32I-ILP32-NEXT: sh a0, 0(s0)
558 ; RV32I-ILP32-NEXT: sh a0, 16(s0)
559 ; RV32I-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
560 ; RV32I-ILP32-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
561 ; RV32I-ILP32-NEXT: addi sp, sp, 16
562 ; RV32I-ILP32-NEXT: ret
564 ; RV64I-LP64-LABEL: bfloat_store:
565 ; RV64I-LP64: # %bb.0:
566 ; RV64I-LP64-NEXT: addi sp, sp, -16
567 ; RV64I-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
568 ; RV64I-LP64-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
569 ; RV64I-LP64-NEXT: mv s0, a0
570 ; RV64I-LP64-NEXT: slliw a0, a1, 16
571 ; RV64I-LP64-NEXT: slliw a1, a2, 16
572 ; RV64I-LP64-NEXT: call __addsf3@plt
573 ; RV64I-LP64-NEXT: call __truncsfbf2@plt
574 ; RV64I-LP64-NEXT: sh a0, 0(s0)
575 ; RV64I-LP64-NEXT: sh a0, 16(s0)
576 ; RV64I-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
577 ; RV64I-LP64-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
578 ; RV64I-LP64-NEXT: addi sp, sp, 16
579 ; RV64I-LP64-NEXT: ret
581 ; RV32ID-ILP32-LABEL: bfloat_store:
582 ; RV32ID-ILP32: # %bb.0:
583 ; RV32ID-ILP32-NEXT: addi sp, sp, -16
584 ; RV32ID-ILP32-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
585 ; RV32ID-ILP32-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
586 ; RV32ID-ILP32-NEXT: mv s0, a0
587 ; RV32ID-ILP32-NEXT: slli a2, a2, 16
588 ; RV32ID-ILP32-NEXT: fmv.w.x fa5, a2
589 ; RV32ID-ILP32-NEXT: slli a1, a1, 16
590 ; RV32ID-ILP32-NEXT: fmv.w.x fa4, a1
591 ; RV32ID-ILP32-NEXT: fadd.s fa5, fa4, fa5
592 ; RV32ID-ILP32-NEXT: fmv.x.w a0, fa5
593 ; RV32ID-ILP32-NEXT: call __truncsfbf2@plt
594 ; RV32ID-ILP32-NEXT: sh a0, 0(s0)
595 ; RV32ID-ILP32-NEXT: sh a0, 16(s0)
596 ; RV32ID-ILP32-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
597 ; RV32ID-ILP32-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
598 ; RV32ID-ILP32-NEXT: addi sp, sp, 16
599 ; RV32ID-ILP32-NEXT: ret
601 ; RV64ID-LP64-LABEL: bfloat_store:
602 ; RV64ID-LP64: # %bb.0:
603 ; RV64ID-LP64-NEXT: addi sp, sp, -16
604 ; RV64ID-LP64-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
605 ; RV64ID-LP64-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
606 ; RV64ID-LP64-NEXT: mv s0, a0
607 ; RV64ID-LP64-NEXT: lui a0, 16
608 ; RV64ID-LP64-NEXT: addi a0, a0, -1
609 ; RV64ID-LP64-NEXT: and a1, a1, a0
610 ; RV64ID-LP64-NEXT: and a0, a2, a0
611 ; RV64ID-LP64-NEXT: slli a0, a0, 16
612 ; RV64ID-LP64-NEXT: fmv.w.x fa5, a0
613 ; RV64ID-LP64-NEXT: slli a1, a1, 16
614 ; RV64ID-LP64-NEXT: fmv.w.x fa4, a1
615 ; RV64ID-LP64-NEXT: fadd.s fa5, fa4, fa5
616 ; RV64ID-LP64-NEXT: fmv.x.w a0, fa5
617 ; RV64ID-LP64-NEXT: call __truncsfbf2@plt
618 ; RV64ID-LP64-NEXT: sh a0, 0(s0)
619 ; RV64ID-LP64-NEXT: sh a0, 16(s0)
620 ; RV64ID-LP64-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
621 ; RV64ID-LP64-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
622 ; RV64ID-LP64-NEXT: addi sp, sp, 16
623 ; RV64ID-LP64-NEXT: ret
625 ; RV32ID-ILP32D-LABEL: bfloat_store:
626 ; RV32ID-ILP32D: # %bb.0:
627 ; RV32ID-ILP32D-NEXT: addi sp, sp, -16
628 ; RV32ID-ILP32D-NEXT: sw ra, 12(sp) # 4-byte Folded Spill
629 ; RV32ID-ILP32D-NEXT: sw s0, 8(sp) # 4-byte Folded Spill
630 ; RV32ID-ILP32D-NEXT: mv s0, a0
631 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
632 ; RV32ID-ILP32D-NEXT: fmv.x.w a1, fa1
633 ; RV32ID-ILP32D-NEXT: slli a1, a1, 16
634 ; RV32ID-ILP32D-NEXT: fmv.w.x fa5, a1
635 ; RV32ID-ILP32D-NEXT: slli a0, a0, 16
636 ; RV32ID-ILP32D-NEXT: fmv.w.x fa4, a0
637 ; RV32ID-ILP32D-NEXT: fadd.s fa0, fa4, fa5
638 ; RV32ID-ILP32D-NEXT: call __truncsfbf2@plt
639 ; RV32ID-ILP32D-NEXT: fmv.x.w a0, fa0
640 ; RV32ID-ILP32D-NEXT: sh a0, 0(s0)
641 ; RV32ID-ILP32D-NEXT: sh a0, 16(s0)
642 ; RV32ID-ILP32D-NEXT: lw ra, 12(sp) # 4-byte Folded Reload
643 ; RV32ID-ILP32D-NEXT: lw s0, 8(sp) # 4-byte Folded Reload
644 ; RV32ID-ILP32D-NEXT: addi sp, sp, 16
645 ; RV32ID-ILP32D-NEXT: ret
647 ; RV64ID-LP64D-LABEL: bfloat_store:
648 ; RV64ID-LP64D: # %bb.0:
649 ; RV64ID-LP64D-NEXT: addi sp, sp, -16
650 ; RV64ID-LP64D-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
651 ; RV64ID-LP64D-NEXT: sd s0, 0(sp) # 8-byte Folded Spill
652 ; RV64ID-LP64D-NEXT: mv s0, a0
653 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
654 ; RV64ID-LP64D-NEXT: lui a1, 16
655 ; RV64ID-LP64D-NEXT: addi a1, a1, -1
656 ; RV64ID-LP64D-NEXT: and a0, a0, a1
657 ; RV64ID-LP64D-NEXT: fmv.x.w a2, fa1
658 ; RV64ID-LP64D-NEXT: and a1, a2, a1
659 ; RV64ID-LP64D-NEXT: slli a1, a1, 16
660 ; RV64ID-LP64D-NEXT: fmv.w.x fa5, a1
661 ; RV64ID-LP64D-NEXT: slli a0, a0, 16
662 ; RV64ID-LP64D-NEXT: fmv.w.x fa4, a0
663 ; RV64ID-LP64D-NEXT: fadd.s fa0, fa4, fa5
664 ; RV64ID-LP64D-NEXT: call __truncsfbf2@plt
665 ; RV64ID-LP64D-NEXT: fmv.x.w a0, fa0
666 ; RV64ID-LP64D-NEXT: sh a0, 0(s0)
667 ; RV64ID-LP64D-NEXT: sh a0, 16(s0)
668 ; RV64ID-LP64D-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
669 ; RV64ID-LP64D-NEXT: ld s0, 0(sp) # 8-byte Folded Reload
670 ; RV64ID-LP64D-NEXT: addi sp, sp, 16
671 ; RV64ID-LP64D-NEXT: ret
672 %1 = fadd bfloat %b, %c
673 store bfloat %1, ptr %a
674 %2 = getelementptr bfloat, ptr %a, i32 8
675 store bfloat %1, ptr %2