1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple riscv32 -mattr=+d,+zfh,+zvfh,+v < %s \
3 ; RUN: -verify-machineinstrs | FileCheck %s
4 ; RUN: llc -mtriple riscv64 -mattr=+d,+zfh,+zvfh,+v < %s \
5 ; RUN: -verify-machineinstrs | FileCheck %s
6 ; RUN: llc -mtriple riscv32 -mattr=+d,+zfh,+zvfh,+v,+unaligned-vector-mem < %s \
7 ; RUN: -verify-machineinstrs | FileCheck --check-prefix=FAST %s
8 ; RUN: llc -mtriple riscv64 -mattr=+d,+zfh,+zvfh,+v,+unaligned-vector-mem < %s \
9 ; RUN: -verify-machineinstrs | FileCheck --check-prefix=FAST %s
12 define <vscale x 1 x i32> @unaligned_load_nxv1i32_a1(ptr %ptr) {
13 ; CHECK-LABEL: unaligned_load_nxv1i32_a1:
15 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
16 ; CHECK-NEXT: vle8.v v8, (a0)
19 ; FAST-LABEL: unaligned_load_nxv1i32_a1:
21 ; FAST-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
22 ; FAST-NEXT: vle32.v v8, (a0)
24 %v = load <vscale x 1 x i32>, ptr %ptr, align 1
25 ret <vscale x 1 x i32> %v
28 define <vscale x 1 x i32> @unaligned_load_nxv1i32_a2(ptr %ptr) {
29 ; CHECK-LABEL: unaligned_load_nxv1i32_a2:
31 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
32 ; CHECK-NEXT: vle8.v v8, (a0)
35 ; FAST-LABEL: unaligned_load_nxv1i32_a2:
37 ; FAST-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
38 ; FAST-NEXT: vle32.v v8, (a0)
40 %v = load <vscale x 1 x i32>, ptr %ptr, align 2
41 ret <vscale x 1 x i32> %v
44 define <vscale x 1 x i32> @aligned_load_nxv1i32_a4(ptr %ptr) {
45 ; CHECK-LABEL: aligned_load_nxv1i32_a4:
47 ; CHECK-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
48 ; CHECK-NEXT: vle32.v v8, (a0)
51 ; FAST-LABEL: aligned_load_nxv1i32_a4:
53 ; FAST-NEXT: vsetvli a1, zero, e32, mf2, ta, ma
54 ; FAST-NEXT: vle32.v v8, (a0)
56 %v = load <vscale x 1 x i32>, ptr %ptr, align 4
57 ret <vscale x 1 x i32> %v
60 define <vscale x 1 x i64> @unaligned_load_nxv1i64_a1(ptr %ptr) {
61 ; CHECK-LABEL: unaligned_load_nxv1i64_a1:
63 ; CHECK-NEXT: vl1r.v v8, (a0)
66 ; FAST-LABEL: unaligned_load_nxv1i64_a1:
68 ; FAST-NEXT: vl1re64.v v8, (a0)
70 %v = load <vscale x 1 x i64>, ptr %ptr, align 1
71 ret <vscale x 1 x i64> %v
74 define <vscale x 1 x i64> @unaligned_load_nxv1i64_a4(ptr %ptr) {
75 ; CHECK-LABEL: unaligned_load_nxv1i64_a4:
77 ; CHECK-NEXT: vl1r.v v8, (a0)
80 ; FAST-LABEL: unaligned_load_nxv1i64_a4:
82 ; FAST-NEXT: vl1re64.v v8, (a0)
84 %v = load <vscale x 1 x i64>, ptr %ptr, align 4
85 ret <vscale x 1 x i64> %v
88 define <vscale x 1 x i64> @aligned_load_nxv1i64_a8(ptr %ptr) {
89 ; CHECK-LABEL: aligned_load_nxv1i64_a8:
91 ; CHECK-NEXT: vl1re64.v v8, (a0)
94 ; FAST-LABEL: aligned_load_nxv1i64_a8:
96 ; FAST-NEXT: vl1re64.v v8, (a0)
98 %v = load <vscale x 1 x i64>, ptr %ptr, align 8
99 ret <vscale x 1 x i64> %v
102 define <vscale x 2 x i64> @unaligned_load_nxv2i64_a1(ptr %ptr) {
103 ; CHECK-LABEL: unaligned_load_nxv2i64_a1:
105 ; CHECK-NEXT: vl2r.v v8, (a0)
108 ; FAST-LABEL: unaligned_load_nxv2i64_a1:
110 ; FAST-NEXT: vl2re64.v v8, (a0)
112 %v = load <vscale x 2 x i64>, ptr %ptr, align 1
113 ret <vscale x 2 x i64> %v
116 define <vscale x 2 x i64> @unaligned_load_nxv2i64_a4(ptr %ptr) {
117 ; CHECK-LABEL: unaligned_load_nxv2i64_a4:
119 ; CHECK-NEXT: vl2r.v v8, (a0)
122 ; FAST-LABEL: unaligned_load_nxv2i64_a4:
124 ; FAST-NEXT: vl2re64.v v8, (a0)
126 %v = load <vscale x 2 x i64>, ptr %ptr, align 4
127 ret <vscale x 2 x i64> %v
130 define <vscale x 2 x i64> @aligned_load_nxv2i64_a8(ptr %ptr) {
131 ; CHECK-LABEL: aligned_load_nxv2i64_a8:
133 ; CHECK-NEXT: vl2re64.v v8, (a0)
136 ; FAST-LABEL: aligned_load_nxv2i64_a8:
138 ; FAST-NEXT: vl2re64.v v8, (a0)
140 %v = load <vscale x 2 x i64>, ptr %ptr, align 8
141 ret <vscale x 2 x i64> %v
144 ; Masks should always be aligned
145 define <vscale x 1 x i1> @unaligned_load_nxv1i1_a1(ptr %ptr) {
146 ; CHECK-LABEL: unaligned_load_nxv1i1_a1:
148 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
149 ; CHECK-NEXT: vlm.v v0, (a0)
152 ; FAST-LABEL: unaligned_load_nxv1i1_a1:
154 ; FAST-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
155 ; FAST-NEXT: vlm.v v0, (a0)
157 %v = load <vscale x 1 x i1>, ptr %ptr, align 1
158 ret <vscale x 1 x i1> %v
161 define <vscale x 4 x float> @unaligned_load_nxv4f32_a1(ptr %ptr) {
162 ; CHECK-LABEL: unaligned_load_nxv4f32_a1:
164 ; CHECK-NEXT: vl2r.v v8, (a0)
167 ; FAST-LABEL: unaligned_load_nxv4f32_a1:
169 ; FAST-NEXT: vl2re32.v v8, (a0)
171 %v = load <vscale x 4 x float>, ptr %ptr, align 1
172 ret <vscale x 4 x float> %v
175 define <vscale x 4 x float> @unaligned_load_nxv4f32_a2(ptr %ptr) {
176 ; CHECK-LABEL: unaligned_load_nxv4f32_a2:
178 ; CHECK-NEXT: vl2r.v v8, (a0)
181 ; FAST-LABEL: unaligned_load_nxv4f32_a2:
183 ; FAST-NEXT: vl2re32.v v8, (a0)
185 %v = load <vscale x 4 x float>, ptr %ptr, align 2
186 ret <vscale x 4 x float> %v
189 define <vscale x 4 x float> @aligned_load_nxv4f32_a4(ptr %ptr) {
190 ; CHECK-LABEL: aligned_load_nxv4f32_a4:
192 ; CHECK-NEXT: vl2re32.v v8, (a0)
195 ; FAST-LABEL: aligned_load_nxv4f32_a4:
197 ; FAST-NEXT: vl2re32.v v8, (a0)
199 %v = load <vscale x 4 x float>, ptr %ptr, align 4
200 ret <vscale x 4 x float> %v
203 define <vscale x 8 x half> @unaligned_load_nxv8f16_a1(ptr %ptr) {
204 ; CHECK-LABEL: unaligned_load_nxv8f16_a1:
206 ; CHECK-NEXT: vl2r.v v8, (a0)
209 ; FAST-LABEL: unaligned_load_nxv8f16_a1:
211 ; FAST-NEXT: vl2re16.v v8, (a0)
213 %v = load <vscale x 8 x half>, ptr %ptr, align 1
214 ret <vscale x 8 x half> %v
217 define <vscale x 8 x half> @aligned_load_nxv8f16_a2(ptr %ptr) {
218 ; CHECK-LABEL: aligned_load_nxv8f16_a2:
220 ; CHECK-NEXT: vl2re16.v v8, (a0)
223 ; FAST-LABEL: aligned_load_nxv8f16_a2:
225 ; FAST-NEXT: vl2re16.v v8, (a0)
227 %v = load <vscale x 8 x half>, ptr %ptr, align 2
228 ret <vscale x 8 x half> %v
231 define void @unaligned_store_nxv4i32_a1(<vscale x 4 x i32> %x, ptr %ptr) {
232 ; CHECK-LABEL: unaligned_store_nxv4i32_a1:
234 ; CHECK-NEXT: vs2r.v v8, (a0)
237 ; FAST-LABEL: unaligned_store_nxv4i32_a1:
239 ; FAST-NEXT: vs2r.v v8, (a0)
241 store <vscale x 4 x i32> %x, ptr %ptr, align 1
245 define void @unaligned_store_nxv4i32_a2(<vscale x 4 x i32> %x, ptr %ptr) {
246 ; CHECK-LABEL: unaligned_store_nxv4i32_a2:
248 ; CHECK-NEXT: vs2r.v v8, (a0)
251 ; FAST-LABEL: unaligned_store_nxv4i32_a2:
253 ; FAST-NEXT: vs2r.v v8, (a0)
255 store <vscale x 4 x i32> %x, ptr %ptr, align 2
259 define void @aligned_store_nxv4i32_a4(<vscale x 4 x i32> %x, ptr %ptr) {
260 ; CHECK-LABEL: aligned_store_nxv4i32_a4:
262 ; CHECK-NEXT: vs2r.v v8, (a0)
265 ; FAST-LABEL: aligned_store_nxv4i32_a4:
267 ; FAST-NEXT: vs2r.v v8, (a0)
269 store <vscale x 4 x i32> %x, ptr %ptr, align 4
273 define void @unaligned_store_nxv1i16_a1(<vscale x 1 x i16> %x, ptr %ptr) {
274 ; CHECK-LABEL: unaligned_store_nxv1i16_a1:
276 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
277 ; CHECK-NEXT: vse8.v v8, (a0)
280 ; FAST-LABEL: unaligned_store_nxv1i16_a1:
282 ; FAST-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
283 ; FAST-NEXT: vse16.v v8, (a0)
285 store <vscale x 1 x i16> %x, ptr %ptr, align 1
289 define void @aligned_store_nxv1i16_a2(<vscale x 1 x i16> %x, ptr %ptr) {
290 ; CHECK-LABEL: aligned_store_nxv1i16_a2:
292 ; CHECK-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
293 ; CHECK-NEXT: vse16.v v8, (a0)
296 ; FAST-LABEL: aligned_store_nxv1i16_a2:
298 ; FAST-NEXT: vsetvli a1, zero, e16, mf4, ta, ma
299 ; FAST-NEXT: vse16.v v8, (a0)
301 store <vscale x 1 x i16> %x, ptr %ptr, align 2