Skip to content

Commit 32b95a3

Browse files
committed
[VectorCombine][X86] Extend shuffle(bitcast(x),bitcast(y)) test coverage
As discussed on #87510 the intention is to fold shuffle(bitcast(x),bitcast(y)) -> bitcast(shuffle(x,y)), but it must not interfere with existing bitcast(shuffle(bitcast(x),bitcast(y))) folds.
1 parent db2fb3d commit 32b95a3

File tree

1 file changed

+56
-11
lines changed

1 file changed

+56
-11
lines changed

llvm/test/Transforms/VectorCombine/X86/shuffle-of-casts.ll

+56-11
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,51 @@ define <8 x double> @interleave_fpext_v4f32_v8f64(<4 x float> %a0, <4 x float> %
165165
ret <8 x double> %r
166166
}
167167

168+
; TODO - bitcasts (same element count)
169+
170+
define <8 x float> @concat_bitcast_v4i32_v8f32(<4 x i32> %a0, <4 x i32> %a1) {
171+
; CHECK-LABEL: @concat_bitcast_v4i32_v8f32(
172+
; CHECK-NEXT: [[X0:%.*]] = bitcast <4 x i32> [[A0:%.*]] to <4 x float>
173+
; CHECK-NEXT: [[X1:%.*]] = bitcast <4 x i32> [[A1:%.*]] to <4 x float>
174+
; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[X0]], <4 x float> [[X1]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
175+
; CHECK-NEXT: ret <8 x float> [[R]]
176+
;
177+
%x0 = bitcast <4 x i32> %a0 to <4 x float>
178+
%x1 = bitcast <4 x i32> %a1 to <4 x float>
179+
%r = shufflevector <4 x float> %x0, <4 x float> %x1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
180+
ret <8 x float> %r
181+
}
182+
183+
; TODO - bitcasts (lower element count)
184+
185+
define <4 x double> @concat_bitcast_v8i16_v4f64(<8 x i16> %a0, <8 x i16> %a1) {
186+
; CHECK-LABEL: @concat_bitcast_v8i16_v4f64(
187+
; CHECK-NEXT: [[X0:%.*]] = bitcast <8 x i16> [[A0:%.*]] to <2 x double>
188+
; CHECK-NEXT: [[X1:%.*]] = bitcast <8 x i16> [[A1:%.*]] to <2 x double>
189+
; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x double> [[X0]], <2 x double> [[X1]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
190+
; CHECK-NEXT: ret <4 x double> [[R]]
191+
;
192+
%x0 = bitcast <8 x i16> %a0 to <2 x double>
193+
%x1 = bitcast <8 x i16> %a1 to <2 x double>
194+
%r = shufflevector <2 x double> %x0, <2 x double> %x1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
195+
ret <4 x double> %r
196+
}
197+
198+
; TODO - bitcasts (higher element count)
199+
200+
define <16 x i16> @concat_bitcast_v4i32_v16i16(<4 x i32> %a0, <4 x i32> %a1) {
201+
; CHECK-LABEL: @concat_bitcast_v4i32_v16i16(
202+
; CHECK-NEXT: [[X0:%.*]] = bitcast <4 x i32> [[A0:%.*]] to <8 x i16>
203+
; CHECK-NEXT: [[X1:%.*]] = bitcast <4 x i32> [[A1:%.*]] to <8 x i16>
204+
; CHECK-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[X0]], <8 x i16> [[X1]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
205+
; CHECK-NEXT: ret <16 x i16> [[R]]
206+
;
207+
%x0 = bitcast <4 x i32> %a0 to <8 x i16>
208+
%x1 = bitcast <4 x i32> %a1 to <8 x i16>
209+
%r = shufflevector <8 x i16> %x0, <8 x i16> %x1, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15>
210+
ret <16 x i16> %r
211+
}
212+
168213
; negative - multiuse
169214

170215
define <8 x i16> @concat_trunc_v4i32_v8i16_multiuse(<4 x i32> %a0, <4 x i32> %a1, ptr %a2) {
@@ -182,19 +227,19 @@ define <8 x i16> @concat_trunc_v4i32_v8i16_multiuse(<4 x i32> %a0, <4 x i32> %a1
182227
ret <8 x i16> %r
183228
}
184229

185-
; negative - bitcasts
230+
; negative - bitcasts (unscalable higher element count)
186231

187-
define <8 x float> @concat_bitcast_v4i32_v8f32(<4 x i32> %a0, <4 x i32> %a1) {
188-
; CHECK-LABEL: @concat_bitcast_v4i32_v8f32(
189-
; CHECK-NEXT: [[X0:%.*]] = bitcast <4 x i32> [[A0:%.*]] to <4 x float>
190-
; CHECK-NEXT: [[X1:%.*]] = bitcast <4 x i32> [[A1:%.*]] to <4 x float>
191-
; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x float> [[X0]], <4 x float> [[X1]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
192-
; CHECK-NEXT: ret <8 x float> [[R]]
232+
define <16 x i16> @revpair_bitcast_v4i32_v16i16(<4 x i32> %a0, <4 x i32> %a1) {
233+
; CHECK-LABEL: @revpair_bitcast_v4i32_v16i16(
234+
; CHECK-NEXT: [[X0:%.*]] = bitcast <4 x i32> [[A0:%.*]] to <8 x i16>
235+
; CHECK-NEXT: [[X1:%.*]] = bitcast <4 x i32> [[A1:%.*]] to <8 x i16>
236+
; CHECK-NEXT: [[R:%.*]] = shufflevector <8 x i16> [[X0]], <8 x i16> [[X1]], <16 x i32> <i32 1, i32 0, i32 3, i32 3, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
237+
; CHECK-NEXT: ret <16 x i16> [[R]]
193238
;
194-
%x0 = bitcast <4 x i32> %a0 to <4 x float>
195-
%x1 = bitcast <4 x i32> %a1 to <4 x float>
196-
%r = shufflevector <4 x float> %x0, <4 x float> %x1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
197-
ret <8 x float> %r
239+
%x0 = bitcast <4 x i32> %a0 to <8 x i16>
240+
%x1 = bitcast <4 x i32> %a1 to <8 x i16>
241+
%r = shufflevector <8 x i16> %x0, <8 x i16> %x1, <16 x i32> <i32 1, i32 0, i32 3, i32 3, i32 5, i32 4, i32 7, i32 6, i32 9, i32 8, i32 11, i32 10, i32 13, i32 12, i32 15, i32 14>
242+
ret <16 x i16> %r
198243
}
199244

200245
; negative - src type mismatch

0 commit comments

Comments
 (0)