@@ -105,3 +105,147 @@ define <vscale x 4 x float> @splat_idx_nxv4f32(<vscale x 4 x float> %v, i64 %idx
105
105
%splat = shufflevector <vscale x 4 x float > %ins , <vscale x 4 x float > poison, <vscale x 4 x i32 > zeroinitializer
106
106
ret <vscale x 4 x float > %splat
107
107
}
108
+
109
+ define <vscale x 8 x float > @splat_idx_nxv4f32_nxv8f32 (<vscale x 4 x float > %v , i64 %idx ) {
110
+ ; CHECK-LABEL: splat_idx_nxv4f32_nxv8f32:
111
+ ; CHECK: # %bb.0:
112
+ ; CHECK-NEXT: vsetvli a1, zero, e32, m4, ta, ma
113
+ ; CHECK-NEXT: vrgather.vx v12, v8, a0
114
+ ; CHECK-NEXT: vmv.v.v v8, v12
115
+ ; CHECK-NEXT: ret
116
+ %x = extractelement <vscale x 4 x float > %v , i64 %idx
117
+ %ins = insertelement <vscale x 8 x float > poison, float %x , i32 0
118
+ %splat = shufflevector <vscale x 8 x float > %ins , <vscale x 8 x float > poison, <vscale x 8 x i32 > zeroinitializer
119
+ ret <vscale x 8 x float > %splat
120
+ }
121
+
122
+ define <vscale x 4 x float > @splat_idx_v4f32_nxv4f32 (<4 x float > %v , i64 %idx ) {
123
+ ; CHECK-LABEL: splat_idx_v4f32_nxv4f32:
124
+ ; CHECK: # %bb.0:
125
+ ; CHECK-NEXT: vsetvli a1, zero, e32, m2, ta, ma
126
+ ; CHECK-NEXT: vrgather.vx v10, v8, a0
127
+ ; CHECK-NEXT: vmv.v.v v8, v10
128
+ ; CHECK-NEXT: ret
129
+ %x = extractelement <4 x float > %v , i64 %idx
130
+ %ins = insertelement <vscale x 4 x float > poison, float %x , i32 0
131
+ %splat = shufflevector <vscale x 4 x float > %ins , <vscale x 4 x float > poison, <vscale x 4 x i32 > zeroinitializer
132
+ ret <vscale x 4 x float > %splat
133
+ }
134
+
135
+ ; Negative test, scale could have a value > 2
136
+ define <8 x float > @splat_idx_nxv4f32_v8f32 (<vscale x 4 x float > %v , i64 %idx ) {
137
+ ; CHECK-LABEL: splat_idx_nxv4f32_v8f32:
138
+ ; CHECK: # %bb.0:
139
+ ; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
140
+ ; CHECK-NEXT: vslidedown.vx v8, v8, a0
141
+ ; CHECK-NEXT: vfmv.f.s fa5, v8
142
+ ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
143
+ ; CHECK-NEXT: vfmv.v.f v8, fa5
144
+ ; CHECK-NEXT: ret
145
+ %x = extractelement <vscale x 4 x float > %v , i64 %idx
146
+ %ins = insertelement <8 x float > poison, float %x , i32 0
147
+ %splat = shufflevector <8 x float > %ins , <8 x float > poison, <8 x i32 > zeroinitializer
148
+ ret <8 x float > %splat
149
+ }
150
+
151
+ define <vscale x 4 x float > @splat_idx_nxv8f32_nxv4f32_constant_0 (<vscale x 8 x float > %v ) {
152
+ ; CHECK-LABEL: splat_idx_nxv8f32_nxv4f32_constant_0:
153
+ ; CHECK: # %bb.0:
154
+ ; CHECK-NEXT: vsetvli a0, zero, e32, m2, ta, ma
155
+ ; CHECK-NEXT: vrgather.vi v10, v8, 0
156
+ ; CHECK-NEXT: vmv.v.v v8, v10
157
+ ; CHECK-NEXT: ret
158
+ %x = extractelement <vscale x 8 x float > %v , i64 0
159
+ %ins = insertelement <vscale x 4 x float > poison, float %x , i32 0
160
+ %splat = shufflevector <vscale x 4 x float > %ins , <vscale x 4 x float > poison, <vscale x 4 x i32 > zeroinitializer
161
+ ret <vscale x 4 x float > %splat
162
+ }
163
+
164
+ define <vscale x 4 x i8 > @splat_idx_nxv8i8_nxv4i8_constant_0 (<vscale x 8 x i8 > %v ) {
165
+ ; CHECK-LABEL: splat_idx_nxv8i8_nxv4i8_constant_0:
166
+ ; CHECK: # %bb.0:
167
+ ; CHECK-NEXT: vsetvli a0, zero, e8, mf2, ta, ma
168
+ ; CHECK-NEXT: vmv.x.s a0, v8
169
+ ; CHECK-NEXT: vmv.v.x v8, a0
170
+ ; CHECK-NEXT: ret
171
+ %x = extractelement <vscale x 8 x i8 > %v , i64 0
172
+ %ins = insertelement <vscale x 4 x i8 > poison, i8 %x , i32 0
173
+ %splat = shufflevector <vscale x 4 x i8 > %ins , <vscale x 4 x i8 > poison, <vscale x 4 x i32 > zeroinitializer
174
+ ret <vscale x 4 x i8 > %splat
175
+ }
176
+
177
+ define <vscale x 4 x i8 > @splat_idx_nxv8i8_nxv4i8_constant_3 (<vscale x 8 x i8 > %v ) {
178
+ ; CHECK-LABEL: splat_idx_nxv8i8_nxv4i8_constant_3:
179
+ ; CHECK: # %bb.0:
180
+ ; CHECK-NEXT: vsetivli zero, 1, e8, m1, ta, ma
181
+ ; CHECK-NEXT: vslidedown.vi v8, v8, 3
182
+ ; CHECK-NEXT: vmv.x.s a0, v8
183
+ ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
184
+ ; CHECK-NEXT: vmv.v.x v8, a0
185
+ ; CHECK-NEXT: ret
186
+ %x = extractelement <vscale x 8 x i8 > %v , i64 3
187
+ %ins = insertelement <vscale x 4 x i8 > poison, i8 %x , i32 0
188
+ %splat = shufflevector <vscale x 4 x i8 > %ins , <vscale x 4 x i8 > poison, <vscale x 4 x i32 > zeroinitializer
189
+ ret <vscale x 4 x i8 > %splat
190
+ }
191
+
192
+
193
+ ; Negative test, vscale coule be 2
194
+ define <vscale x 4 x i8 > @splat_idx_nxv8i8_nxv4i8_constant_15 (<vscale x 8 x i8 > %v ) {
195
+ ; CHECK-LABEL: splat_idx_nxv8i8_nxv4i8_constant_15:
196
+ ; CHECK: # %bb.0:
197
+ ; CHECK-NEXT: vsetivli zero, 1, e8, m1, ta, ma
198
+ ; CHECK-NEXT: vslidedown.vi v8, v8, 15
199
+ ; CHECK-NEXT: vmv.x.s a0, v8
200
+ ; CHECK-NEXT: vsetvli a1, zero, e8, mf2, ta, ma
201
+ ; CHECK-NEXT: vmv.v.x v8, a0
202
+ ; CHECK-NEXT: ret
203
+ %x = extractelement <vscale x 8 x i8 > %v , i64 15
204
+ %ins = insertelement <vscale x 4 x i8 > poison, i8 %x , i32 0
205
+ %splat = shufflevector <vscale x 4 x i8 > %ins , <vscale x 4 x i8 > poison, <vscale x 4 x i32 > zeroinitializer
206
+ ret <vscale x 4 x i8 > %splat
207
+ }
208
+
209
+ define <8 x float > @splat_idx_nxv4f32_v8f32_constant_0 (<vscale x 4 x float > %v ) {
210
+ ; CHECK-LABEL: splat_idx_nxv4f32_v8f32_constant_0:
211
+ ; CHECK: # %bb.0:
212
+ ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
213
+ ; CHECK-NEXT: vfmv.f.s fa5, v8
214
+ ; CHECK-NEXT: vfmv.v.f v8, fa5
215
+ ; CHECK-NEXT: ret
216
+ %x = extractelement <vscale x 4 x float > %v , i64 0
217
+ %ins = insertelement <8 x float > poison, float %x , i32 0
218
+ %splat = shufflevector <8 x float > %ins , <8 x float > poison, <8 x i32 > zeroinitializer
219
+ ret <8 x float > %splat
220
+ }
221
+
222
+ define <8 x float > @splat_idx_nxv4f32_v8f32_constant_7 (<vscale x 4 x float > %v ) {
223
+ ; CHECK-LABEL: splat_idx_nxv4f32_v8f32_constant_7:
224
+ ; CHECK: # %bb.0:
225
+ ; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
226
+ ; CHECK-NEXT: vslidedown.vi v8, v8, 7
227
+ ; CHECK-NEXT: vfmv.f.s fa5, v8
228
+ ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
229
+ ; CHECK-NEXT: vfmv.v.f v8, fa5
230
+ ; CHECK-NEXT: ret
231
+ %x = extractelement <vscale x 4 x float > %v , i64 7
232
+ %ins = insertelement <8 x float > poison, float %x , i32 0
233
+ %splat = shufflevector <8 x float > %ins , <8 x float > poison, <8 x i32 > zeroinitializer
234
+ ret <8 x float > %splat
235
+ }
236
+
237
+ ; Negative test, vscale might be 4
238
+ define <8 x float > @splat_idx_nxv4f32_v8f32_constant_8 (<vscale x 4 x float > %v ) {
239
+ ; CHECK-LABEL: splat_idx_nxv4f32_v8f32_constant_8:
240
+ ; CHECK: # %bb.0:
241
+ ; CHECK-NEXT: vsetivli zero, 1, e32, m2, ta, ma
242
+ ; CHECK-NEXT: vslidedown.vi v8, v8, 8
243
+ ; CHECK-NEXT: vfmv.f.s fa5, v8
244
+ ; CHECK-NEXT: vsetivli zero, 8, e32, m2, ta, ma
245
+ ; CHECK-NEXT: vfmv.v.f v8, fa5
246
+ ; CHECK-NEXT: ret
247
+ %x = extractelement <vscale x 4 x float > %v , i64 8
248
+ %ins = insertelement <8 x float > poison, float %x , i32 0
249
+ %splat = shufflevector <8 x float > %ins , <8 x float > poison, <8 x i32 > zeroinitializer
250
+ ret <8 x float > %splat
251
+ }
0 commit comments