[llvm] b60974d - [VectorCombine][X86] Extend bitcast(shuffle(x,y)) test coverage
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 11 03:15:59 PDT 2024
Author: Simon Pilgrim
Date: 2024-04-11T11:13:12+01:00
New Revision: b60974dc9e5d98054f5a3a0dac7eab70e38bd416
URL: https://github.com/llvm/llvm-project/commit/b60974dc9e5d98054f5a3a0dac7eab70e38bd416
DIFF: https://github.com/llvm/llvm-project/commit/b60974dc9e5d98054f5a3a0dac7eab70e38bd416.diff
LOG: [VectorCombine][X86] Extend bitcast(shuffle(x,y)) test coverage
As discussed on #87510 the intention is only to fold bitcast(shuffle(x,y)) -> shuffle(bitcast(x),bitcast(y)) if we won't actually increase the number of bitcasts (i.e. x or y is already bitcasted from the correct type).
Added:
Modified:
llvm/test/Transforms/VectorCombine/X86/shuffle.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/VectorCombine/X86/shuffle.ll b/llvm/test/Transforms/VectorCombine/X86/shuffle.ll
index d1484fd5ab3399..5020d37f86f565 100644
--- a/llvm/test/Transforms/VectorCombine/X86/shuffle.ll
+++ b/llvm/test/Transforms/VectorCombine/X86/shuffle.ll
@@ -121,6 +121,48 @@ define <16 x i8> @bitcast_shuf_uses(<4 x i32> %v) {
ret <16 x i8> %r
}
+; shuffle of 2 operands removes bitcasts
+
+define <4 x i64> @bitcast_shuf_remove_bitcasts(<2 x i64> %a0, <2 x i64> %a1) {
+; CHECK-LABEL: @bitcast_shuf_remove_bitcasts(
+; CHECK-NEXT: [[R:%.*]] = shufflevector <2 x i64> [[A0:%.*]], <2 x i64> [[A1:%.*]], <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+; CHECK-NEXT: ret <4 x i64> [[R]]
+;
+ %bc0 = bitcast <2 x i64> %a0 to <4 x i32>
+ %bc1 = bitcast <2 x i64> %a1 to <4 x i32>
+ %shuf = shufflevector <4 x i32> %bc0, <4 x i32> %bc1, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+ %r = bitcast <8 x i32> %shuf to <4 x i64>
+ ret <4 x i64> %r
+}
+
+; shuffle of 2 operands must reduce bitcasts
+
+define <8 x i32> @bitcast_shuf_one_bitcast(<4 x i32> %a0, <2 x i64> %a1) {
+; CHECK-LABEL: @bitcast_shuf_one_bitcast(
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> [[A1:%.*]] to <4 x i32>
+; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[A0:%.*]], <4 x i32> [[TMP1]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: ret <8 x i32> [[R]]
+;
+ %bc0 = bitcast <4 x i32> %a0 to <2 x i64>
+ %shuf = shufflevector <2 x i64> %bc0, <2 x i64> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %r = bitcast <4 x i64> %shuf to <8 x i32>
+ ret <8 x i32> %r
+}
+
+; TODO - Negative test - shuffle of 2 operands must not increase bitcasts
+
+define <8 x i32> @bitcast_shuf_too_many_bitcasts(<2 x i64> %a0, <2 x i64> %a1) {
+; CHECK-LABEL: @bitcast_shuf_too_many_bitcasts(
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x i64> [[A0:%.*]] to <4 x i32>
+; CHECK-NEXT: [[TMP2:%.*]] = bitcast <2 x i64> [[A1:%.*]] to <4 x i32>
+; CHECK-NEXT: [[R:%.*]] = shufflevector <4 x i32> [[TMP1]], <4 x i32> [[TMP2]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
+; CHECK-NEXT: ret <8 x i32> [[R]]
+;
+ %shuf = shufflevector <2 x i64> %a0, <2 x i64> %a1, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
+ %r = bitcast <4 x i64> %shuf to <8 x i32>
+ ret <8 x i32> %r
+}
+
define <2 x i64> @PR35454_1(<2 x i64> %v) {
; SSE-LABEL: @PR35454_1(
; SSE-NEXT: [[BC:%.*]] = bitcast <2 x i64> [[V:%.*]] to <4 x i32>
More information about the llvm-commits
mailing list