1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV32
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s --check-prefixes=CHECK,RV64
5 define void @splat_ones_v1i1(ptr %x) {
6 ; CHECK-LABEL: splat_ones_v1i1:
9 ; CHECK-NEXT: sb a1, 0(a0)
11 store <1 x i1> <i1 1>, ptr %x
15 define void @splat_zeros_v2i1(ptr %x) {
16 ; CHECK-LABEL: splat_zeros_v2i1:
18 ; CHECK-NEXT: sb zero, 0(a0)
20 store <2 x i1> zeroinitializer, ptr %x
24 define void @splat_v1i1(ptr %x, i1 %y) {
25 ; CHECK-LABEL: splat_v1i1:
27 ; CHECK-NEXT: andi a1, a1, 1
28 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
29 ; CHECK-NEXT: vmv.s.x v8, a1
30 ; CHECK-NEXT: vmsne.vi v0, v8, 0
31 ; CHECK-NEXT: vmv.s.x v8, zero
32 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
33 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
34 ; CHECK-NEXT: vmv.v.i v9, 0
35 ; CHECK-NEXT: vsetivli zero, 1, e8, mf2, tu, ma
36 ; CHECK-NEXT: vmv.v.v v9, v8
37 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
38 ; CHECK-NEXT: vmsne.vi v8, v9, 0
39 ; CHECK-NEXT: vsm.v v8, (a0)
41 %a = insertelement <1 x i1> poison, i1 %y, i32 0
42 %b = shufflevector <1 x i1> %a, <1 x i1> poison, <1 x i32> zeroinitializer
43 store <1 x i1> %b, ptr %x
47 define void @splat_v1i1_icmp(ptr %x, i32 signext %y, i32 signext %z) {
48 ; CHECK-LABEL: splat_v1i1_icmp:
50 ; CHECK-NEXT: xor a1, a1, a2
51 ; CHECK-NEXT: seqz a1, a1
52 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
53 ; CHECK-NEXT: vmv.s.x v8, a1
54 ; CHECK-NEXT: vmsne.vi v0, v8, 0
55 ; CHECK-NEXT: vmv.s.x v8, zero
56 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
57 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
58 ; CHECK-NEXT: vmv.v.i v9, 0
59 ; CHECK-NEXT: vsetivli zero, 1, e8, mf2, tu, ma
60 ; CHECK-NEXT: vmv.v.v v9, v8
61 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
62 ; CHECK-NEXT: vmsne.vi v8, v9, 0
63 ; CHECK-NEXT: vsm.v v8, (a0)
65 %c = icmp eq i32 %y, %z
66 %a = insertelement <1 x i1> poison, i1 %c, i32 0
67 %b = shufflevector <1 x i1> %a, <1 x i1> poison, <1 x i32> zeroinitializer
68 store <1 x i1> %b, ptr %x
72 define void @splat_ones_v4i1(ptr %x) {
73 ; CHECK-LABEL: splat_ones_v4i1:
75 ; CHECK-NEXT: li a1, 15
76 ; CHECK-NEXT: sb a1, 0(a0)
78 store <4 x i1> <i1 1, i1 1, i1 1, i1 1>, ptr %x
82 define void @splat_v4i1(ptr %x, i1 %y) {
83 ; CHECK-LABEL: splat_v4i1:
85 ; CHECK-NEXT: andi a1, a1, 1
86 ; CHECK-NEXT: vsetivli zero, 4, e8, mf4, ta, ma
87 ; CHECK-NEXT: vmv.v.x v8, a1
88 ; CHECK-NEXT: vmsne.vi v0, v8, 0
89 ; CHECK-NEXT: vmv.v.i v8, 0
90 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
91 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
92 ; CHECK-NEXT: vmv.v.i v9, 0
93 ; CHECK-NEXT: vsetivli zero, 4, e8, mf2, tu, ma
94 ; CHECK-NEXT: vmv.v.v v9, v8
95 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
96 ; CHECK-NEXT: vmsne.vi v8, v9, 0
97 ; CHECK-NEXT: vsm.v v8, (a0)
99 %a = insertelement <4 x i1> poison, i1 %y, i32 0
100 %b = shufflevector <4 x i1> %a, <4 x i1> poison, <4 x i32> zeroinitializer
101 store <4 x i1> %b, ptr %x
105 define void @splat_zeros_v8i1(ptr %x) {
106 ; CHECK-LABEL: splat_zeros_v8i1:
108 ; CHECK-NEXT: sb zero, 0(a0)
110 store <8 x i1> zeroinitializer, ptr %x
114 define void @splat_v8i1(ptr %x, i1 %y) {
115 ; CHECK-LABEL: splat_v8i1:
117 ; CHECK-NEXT: andi a1, a1, 1
118 ; CHECK-NEXT: vsetivli zero, 8, e8, mf2, ta, ma
119 ; CHECK-NEXT: vmv.v.x v8, a1
120 ; CHECK-NEXT: vmsne.vi v8, v8, 0
121 ; CHECK-NEXT: vsm.v v8, (a0)
123 %a = insertelement <8 x i1> poison, i1 %y, i32 0
124 %b = shufflevector <8 x i1> %a, <8 x i1> poison, <8 x i32> zeroinitializer
125 store <8 x i1> %b, ptr %x
129 define void @splat_ones_v16i1(ptr %x) {
130 ; CHECK-LABEL: splat_ones_v16i1:
132 ; CHECK-NEXT: li a1, -1
133 ; CHECK-NEXT: sh a1, 0(a0)
135 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
139 define void @splat_v16i1(ptr %x, i1 %y) {
140 ; CHECK-LABEL: splat_v16i1:
142 ; CHECK-NEXT: andi a1, a1, 1
143 ; CHECK-NEXT: vsetivli zero, 16, e8, m1, ta, ma
144 ; CHECK-NEXT: vmv.v.x v8, a1
145 ; CHECK-NEXT: vmsne.vi v8, v8, 0
146 ; CHECK-NEXT: vsm.v v8, (a0)
148 %a = insertelement <16 x i1> poison, i1 %y, i32 0
149 %b = shufflevector <16 x i1> %a, <16 x i1> poison, <16 x i32> zeroinitializer
150 store <16 x i1> %b, ptr %x
154 define void @splat_zeros_v32i1(ptr %x) {
155 ; CHECK-LABEL: splat_zeros_v32i1:
157 ; CHECK-NEXT: sw zero, 0(a0)
159 store <32 x i1> zeroinitializer, ptr %x
163 define void @splat_v32i1(ptr %x, i1 %y) {
164 ; CHECK-LABEL: splat_v32i1:
166 ; CHECK-NEXT: andi a1, a1, 1
167 ; CHECK-NEXT: li a2, 32
168 ; CHECK-NEXT: vsetvli zero, a2, e8, m2, ta, ma
169 ; CHECK-NEXT: vmv.v.x v8, a1
170 ; CHECK-NEXT: vmsne.vi v10, v8, 0
171 ; CHECK-NEXT: vsm.v v10, (a0)
173 %a = insertelement <32 x i1> poison, i1 %y, i32 0
174 %b = shufflevector <32 x i1> %a, <32 x i1> poison, <32 x i32> zeroinitializer
175 store <32 x i1> %b, ptr %x
179 define void @splat_ones_v64i1(ptr %x) {
180 ; RV32-LABEL: splat_ones_v64i1:
182 ; RV32-NEXT: li a1, 64
183 ; RV32-NEXT: vsetvli zero, a1, e8, m4, ta, ma
184 ; RV32-NEXT: vmset.m v8
185 ; RV32-NEXT: vsm.v v8, (a0)
188 ; RV64-LABEL: splat_ones_v64i1:
190 ; RV64-NEXT: li a1, -1
191 ; RV64-NEXT: sd a1, 0(a0)
193 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
197 define void @splat_v64i1(ptr %x, i1 %y) {
198 ; CHECK-LABEL: splat_v64i1:
200 ; CHECK-NEXT: andi a1, a1, 1
201 ; CHECK-NEXT: li a2, 64
202 ; CHECK-NEXT: vsetvli zero, a2, e8, m4, ta, ma
203 ; CHECK-NEXT: vmv.v.x v8, a1
204 ; CHECK-NEXT: vmsne.vi v12, v8, 0
205 ; CHECK-NEXT: vsm.v v12, (a0)
207 %a = insertelement <64 x i1> poison, i1 %y, i32 0
208 %b = shufflevector <64 x i1> %a, <64 x i1> poison, <64 x i32> zeroinitializer
209 store <64 x i1> %b, ptr %x