1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=4 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX4
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=4 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX4
4 ; RUN: llc -mtriple=riscv32 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX1
5 ; RUN: llc -mtriple=riscv64 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX1
7 define void @gather_const_v16i8(ptr %x) {
8 ; CHECK-LABEL: gather_const_v16i8:
10 ; CHECK-NEXT: addi a1, a0, 12
11 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
12 ; CHECK-NEXT: vlse8.v v8, (a1), zero
13 ; CHECK-NEXT: vse8.v v8, (a0)
15 %a = load <16 x i8>, ptr %x
16 %b = extractelement <16 x i8> %a, i32 12
17 %c = insertelement <16 x i8> poison, i8 %b, i32 0
18 %d = shufflevector <16 x i8> %c, <16 x i8> poison, <16 x i32> zeroinitializer
19 store <16 x i8> %d, ptr %x
23 define void @gather_const_v8i16(ptr %x) {
24 ; CHECK-LABEL: gather_const_v8i16:
26 ; CHECK-NEXT: addi a1, a0, 10
27 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
28 ; CHECK-NEXT: vlse16.v v8, (a1), zero
29 ; CHECK-NEXT: vse16.v v8, (a0)
31 %a = load <8 x i16>, ptr %x
32 %b = extractelement <8 x i16> %a, i32 5
33 %c = insertelement <8 x i16> poison, i16 %b, i32 0
34 %d = shufflevector <8 x i16> %c, <8 x i16> poison, <8 x i32> zeroinitializer
35 store <8 x i16> %d, ptr %x
39 define void @gather_const_v4i32(ptr %x) {
40 ; CHECK-LABEL: gather_const_v4i32:
42 ; CHECK-NEXT: addi a1, a0, 12
43 ; CHECK-NEXT: vsetivli zero, 4, e32, m1, ta, ma
44 ; CHECK-NEXT: vlse32.v v8, (a1), zero
45 ; CHECK-NEXT: vse32.v v8, (a0)
47 %a = load <4 x i32>, ptr %x
48 %b = extractelement <4 x i32> %a, i32 3
49 %c = insertelement <4 x i32> poison, i32 %b, i32 0
50 %d = shufflevector <4 x i32> %c, <4 x i32> poison, <4 x i32> zeroinitializer
51 store <4 x i32> %d, ptr %x
55 define void @gather_const_v2i64(ptr %x) {
56 ; CHECK-LABEL: gather_const_v2i64:
58 ; CHECK-NEXT: addi a1, a0, 8
59 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
60 ; CHECK-NEXT: vlse64.v v8, (a1), zero
61 ; CHECK-NEXT: vse64.v v8, (a0)
63 %a = load <2 x i64>, ptr %x
64 %b = extractelement <2 x i64> %a, i32 1
65 %c = insertelement <2 x i64> poison, i64 %b, i32 0
66 %d = shufflevector <2 x i64> %c, <2 x i64> poison, <2 x i32> zeroinitializer
67 store <2 x i64> %d, ptr %x
71 define void @gather_const_v64i8(ptr %x) {
72 ; LMULMAX4-LABEL: gather_const_v64i8:
74 ; LMULMAX4-NEXT: li a1, 64
75 ; LMULMAX4-NEXT: addi a2, a0, 32
76 ; LMULMAX4-NEXT: vsetvli zero, a1, e8, m4, ta, ma
77 ; LMULMAX4-NEXT: vlse8.v v8, (a2), zero
78 ; LMULMAX4-NEXT: vse8.v v8, (a0)
81 ; LMULMAX1-LABEL: gather_const_v64i8:
83 ; LMULMAX1-NEXT: addi a1, a0, 32
84 ; LMULMAX1-NEXT: vsetivli zero, 16, e8, m1, ta, ma
85 ; LMULMAX1-NEXT: vlse8.v v8, (a1), zero
86 ; LMULMAX1-NEXT: addi a2, a0, 16
87 ; LMULMAX1-NEXT: addi a3, a0, 48
88 ; LMULMAX1-NEXT: vse8.v v8, (a1)
89 ; LMULMAX1-NEXT: vse8.v v8, (a3)
90 ; LMULMAX1-NEXT: vse8.v v8, (a0)
91 ; LMULMAX1-NEXT: vse8.v v8, (a2)
93 %a = load <64 x i8>, ptr %x
94 %b = extractelement <64 x i8> %a, i32 32
95 %c = insertelement <64 x i8> poison, i8 %b, i32 0
96 %d = shufflevector <64 x i8> %c, <64 x i8> poison, <64 x i32> zeroinitializer
97 store <64 x i8> %d, ptr %x
101 define void @gather_const_v16i16(ptr %x) {
102 ; LMULMAX4-LABEL: gather_const_v16i16:
104 ; LMULMAX4-NEXT: li a1, 32
105 ; LMULMAX4-NEXT: addi a2, a0, 50
106 ; LMULMAX4-NEXT: vsetvli zero, a1, e16, m4, ta, ma
107 ; LMULMAX4-NEXT: vlse16.v v8, (a2), zero
108 ; LMULMAX4-NEXT: vse16.v v8, (a0)
111 ; LMULMAX1-LABEL: gather_const_v16i16:
113 ; LMULMAX1-NEXT: addi a1, a0, 50
114 ; LMULMAX1-NEXT: vsetivli zero, 8, e16, m1, ta, ma
115 ; LMULMAX1-NEXT: vlse16.v v8, (a1), zero
116 ; LMULMAX1-NEXT: addi a1, a0, 48
117 ; LMULMAX1-NEXT: addi a2, a0, 16
118 ; LMULMAX1-NEXT: addi a3, a0, 32
119 ; LMULMAX1-NEXT: vse16.v v8, (a3)
120 ; LMULMAX1-NEXT: vse16.v v8, (a1)
121 ; LMULMAX1-NEXT: vse16.v v8, (a0)
122 ; LMULMAX1-NEXT: vse16.v v8, (a2)
124 %a = load <32 x i16>, ptr %x
125 %b = extractelement <32 x i16> %a, i32 25
126 %c = insertelement <32 x i16> poison, i16 %b, i32 0
127 %d = shufflevector <32 x i16> %c, <32 x i16> poison, <32 x i32> zeroinitializer
128 store <32 x i16> %d, ptr %x
132 define void @gather_const_v16i32(ptr %x) {
133 ; LMULMAX4-LABEL: gather_const_v16i32:
135 ; LMULMAX4-NEXT: addi a1, a0, 36
136 ; LMULMAX4-NEXT: vsetivli zero, 16, e32, m4, ta, ma
137 ; LMULMAX4-NEXT: vlse32.v v8, (a1), zero
138 ; LMULMAX4-NEXT: vse32.v v8, (a0)
141 ; LMULMAX1-LABEL: gather_const_v16i32:
143 ; LMULMAX1-NEXT: addi a1, a0, 36
144 ; LMULMAX1-NEXT: vsetivli zero, 4, e32, m1, ta, ma
145 ; LMULMAX1-NEXT: vlse32.v v8, (a1), zero
146 ; LMULMAX1-NEXT: addi a1, a0, 32
147 ; LMULMAX1-NEXT: addi a2, a0, 16
148 ; LMULMAX1-NEXT: addi a3, a0, 48
149 ; LMULMAX1-NEXT: vse32.v v8, (a1)
150 ; LMULMAX1-NEXT: vse32.v v8, (a3)
151 ; LMULMAX1-NEXT: vse32.v v8, (a0)
152 ; LMULMAX1-NEXT: vse32.v v8, (a2)
154 %a = load <16 x i32>, ptr %x
155 %b = extractelement <16 x i32> %a, i32 9
156 %c = insertelement <16 x i32> poison, i32 %b, i32 0
157 %d = shufflevector <16 x i32> %c, <16 x i32> poison, <16 x i32> zeroinitializer
158 store <16 x i32> %d, ptr %x
162 define void @gather_const_v8i64(ptr %x) {
163 ; LMULMAX4-LABEL: gather_const_v8i64:
165 ; LMULMAX4-NEXT: addi a1, a0, 24
166 ; LMULMAX4-NEXT: vsetivli zero, 8, e64, m4, ta, ma
167 ; LMULMAX4-NEXT: vlse64.v v8, (a1), zero
168 ; LMULMAX4-NEXT: vse64.v v8, (a0)
171 ; LMULMAX1-LABEL: gather_const_v8i64:
173 ; LMULMAX1-NEXT: addi a1, a0, 24
174 ; LMULMAX1-NEXT: vsetivli zero, 2, e64, m1, ta, ma
175 ; LMULMAX1-NEXT: vlse64.v v8, (a1), zero
176 ; LMULMAX1-NEXT: addi a1, a0, 16
177 ; LMULMAX1-NEXT: addi a2, a0, 48
178 ; LMULMAX1-NEXT: addi a3, a0, 32
179 ; LMULMAX1-NEXT: vse64.v v8, (a3)
180 ; LMULMAX1-NEXT: vse64.v v8, (a2)
181 ; LMULMAX1-NEXT: vse64.v v8, (a0)
182 ; LMULMAX1-NEXT: vse64.v v8, (a1)
184 %a = load <8 x i64>, ptr %x
185 %b = extractelement <8 x i64> %a, i32 3
186 %c = insertelement <8 x i64> poison, i64 %b, i32 0
187 %d = shufflevector <8 x i64> %c, <8 x i64> poison, <8 x i32> zeroinitializer
188 store <8 x i64> %d, ptr %x
192 define void @splat_concat_low(ptr %x, ptr %y, ptr %z) {
193 ; CHECK-LABEL: splat_concat_low:
195 ; CHECK-NEXT: addi a0, a0, 2
196 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
197 ; CHECK-NEXT: vlse16.v v8, (a0), zero
198 ; CHECK-NEXT: vse16.v v8, (a2)
200 %a = load <4 x i16>, ptr %x
201 %b = load <4 x i16>, ptr %y
202 %c = shufflevector <4 x i16> %a, <4 x i16> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
203 %d = shufflevector <8 x i16> %c, <8 x i16> poison, <8 x i32> <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
204 store <8 x i16> %d, ptr %z
208 define void @splat_concat_high(ptr %x, ptr %y, ptr %z) {
209 ; CHECK-LABEL: splat_concat_high:
211 ; CHECK-NEXT: addi a1, a1, 2
212 ; CHECK-NEXT: vsetivli zero, 8, e16, m1, ta, ma
213 ; CHECK-NEXT: vlse16.v v8, (a1), zero
214 ; CHECK-NEXT: vse16.v v8, (a2)
216 %a = load <4 x i16>, ptr %x
217 %b = load <4 x i16>, ptr %y
218 %c = shufflevector <4 x i16> %a, <4 x i16> %b, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
219 %d = shufflevector <8 x i16> %c, <8 x i16> poison, <8 x i32> <i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5, i32 5>
220 store <8 x i16> %d, ptr %z