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> @vsplat_nxv1i1_0() {
6 ; CHECK-LABEL: vsplat_nxv1i1_0:
8 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
9 ; CHECK-NEXT: vmclr.m v0
11 ret <vscale x 1 x i1> splat (i1 0)
14 define <vscale x 1 x i1> @vsplat_nxv1i1_1() {
15 ; CHECK-LABEL: vsplat_nxv1i1_1:
17 ; CHECK-NEXT: vsetvli a0, zero, e8, mf8, ta, ma
18 ; CHECK-NEXT: vmset.m v0
20 ret <vscale x 1 x i1> splat (i1 -1)
23 define <vscale x 1 x i1> @vsplat_nxv1i1_2(i1 %x) {
24 ; CHECK-LABEL: vsplat_nxv1i1_2:
26 ; CHECK-NEXT: andi a0, a0, 1
27 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
28 ; CHECK-NEXT: vmv.v.x v8, a0
29 ; CHECK-NEXT: vmsne.vi v0, v8, 0
31 %head = insertelement <vscale x 1 x i1> poison, i1 %x, i32 0
32 %splat = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
33 ret <vscale x 1 x i1> %splat
36 define <vscale x 1 x i1> @vsplat_nxv1i1_3(i32 signext %x, i32 signext %y) {
37 ; CHECK-LABEL: vsplat_nxv1i1_3:
39 ; CHECK-NEXT: xor a0, a0, a1
40 ; CHECK-NEXT: snez a0, a0
41 ; CHECK-NEXT: vsetvli a1, zero, e8, mf8, ta, ma
42 ; CHECK-NEXT: vmv.v.x v8, a0
43 ; CHECK-NEXT: vmsne.vi v0, v8, 0
45 %c = icmp ne i32 %x, %y
46 %head = insertelement <vscale x 1 x i1> poison, i1 %c, i32 0
47 %splat = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> poison, <vscale x 1 x i32> zeroinitializer
48 ret <vscale x 1 x i1> %splat
51 define <vscale x 2 x i1> @vsplat_nxv2i1_0() {
52 ; CHECK-LABEL: vsplat_nxv2i1_0:
54 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
55 ; CHECK-NEXT: vmclr.m v0
57 ret <vscale x 2 x i1> splat (i1 0)
60 define <vscale x 2 x i1> @vsplat_nxv2i1_1() {
61 ; CHECK-LABEL: vsplat_nxv2i1_1:
63 ; CHECK-NEXT: vsetvli a0, zero, e8, mf4, ta, ma
64 ; CHECK-NEXT: vmset.m v0
66 ret <vscale x 2 x i1> splat (i1 -1)
69 define <vscale x 2 x i1> @vsplat_nxv2i1_2(i1 %x) {
70 ; CHECK-LABEL: vsplat_nxv2i1_2:
72 ; CHECK-NEXT: andi a0, a0, 1
73 ; CHECK-NEXT: vsetvli a1, zero, e8, mf4, ta, ma
74 ; CHECK-NEXT: vmv.v.x v8, a0
75 ; CHECK-NEXT: vmsne.vi v0, v8, 0
77 %head = insertelement <vscale x 2 x i1> poison, i1 %x, i32 0
78 %splat = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
79 ret <vscale x 2 x i1> %splat
82 define <vscale x 4 x i1> @vsplat_nxv4i1_0() {
83 ; CHECK-LABEL: vsplat_nxv4i1_0:
85 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
86 ; CHECK-NEXT: vmclr.m v0
88 ret <vscale x 4 x i1> splat (i1 0)
91 define <vscale x 4 x i1> @vsplat_nxv4i1_1() {
92 ; CHECK-LABEL: vsplat_nxv4i1_1:
94 ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
95 ; CHECK-NEXT: vmset.m v0
97 ret <vscale x 4 x i1> splat (i1 -1)
100 define <vscale x 4 x i1> @vsplat_nxv4i1_2(i1 %x) {
101 ; CHECK-LABEL: vsplat_nxv4i1_2:
103 ; CHECK-NEXT: andi a0, a0, 1
104 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
105 ; CHECK-NEXT: vmv.v.x v8, a0
106 ; CHECK-NEXT: vmsne.vi v0, v8, 0
108 %head = insertelement <vscale x 4 x i1> poison, i1 %x, i32 0
109 %splat = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
110 ret <vscale x 4 x i1> %splat
113 define <vscale x 8 x i1> @vsplat_nxv8i1_0() {
114 ; CHECK-LABEL: vsplat_nxv8i1_0:
116 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
117 ; CHECK-NEXT: vmclr.m v0
119 ret <vscale x 8 x i1> splat (i1 0)
122 define <vscale x 8 x i1> @vsplat_nxv8i1_1() {
123 ; CHECK-LABEL: vsplat_nxv8i1_1:
125 ; CHECK-NEXT: vsetvli a0, zero, e8, m1, ta, ma
126 ; CHECK-NEXT: vmset.m v0
128 ret <vscale x 8 x i1> splat (i1 -1)
131 define <vscale x 8 x i1> @vsplat_nxv8i1_2(i1 %x) {
132 ; CHECK-LABEL: vsplat_nxv8i1_2:
134 ; CHECK-NEXT: andi a0, a0, 1
135 ; CHECK-NEXT: vsetvli a1, zero, e8, m1, ta, ma
136 ; CHECK-NEXT: vmv.v.x v8, a0
137 ; CHECK-NEXT: vmsne.vi v0, v8, 0
139 %head = insertelement <vscale x 8 x i1> poison, i1 %x, i32 0
140 %splat = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
141 ret <vscale x 8 x i1> %splat
144 define <vscale x 16 x i1> @vsplat_nxv16i1_0() {
145 ; CHECK-LABEL: vsplat_nxv16i1_0:
147 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
148 ; CHECK-NEXT: vmclr.m v0
150 ret <vscale x 16 x i1> splat (i1 0)
153 define <vscale x 16 x i1> @vsplat_nxv16i1_1() {
154 ; CHECK-LABEL: vsplat_nxv16i1_1:
156 ; CHECK-NEXT: vsetvli a0, zero, e8, m2, ta, ma
157 ; CHECK-NEXT: vmset.m v0
159 ret <vscale x 16 x i1> splat (i1 -1)
162 define <vscale x 16 x i1> @vsplat_nxv16i1_2(i1 %x) {
163 ; CHECK-LABEL: vsplat_nxv16i1_2:
165 ; CHECK-NEXT: andi a0, a0, 1
166 ; CHECK-NEXT: vsetvli a1, zero, e8, m2, ta, ma
167 ; CHECK-NEXT: vmv.v.x v8, a0
168 ; CHECK-NEXT: vmsne.vi v0, v8, 0
170 %head = insertelement <vscale x 16 x i1> poison, i1 %x, i32 0
171 %splat = shufflevector <vscale x 16 x i1> %head, <vscale x 16 x i1> poison, <vscale x 16 x i32> zeroinitializer
172 ret <vscale x 16 x i1> %splat
175 define <vscale x 4 x i1> @splat_idx_nxv4i32(<vscale x 4 x i1> %v, i64 %idx) {
176 ; CHECK-LABEL: splat_idx_nxv4i32:
178 ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
179 ; CHECK-NEXT: vmv.v.i v8, 0
180 ; CHECK-NEXT: vmerge.vim v8, v8, 1, v0
181 ; CHECK-NEXT: vslidedown.vx v8, v8, a0
182 ; CHECK-NEXT: vmv.x.s a0, v8
183 ; CHECK-NEXT: andi a0, a0, 1
184 ; CHECK-NEXT: vmv.v.x v8, a0
185 ; CHECK-NEXT: vmsne.vi v0, v8, 0
187 %x = extractelement <vscale x 4 x i1> %v, i64 %idx
188 %ins = insertelement <vscale x 4 x i1> poison, i1 %x, i32 0
189 %splat = shufflevector <vscale x 4 x i1> %ins, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
190 ret <vscale x 4 x i1> %splat