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=2 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX2
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=2 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX2
4 ; RUN: llc -mtriple=riscv32 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX1-RV32
5 ; RUN: llc -mtriple=riscv64 -mattr=+v -riscv-v-fixed-length-vector-lmul-max=1 -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,LMULMAX1-RV64
7 define void @splat_ones_v1i1(ptr %x) {
8 ; CHECK-LABEL: splat_ones_v1i1:
10 ; CHECK-NEXT: li a1, 1
11 ; CHECK-NEXT: sb a1, 0(a0)
13 store <1 x i1> <i1 1>, ptr %x
17 define void @splat_zeros_v2i1(ptr %x) {
18 ; CHECK-LABEL: splat_zeros_v2i1:
20 ; CHECK-NEXT: sb zero, 0(a0)
22 store <2 x i1> zeroinitializer, ptr %x
26 define void @splat_v1i1(ptr %x, i1 %y) {
27 ; CHECK-LABEL: splat_v1i1:
29 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
30 ; CHECK-NEXT: andi a1, a1, 1
31 ; CHECK-NEXT: vmv.s.x v8, a1
32 ; CHECK-NEXT: vmsne.vi v0, v8, 0
33 ; CHECK-NEXT: vmv.s.x v8, zero
34 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
35 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
36 ; CHECK-NEXT: vmv.v.i v9, 0
37 ; CHECK-NEXT: vsetivli zero, 1, e8, mf2, tu, ma
38 ; CHECK-NEXT: vmv.v.v v9, v8
39 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
40 ; CHECK-NEXT: vmsne.vi v8, v9, 0
41 ; CHECK-NEXT: vsm.v v8, (a0)
43 %a = insertelement <1 x i1> poison, i1 %y, i32 0
44 %b = shufflevector <1 x i1> %a, <1 x i1> poison, <1 x i32> zeroinitializer
45 store <1 x i1> %b, ptr %x
49 define void @splat_v1i1_icmp(ptr %x, i32 signext %y, i32 signext %z) {
50 ; CHECK-LABEL: splat_v1i1_icmp:
52 ; CHECK-NEXT: xor a1, a1, a2
53 ; CHECK-NEXT: seqz a1, a1
54 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
55 ; CHECK-NEXT: vmv.s.x v8, a1
56 ; CHECK-NEXT: vmsne.vi v0, v8, 0
57 ; CHECK-NEXT: vmv.s.x v8, zero
58 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
59 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
60 ; CHECK-NEXT: vmv.v.i v9, 0
61 ; CHECK-NEXT: vsetivli zero, 1, e8, mf2, tu, ma
62 ; CHECK-NEXT: vmv.v.v v9, v8
63 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
64 ; CHECK-NEXT: vmsne.vi v8, v9, 0
65 ; CHECK-NEXT: vsm.v v8, (a0)
67 %c = icmp eq i32 %y, %z
68 %a = insertelement <1 x i1> poison, i1 %c, i32 0
69 %b = shufflevector <1 x i1> %a, <1 x i1> poison, <1 x i32> zeroinitializer
70 store <1 x i1> %b, ptr %x
74 define void @splat_ones_v4i1(ptr %x) {
75 ; CHECK-LABEL: splat_ones_v4i1:
77 ; CHECK-NEXT: li a1, 15
78 ; CHECK-NEXT: sb a1, 0(a0)
80 store <4 x i1> <i1 1, i1 1, i1 1, i1 1>, ptr %x
84 define void @splat_v4i1(ptr %x, i1 %y) {
85 ; CHECK-LABEL: splat_v4i1:
87 ; CHECK-NEXT: andi a1, a1, 1
88 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
89 ; CHECK-NEXT: vmv.v.x v8, a1
90 ; CHECK-NEXT: vmsne.vi v0, v8, 0
91 ; CHECK-NEXT: vmv.v.i v8, 0
92 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
93 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
94 ; CHECK-NEXT: vmv.v.i v9, 0
95 ; CHECK-NEXT: vsetivli zero, 4, e8, mf2, tu, ma
96 ; CHECK-NEXT: vmv.v.v v9, v8
97 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
98 ; CHECK-NEXT: vmsne.vi v8, v9, 0
99 ; CHECK-NEXT: vsm.v v8, (a0)
101 %a = insertelement <4 x i1> poison, i1 %y, i32 0
102 %b = shufflevector <4 x i1> %a, <4 x i1> poison, <4 x i32> zeroinitializer
103 store <4 x i1> %b, ptr %x
107 define void @splat_zeros_v8i1(ptr %x) {
108 ; CHECK-LABEL: splat_zeros_v8i1:
110 ; CHECK-NEXT: sb zero, 0(a0)
112 store <8 x i1> zeroinitializer, ptr %x
116 define void @splat_v8i1(ptr %x, i1 %y) {
117 ; CHECK-LABEL: splat_v8i1:
119 ; CHECK-NEXT: andi a1, a1, 1
120 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
121 ; CHECK-NEXT: vmv.v.x v8, a1
122 ; CHECK-NEXT: vmsne.vi v8, v8, 0
123 ; CHECK-NEXT: vsm.v v8, (a0)
125 %a = insertelement <8 x i1> poison, i1 %y, i32 0
126 %b = shufflevector <8 x i1> %a, <8 x i1> poison, <8 x i32> zeroinitializer
127 store <8 x i1> %b, ptr %x
131 define void @splat_ones_v16i1(ptr %x) {
132 ; CHECK-LABEL: splat_ones_v16i1:
134 ; CHECK-NEXT: li a1, -1
135 ; CHECK-NEXT: sh a1, 0(a0)
137 store <16 x i1> <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1>, ptr %x
141 define void @splat_v16i1(ptr %x, i1 %y) {
142 ; CHECK-LABEL: splat_v16i1:
144 ; CHECK-NEXT: andi a1, a1, 1
145 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
146 ; CHECK-NEXT: vmv.v.x v8, a1
147 ; CHECK-NEXT: vmsne.vi v8, v8, 0
148 ; CHECK-NEXT: vsm.v v8, (a0)
150 %a = insertelement <16 x i1> poison, i1 %y, i32 0
151 %b = shufflevector <16 x i1> %a, <16 x i1> poison, <16 x i32> zeroinitializer
152 store <16 x i1> %b, ptr %x
156 define void @splat_zeros_v32i1(ptr %x) {
157 ; CHECK-LABEL: splat_zeros_v32i1:
159 ; CHECK-NEXT: sw zero, 0(a0)
161 store <32 x i1> zeroinitializer, ptr %x
165 define void @splat_v32i1(ptr %x, i1 %y) {
166 ; LMULMAX2-LABEL: splat_v32i1:
168 ; LMULMAX2-NEXT: andi a1, a1, 1
169 ; LMULMAX2-NEXT: li a2, 32
170 ; LMULMAX2-NEXT: vsetvli zero, a2, e8, m2, ta, ma
171 ; LMULMAX2-NEXT: vmv.v.x v8, a1
172 ; LMULMAX2-NEXT: vmsne.vi v10, v8, 0
173 ; LMULMAX2-NEXT: vsm.v v10, (a0)
176 ; LMULMAX1-RV32-LABEL: splat_v32i1:
177 ; LMULMAX1-RV32: # %bb.0:
178 ; LMULMAX1-RV32-NEXT: andi a1, a1, 1
179 ; LMULMAX1-RV32-NEXT: vsetivli zero, 16, e8, m1, ta, ma
180 ; LMULMAX1-RV32-NEXT: vmv.v.x v8, a1
181 ; LMULMAX1-RV32-NEXT: vmsne.vi v8, v8, 0
182 ; LMULMAX1-RV32-NEXT: addi a1, a0, 2
183 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a1)
184 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a0)
185 ; LMULMAX1-RV32-NEXT: ret
187 ; LMULMAX1-RV64-LABEL: splat_v32i1:
188 ; LMULMAX1-RV64: # %bb.0:
189 ; LMULMAX1-RV64-NEXT: andi a1, a1, 1
190 ; LMULMAX1-RV64-NEXT: vsetivli zero, 16, e8, m1, ta, ma
191 ; LMULMAX1-RV64-NEXT: vmv.v.x v8, a1
192 ; LMULMAX1-RV64-NEXT: vmsne.vi v8, v8, 0
193 ; LMULMAX1-RV64-NEXT: addi a1, a0, 2
194 ; LMULMAX1-RV64-NEXT: vsm.v v8, (a1)
195 ; LMULMAX1-RV64-NEXT: vsm.v v8, (a0)
196 ; LMULMAX1-RV64-NEXT: ret
197 %a = insertelement <32 x i1> poison, i1 %y, i32 0
198 %b = shufflevector <32 x i1> %a, <32 x i1> poison, <32 x i32> zeroinitializer
199 store <32 x i1> %b, ptr %x
203 define void @splat_ones_v64i1(ptr %x) {
204 ; LMULMAX1-RV32-LABEL: splat_ones_v64i1:
205 ; LMULMAX1-RV32: # %bb.0:
206 ; LMULMAX1-RV32-NEXT: vsetivli zero, 16, e8, m1, ta, ma
207 ; LMULMAX1-RV32-NEXT: vmset.m v8
208 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a0)
209 ; LMULMAX1-RV32-NEXT: addi a1, a0, 6
210 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a1)
211 ; LMULMAX1-RV32-NEXT: addi a1, a0, 4
212 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a1)
213 ; LMULMAX1-RV32-NEXT: addi a0, a0, 2
214 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a0)
215 ; LMULMAX1-RV32-NEXT: ret
217 ; LMULMAX1-RV64-LABEL: splat_ones_v64i1:
218 ; LMULMAX1-RV64: # %bb.0:
219 ; LMULMAX1-RV64-NEXT: li a1, -1
220 ; LMULMAX1-RV64-NEXT: sd a1, 0(a0)
221 ; LMULMAX1-RV64-NEXT: ret
222 store <64 x i1> <i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1>, ptr %x
226 define void @splat_v64i1(ptr %x, i1 %y) {
227 ; LMULMAX2-LABEL: splat_v64i1:
229 ; LMULMAX2-NEXT: andi a1, a1, 1
230 ; LMULMAX2-NEXT: li a2, 32
231 ; LMULMAX2-NEXT: vsetvli zero, a2, e8, m2, ta, ma
232 ; LMULMAX2-NEXT: vmv.v.x v8, a1
233 ; LMULMAX2-NEXT: vmsne.vi v10, v8, 0
234 ; LMULMAX2-NEXT: addi a1, a0, 4
235 ; LMULMAX2-NEXT: vsm.v v10, (a1)
236 ; LMULMAX2-NEXT: vsm.v v10, (a0)
239 ; LMULMAX1-RV32-LABEL: splat_v64i1:
240 ; LMULMAX1-RV32: # %bb.0:
241 ; LMULMAX1-RV32-NEXT: andi a1, a1, 1
242 ; LMULMAX1-RV32-NEXT: vsetivli zero, 16, e8, m1, ta, ma
243 ; LMULMAX1-RV32-NEXT: vmv.v.x v8, a1
244 ; LMULMAX1-RV32-NEXT: vmsne.vi v8, v8, 0
245 ; LMULMAX1-RV32-NEXT: addi a1, a0, 6
246 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a1)
247 ; LMULMAX1-RV32-NEXT: addi a1, a0, 4
248 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a1)
249 ; LMULMAX1-RV32-NEXT: addi a1, a0, 2
250 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a1)
251 ; LMULMAX1-RV32-NEXT: vsm.v v8, (a0)
252 ; LMULMAX1-RV32-NEXT: ret
254 ; LMULMAX1-RV64-LABEL: splat_v64i1:
255 ; LMULMAX1-RV64: # %bb.0:
256 ; LMULMAX1-RV64-NEXT: andi a1, a1, 1
257 ; LMULMAX1-RV64-NEXT: vsetivli zero, 16, e8, m1, ta, ma
258 ; LMULMAX1-RV64-NEXT: vmv.v.x v8, a1
259 ; LMULMAX1-RV64-NEXT: vmsne.vi v8, v8, 0
260 ; LMULMAX1-RV64-NEXT: addi a1, a0, 6
261 ; LMULMAX1-RV64-NEXT: vsm.v v8, (a1)
262 ; LMULMAX1-RV64-NEXT: addi a1, a0, 4
263 ; LMULMAX1-RV64-NEXT: vsm.v v8, (a1)
264 ; LMULMAX1-RV64-NEXT: addi a1, a0, 2
265 ; LMULMAX1-RV64-NEXT: vsm.v v8, (a1)
266 ; LMULMAX1-RV64-NEXT: vsm.v v8, (a0)
267 ; LMULMAX1-RV64-NEXT: ret
268 %a = insertelement <64 x i1> poison, i1 %y, i32 0
269 %b = shufflevector <64 x i1> %a, <64 x i1> poison, <64 x i32> zeroinitializer
270 store <64 x i1> %b, ptr %x