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
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
5 define <vscale x 1 x i1> @insertelt_nxv1i1(<vscale x 1 x i1> %x, i1 %elt) {
6 ; CHECK-LABEL: insertelt_nxv1i1:
8 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
9 ; CHECK-NEXT: vmv.v.i v8, 0
10 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
11 ; CHECK-NEXT: vmv.s.x v9, a0
12 ; CHECK-NEXT: vsetivli zero, 3, e8, mf8, tu, ma
13 ; CHECK-NEXT: vslideup.vi v8, v9, 2
14 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
15 ; CHECK-NEXT: vand.vi v8, v8, 1
16 ; CHECK-NEXT: vmsne.vi v0, v8, 0
18 %y = insertelement <vscale x 1 x i1> %x, i1 %elt, i64 2
19 ret <vscale x 1 x i1> %y
22 define <vscale x 1 x i1> @insertelt_idx_nxv1i1(<vscale x 1 x i1> %x, i1 %elt, i64 %idx) {
23 ; CHECK-LABEL: insertelt_idx_nxv1i1:
25 ; CHECK-NEXT: vsetvli a2, zero, e8, mf8, ta, ma
26 ; CHECK-NEXT: vmv.v.i v8, 0
27 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
28 ; CHECK-NEXT: addi a2, a1, 1
29 ; CHECK-NEXT: vmv.s.x v9, a0
30 ; CHECK-NEXT: vsetvli zero, a2, e8, mf8, tu, ma
31 ; CHECK-NEXT: vslideup.vx v8, v9, a1
32 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
33 ; CHECK-NEXT: vand.vi v8, v8, 1
34 ; CHECK-NEXT: vmsne.vi v0, v8, 0
36 %y = insertelement <vscale x 1 x i1> %x, i1 %elt, i64 %idx
37 ret <vscale x 1 x i1> %y
40 define <vscale x 2 x i1> @insertelt_nxv2i1(<vscale x 2 x i1> %x, i1 %elt) {
41 ; CHECK-LABEL: insertelt_nxv2i1:
43 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
44 ; CHECK-NEXT: vmv.v.i v8, 0
45 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
46 ; CHECK-NEXT: vmv.s.x v9, a0
47 ; CHECK-NEXT: vsetivli zero, 3, e8, mf4, tu, ma
48 ; CHECK-NEXT: vslideup.vi v8, v9, 2
49 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
50 ; CHECK-NEXT: vand.vi v8, v8, 1
51 ; CHECK-NEXT: vmsne.vi v0, v8, 0
53 %y = insertelement <vscale x 2 x i1> %x, i1 %elt, i64 2
54 ret <vscale x 2 x i1> %y
57 define <vscale x 2 x i1> @insertelt_idx_nxv2i1(<vscale x 2 x i1> %x, i1 %elt, i64 %idx) {
58 ; CHECK-LABEL: insertelt_idx_nxv2i1:
60 ; CHECK-NEXT: vsetvli a2, zero, e8, mf4, ta, ma
61 ; CHECK-NEXT: vmv.v.i v8, 0
62 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
63 ; CHECK-NEXT: addi a2, a1, 1
64 ; CHECK-NEXT: vmv.s.x v9, a0
65 ; CHECK-NEXT: vsetvli zero, a2, e8, mf4, tu, ma
66 ; CHECK-NEXT: vslideup.vx v8, v9, a1
67 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
68 ; CHECK-NEXT: vand.vi v8, v8, 1
69 ; CHECK-NEXT: vmsne.vi v0, v8, 0
71 %y = insertelement <vscale x 2 x i1> %x, i1 %elt, i64 %idx
72 ret <vscale x 2 x i1> %y
75 define <vscale x 4 x i1> @insertelt_nxv4i1(<vscale x 4 x i1> %x, i1 %elt) {
76 ; CHECK-LABEL: insertelt_nxv4i1:
78 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
79 ; CHECK-NEXT: vmv.v.i v8, 0
80 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
81 ; CHECK-NEXT: vmv.s.x v9, a0
82 ; CHECK-NEXT: vsetivli zero, 3, e8, mf2, tu, ma
83 ; CHECK-NEXT: vslideup.vi v8, v9, 2
84 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
85 ; CHECK-NEXT: vand.vi v8, v8, 1
86 ; CHECK-NEXT: vmsne.vi v0, v8, 0
88 %y = insertelement <vscale x 4 x i1> %x, i1 %elt, i64 2
89 ret <vscale x 4 x i1> %y
92 define <vscale x 4 x i1> @insertelt_idx_nxv4i1(<vscale x 4 x i1> %x, i1 %elt, i64 %idx) {
93 ; CHECK-LABEL: insertelt_idx_nxv4i1:
95 ; CHECK-NEXT: vsetvli a2, zero, e8, mf2, ta, ma
96 ; CHECK-NEXT: vmv.v.i v8, 0
97 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
98 ; CHECK-NEXT: addi a2, a1, 1
99 ; CHECK-NEXT: vmv.s.x v9, a0
100 ; CHECK-NEXT: vsetvli zero, a2, e8, mf2, tu, ma
101 ; CHECK-NEXT: vslideup.vx v8, v9, a1
102 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
103 ; CHECK-NEXT: vand.vi v8, v8, 1
104 ; CHECK-NEXT: vmsne.vi v0, v8, 0
106 %y = insertelement <vscale x 4 x i1> %x, i1 %elt, i64 %idx
107 ret <vscale x 4 x i1> %y
110 define <vscale x 8 x i1> @insertelt_nxv8i1(<vscale x 8 x i1> %x, i1 %elt) {
111 ; CHECK-LABEL: insertelt_nxv8i1:
113 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
114 ; CHECK-NEXT: vmv.v.i v8, 0
115 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
116 ; CHECK-NEXT: vmv.s.x v9, a0
117 ; CHECK-NEXT: vsetivli zero, 3, e8, m1, tu, ma
118 ; CHECK-NEXT: vslideup.vi v8, v9, 2
119 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
120 ; CHECK-NEXT: vand.vi v8, v8, 1
121 ; CHECK-NEXT: vmsne.vi v0, v8, 0
123 %y = insertelement <vscale x 8 x i1> %x, i1 %elt, i64 2
124 ret <vscale x 8 x i1> %y
127 define <vscale x 8 x i1> @insertelt_idx_nxv8i1(<vscale x 8 x i1> %x, i1 %elt, i64 %idx) {
128 ; CHECK-LABEL: insertelt_idx_nxv8i1:
130 ; CHECK-NEXT: vsetvli a2, zero, e8, m1, ta, ma
131 ; CHECK-NEXT: vmv.v.i v8, 0
132 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
133 ; CHECK-NEXT: addi a2, a1, 1
134 ; CHECK-NEXT: vmv.s.x v9, a0
135 ; CHECK-NEXT: vsetvli zero, a2, e8, m1, tu, ma
136 ; CHECK-NEXT: vslideup.vx v8, v9, a1
137 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
138 ; CHECK-NEXT: vand.vi v8, v8, 1
139 ; CHECK-NEXT: vmsne.vi v0, v8, 0
141 %y = insertelement <vscale x 8 x i1> %x, i1 %elt, i64 %idx
142 ret <vscale x 8 x i1> %y
145 define <vscale x 16 x i1> @insertelt_nxv16i1(<vscale x 16 x i1> %x, i1 %elt) {
146 ; CHECK-LABEL: insertelt_nxv16i1:
148 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
149 ; CHECK-NEXT: vmv.v.i v8, 0
150 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
151 ; CHECK-NEXT: vmv.s.x v10, a0
152 ; CHECK-NEXT: vsetivli zero, 3, e8, m1, tu, ma
153 ; CHECK-NEXT: vslideup.vi v8, v10, 2
154 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
155 ; CHECK-NEXT: vand.vi v8, v8, 1
156 ; CHECK-NEXT: vmsne.vi v0, v8, 0
158 %y = insertelement <vscale x 16 x i1> %x, i1 %elt, i64 2
159 ret <vscale x 16 x i1> %y
162 define <vscale x 16 x i1> @insertelt_idx_nxv16i1(<vscale x 16 x i1> %x, i1 %elt, i64 %idx) {
163 ; CHECK-LABEL: insertelt_idx_nxv16i1:
165 ; CHECK-NEXT: vsetvli a2, zero, e8, m2, ta, ma
166 ; CHECK-NEXT: vmv.v.i v8, 0
167 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
168 ; CHECK-NEXT: vmv.s.x v10, a0
169 ; CHECK-NEXT: addi a0, a1, 1
170 ; CHECK-NEXT: vsetvli zero, a0, e8, m2, tu, ma
171 ; CHECK-NEXT: vslideup.vx v8, v10, a1
172 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
173 ; CHECK-NEXT: vand.vi v8, v8, 1
174 ; CHECK-NEXT: vmsne.vi v0, v8, 0
176 %y = insertelement <vscale x 16 x i1> %x, i1 %elt, i64 %idx
177 ret <vscale x 16 x i1> %y
180 define <vscale x 32 x i1> @insertelt_nxv32i1(<vscale x 32 x i1> %x, i1 %elt) {
181 ; CHECK-LABEL: insertelt_nxv32i1:
183 ; CHECK-NEXT: vsetvli a1, zero, e8, m4, ta, ma
184 ; CHECK-NEXT: vmv.v.i v8, 0
185 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
186 ; CHECK-NEXT: vmv.s.x v12, a0
187 ; CHECK-NEXT: vsetivli zero, 3, e8, m1, tu, ma
188 ; CHECK-NEXT: vslideup.vi v8, v12, 2
189 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
190 ; CHECK-NEXT: vand.vi v8, v8, 1
191 ; CHECK-NEXT: vmsne.vi v0, v8, 0
193 %y = insertelement <vscale x 32 x i1> %x, i1 %elt, i64 2
194 ret <vscale x 32 x i1> %y
197 define <vscale x 32 x i1> @insertelt_idx_nxv32i1(<vscale x 32 x i1> %x, i1 %elt, i64 %idx) {
198 ; CHECK-LABEL: insertelt_idx_nxv32i1:
200 ; CHECK-NEXT: vsetvli a2, zero, e8, m4, ta, ma
201 ; CHECK-NEXT: vmv.v.i v8, 0
202 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
203 ; CHECK-NEXT: vmv.s.x v12, a0
204 ; CHECK-NEXT: addi a0, a1, 1
205 ; CHECK-NEXT: vsetvli zero, a0, e8, m4, tu, ma
206 ; CHECK-NEXT: vslideup.vx v8, v12, a1
207 ; CHECK-NEXT: vsetvli a0, zero, e8, m4, ta, ma
208 ; CHECK-NEXT: vand.vi v8, v8, 1
209 ; CHECK-NEXT: vmsne.vi v0, v8, 0
211 %y = insertelement <vscale x 32 x i1> %x, i1 %elt, i64 %idx
212 ret <vscale x 32 x i1> %y
215 define <vscale x 64 x i1> @insertelt_nxv64i1(<vscale x 64 x i1> %x, i1 %elt) {
216 ; CHECK-LABEL: insertelt_nxv64i1:
218 ; CHECK-NEXT: vsetvli a1, zero, e8, m8, ta, ma
219 ; CHECK-NEXT: vmv.v.i v8, 0
220 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
221 ; CHECK-NEXT: vmv.s.x v16, a0
222 ; CHECK-NEXT: vsetivli zero, 3, e8, m1, tu, ma
223 ; CHECK-NEXT: vslideup.vi v8, v16, 2
224 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
225 ; CHECK-NEXT: vand.vi v8, v8, 1
226 ; CHECK-NEXT: vmsne.vi v0, v8, 0
228 %y = insertelement <vscale x 64 x i1> %x, i1 %elt, i64 2
229 ret <vscale x 64 x i1> %y
232 define <vscale x 64 x i1> @insertelt_idx_nxv64i1(<vscale x 64 x i1> %x, i1 %elt, i64 %idx) {
233 ; CHECK-LABEL: insertelt_idx_nxv64i1:
235 ; CHECK-NEXT: vsetvli a2, zero, e8, m8, ta, ma
236 ; CHECK-NEXT: vmv.v.i v8, 0
237 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
238 ; CHECK-NEXT: vmv.s.x v16, a0
239 ; CHECK-NEXT: addi a0, a1, 1
240 ; CHECK-NEXT: vsetvli zero, a0, e8, m8, tu, ma
241 ; CHECK-NEXT: vslideup.vx v8, v16, a1
242 ; CHECK-NEXT: vsetvli a0, zero, e8, m8, ta, ma
243 ; CHECK-NEXT: vand.vi v8, v8, 1
244 ; CHECK-NEXT: vmsne.vi v0, v8, 0
246 %y = insertelement <vscale x 64 x i1> %x, i1 %elt, i64 %idx
247 ret <vscale x 64 x i1> %y