1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+d,+zfh,+zvfh,+v -target-abi=ilp32d \
3 ; RUN: -verify-machineinstrs < %s | FileCheck %s \
4 ; RUN: --check-prefixes=CHECK,RV32-FP
5 ; RUN: llc -mtriple=riscv64 -mattr=+d,+zfh,+zvfh,+v -target-abi=lp64d \
6 ; RUN: -verify-machineinstrs < %s | FileCheck %s \
7 ; RUN: --check-prefixes=CHECK,RV64-FP
9 define i16 @bitcast_v1f16_i16(<1 x half> %a) {
10 ; CHECK-LABEL: bitcast_v1f16_i16:
12 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
13 ; CHECK-NEXT: vmv.x.s a0, v8
15 %b = bitcast <1 x half> %a to i16
19 define half @bitcast_v1f16_f16(<1 x half> %a) {
20 ; CHECK-LABEL: bitcast_v1f16_f16:
22 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
23 ; CHECK-NEXT: vfmv.f.s fa0, v8
25 %b = bitcast <1 x half> %a to half
29 define i32 @bitcast_v2f16_i32(<2 x half> %a) {
30 ; CHECK-LABEL: bitcast_v2f16_i32:
32 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
33 ; CHECK-NEXT: vmv.x.s a0, v8
35 %b = bitcast <2 x half> %a to i32
39 define i32 @bitcast_v1f32_i32(<1 x float> %a) {
40 ; CHECK-LABEL: bitcast_v1f32_i32:
42 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
43 ; CHECK-NEXT: vmv.x.s a0, v8
45 %b = bitcast <1 x float> %a to i32
49 define float @bitcast_v2f16_f32(<2 x half> %a) {
50 ; CHECK-LABEL: bitcast_v2f16_f32:
52 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
53 ; CHECK-NEXT: vfmv.f.s fa0, v8
55 %b = bitcast <2 x half> %a to float
59 define float @bitcast_v1f32_f32(<1 x float> %a) {
60 ; CHECK-LABEL: bitcast_v1f32_f32:
62 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
63 ; CHECK-NEXT: vfmv.f.s fa0, v8
65 %b = bitcast <1 x float> %a to float
69 define i64 @bitcast_v4f16_i64(<4 x half> %a) {
70 ; RV32-FP-LABEL: bitcast_v4f16_i64:
72 ; RV32-FP-NEXT: li a0, 32
73 ; RV32-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
74 ; RV32-FP-NEXT: vsrl.vx v9, v8, a0
75 ; RV32-FP-NEXT: vmv.x.s a1, v9
76 ; RV32-FP-NEXT: vmv.x.s a0, v8
79 ; RV64-FP-LABEL: bitcast_v4f16_i64:
81 ; RV64-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
82 ; RV64-FP-NEXT: vmv.x.s a0, v8
84 %b = bitcast <4 x half> %a to i64
88 define i64 @bitcast_v2f32_i64(<2 x float> %a) {
89 ; RV32-FP-LABEL: bitcast_v2f32_i64:
91 ; RV32-FP-NEXT: li a0, 32
92 ; RV32-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
93 ; RV32-FP-NEXT: vsrl.vx v9, v8, a0
94 ; RV32-FP-NEXT: vmv.x.s a1, v9
95 ; RV32-FP-NEXT: vmv.x.s a0, v8
98 ; RV64-FP-LABEL: bitcast_v2f32_i64:
100 ; RV64-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
101 ; RV64-FP-NEXT: vmv.x.s a0, v8
103 %b = bitcast <2 x float> %a to i64
107 define i64 @bitcast_v1f64_i64(<1 x double> %a) {
108 ; RV32-FP-LABEL: bitcast_v1f64_i64:
110 ; RV32-FP-NEXT: li a0, 32
111 ; RV32-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
112 ; RV32-FP-NEXT: vsrl.vx v9, v8, a0
113 ; RV32-FP-NEXT: vmv.x.s a1, v9
114 ; RV32-FP-NEXT: vmv.x.s a0, v8
117 ; RV64-FP-LABEL: bitcast_v1f64_i64:
119 ; RV64-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
120 ; RV64-FP-NEXT: vmv.x.s a0, v8
122 %b = bitcast <1 x double> %a to i64
126 define double @bitcast_v4f16_f64(<4 x half> %a) {
127 ; CHECK-LABEL: bitcast_v4f16_f64:
129 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
130 ; CHECK-NEXT: vfmv.f.s fa0, v8
132 %b = bitcast <4 x half> %a to double
136 define double @bitcast_v2f32_f64(<2 x float> %a) {
137 ; CHECK-LABEL: bitcast_v2f32_f64:
139 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
140 ; CHECK-NEXT: vfmv.f.s fa0, v8
142 %b = bitcast <2 x float> %a to double
146 define double @bitcast_v1f64_f64(<1 x double> %a) {
147 ; CHECK-LABEL: bitcast_v1f64_f64:
149 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
150 ; CHECK-NEXT: vfmv.f.s fa0, v8
152 %b = bitcast <1 x double> %a to double
156 define <1 x half> @bitcast_i16_v1f16(i16 %a) {
157 ; CHECK-LABEL: bitcast_i16_v1f16:
159 ; CHECK-NEXT: vsetivli zero, 1, e16, m1, ta, ma
160 ; CHECK-NEXT: vmv.s.x v8, a0
162 %b = bitcast i16 %a to <1 x half>
166 define <2 x half> @bitcast_i32_v2f16(i32 %a) {
167 ; CHECK-LABEL: bitcast_i32_v2f16:
169 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
170 ; CHECK-NEXT: vmv.s.x v8, a0
172 %b = bitcast i32 %a to <2 x half>
176 define <1 x float> @bitcast_i32_v1f32(i32 %a) {
177 ; CHECK-LABEL: bitcast_i32_v1f32:
179 ; CHECK-NEXT: vsetivli zero, 1, e32, m1, ta, ma
180 ; CHECK-NEXT: vmv.s.x v8, a0
182 %b = bitcast i32 %a to <1 x float>
186 define <4 x half> @bitcast_i64_v4f16(i64 %a) {
187 ; RV32-FP-LABEL: bitcast_i64_v4f16:
189 ; RV32-FP-NEXT: vsetivli zero, 2, e32, m1, ta, ma
190 ; RV32-FP-NEXT: vslide1down.vx v8, v8, a0
191 ; RV32-FP-NEXT: vslide1down.vx v8, v8, a1
194 ; RV64-FP-LABEL: bitcast_i64_v4f16:
196 ; RV64-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
197 ; RV64-FP-NEXT: vmv.s.x v8, a0
199 %b = bitcast i64 %a to <4 x half>
203 define <2 x float> @bitcast_i64_v2f32(i64 %a) {
204 ; RV32-FP-LABEL: bitcast_i64_v2f32:
206 ; RV32-FP-NEXT: vsetivli zero, 2, e32, m1, ta, ma
207 ; RV32-FP-NEXT: vslide1down.vx v8, v8, a0
208 ; RV32-FP-NEXT: vslide1down.vx v8, v8, a1
211 ; RV64-FP-LABEL: bitcast_i64_v2f32:
213 ; RV64-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
214 ; RV64-FP-NEXT: vmv.s.x v8, a0
216 %b = bitcast i64 %a to <2 x float>
220 define <1 x double> @bitcast_i64_v1f64(i64 %a) {
221 ; RV32-FP-LABEL: bitcast_i64_v1f64:
223 ; RV32-FP-NEXT: vsetivli zero, 2, e32, m1, ta, ma
224 ; RV32-FP-NEXT: vslide1down.vx v8, v8, a0
225 ; RV32-FP-NEXT: vslide1down.vx v8, v8, a1
228 ; RV64-FP-LABEL: bitcast_i64_v1f64:
230 ; RV64-FP-NEXT: vsetivli zero, 1, e64, m1, ta, ma
231 ; RV64-FP-NEXT: vmv.s.x v8, a0
233 %b = bitcast i64 %a to <1 x double>
237 define <1 x i16> @bitcast_f16_v1i16(half %a) {
238 ; CHECK-LABEL: bitcast_f16_v1i16:
240 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
241 ; CHECK-NEXT: vfmv.s.f v8, fa0
243 %b = bitcast half %a to <1 x i16>
247 define <1 x half> @bitcast_f16_v1f16(half %a) {
248 ; CHECK-LABEL: bitcast_f16_v1f16:
250 ; CHECK-NEXT: vsetivli zero, 1, e16, mf4, ta, ma
251 ; CHECK-NEXT: vfmv.s.f v8, fa0
253 %b = bitcast half %a to <1 x half>
257 define <2 x i16> @bitcast_f32_v2i16(float %a) {
258 ; CHECK-LABEL: bitcast_f32_v2i16:
260 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
261 ; CHECK-NEXT: vfmv.s.f v8, fa0
263 %b = bitcast float %a to <2 x i16>
267 define <2 x half> @bitcast_f32_v2f16(float %a) {
268 ; CHECK-LABEL: bitcast_f32_v2f16:
270 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
271 ; CHECK-NEXT: vfmv.s.f v8, fa0
273 %b = bitcast float %a to <2 x half>
277 define <1 x i32> @bitcast_f32_v1i32(float %a) {
278 ; CHECK-LABEL: bitcast_f32_v1i32:
280 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
281 ; CHECK-NEXT: vfmv.s.f v8, fa0
283 %b = bitcast float %a to <1 x i32>
287 define <1 x float> @bitcast_f32_v1f32(float %a) {
288 ; CHECK-LABEL: bitcast_f32_v1f32:
290 ; CHECK-NEXT: vsetivli zero, 1, e32, mf2, ta, ma
291 ; CHECK-NEXT: vfmv.s.f v8, fa0
293 %b = bitcast float %a to <1 x float>
297 define <4 x i16> @bitcast_f64_v4i16(double %a) {
298 ; CHECK-LABEL: bitcast_f64_v4i16:
300 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
301 ; CHECK-NEXT: vfmv.s.f v8, fa0
303 %b = bitcast double %a to <4 x i16>
307 define <4 x half> @bitcast_f64_v4f16(double %a) {
308 ; CHECK-LABEL: bitcast_f64_v4f16:
310 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
311 ; CHECK-NEXT: vfmv.s.f v8, fa0
313 %b = bitcast double %a to <4 x half>
317 define <2 x i32> @bitcast_f64_v2i32(double %a) {
318 ; CHECK-LABEL: bitcast_f64_v2i32:
320 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
321 ; CHECK-NEXT: vfmv.s.f v8, fa0
323 %b = bitcast double %a to <2 x i32>
327 define <2 x float> @bitcast_f64_v2f32(double %a) {
328 ; CHECK-LABEL: bitcast_f64_v2f32:
330 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
331 ; CHECK-NEXT: vfmv.s.f v8, fa0
333 %b = bitcast double %a to <2 x float>
337 define <1 x i64> @bitcast_f64_v1i64(double %a) {
338 ; CHECK-LABEL: bitcast_f64_v1i64:
340 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
341 ; CHECK-NEXT: vfmv.s.f v8, fa0
343 %b = bitcast double %a to <1 x i64>
347 define <1 x double> @bitcast_f64_v1f64(double %a) {
348 ; CHECK-LABEL: bitcast_f64_v1f64:
350 ; CHECK-NEXT: vsetivli zero, 1, e64, m1, ta, ma
351 ; CHECK-NEXT: vfmv.s.f v8, fa0
353 %b = bitcast double %a to <1 x double>