[llvm] 21ff15f - [X86] Add test cases showing its not always beneficial to fold concat(add/mul(),add/mul()) -> add/mul(concat(),concat())
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 10 09:01:49 PDT 2025
Author: Simon Pilgrim
Date: 2025-03-10T16:01:33Z
New Revision: 21ff15fa1a4b9abf1c8182a1a465923bdae517a5
URL: https://github.com/llvm/llvm-project/commit/21ff15fa1a4b9abf1c8182a1a465923bdae517a5
DIFF: https://github.com/llvm/llvm-project/commit/21ff15fa1a4b9abf1c8182a1a465923bdae517a5.diff
LOG: [X86] Add test cases showing its not always beneficial to fold concat(add/mul(),add/mul()) -> add/mul(concat(),concat())
Added:
Modified:
llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
index b18a32d7d0459..915c186de9ceb 100644
--- a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
+++ b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
@@ -775,6 +775,38 @@ define <32 x i8> @combine_pshufb_pshufb_or_pshufb(<32 x i8> %a0) {
ret <32 x i8> %4
}
+; TODO: Not beneficial to concatenate both inputs just to create a 256-bit vpaddb
+define <32 x i8> @concat_add_unnecessary(<16 x i8> %a0, <16 x i8> noundef %a1, <16 x i8> %a2) nounwind {
+; CHECK-LABEL: concat_add_unnecessary:
+; CHECK: # %bb.0:
+; CHECK-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
+; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
+; CHECK-NEXT: vinserti128 $1, %xmm2, %ymm1, %ymm1
+; CHECK-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm0
+; CHECK-NEXT: vpaddb %ymm1, %ymm0, %ymm0
+; CHECK-NEXT: ret{{[l|q]}}
+ %lo = add <16 x i8> %a0, %a1
+ %hi = add <16 x i8> %a0, %a2
+ %res = shufflevector <16 x i8> %lo, <16 x i8> %hi, <32 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, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23, i32 24, i32 25, i32 26, i32 27, i32 28, i32 29, i32 30, i32 31>
+ ret <32 x i8> %res
+}
+
+; TODO: Not beneficial to concatenate both inputs just to create a 256-bit vpmullw
+define <16 x i16> @concat_mul_unnecessary(<8 x i16> %a0, <8 x i16> %a1, <8 x i16> %a2) nounwind {
+; CHECK-LABEL: concat_mul_unnecessary:
+; CHECK: # %bb.0:
+; CHECK-NEXT: # kill: def $xmm1 killed $xmm1 def $ymm1
+; CHECK-NEXT: # kill: def $xmm0 killed $xmm0 def $ymm0
+; CHECK-NEXT: vinserti128 $1, %xmm2, %ymm1, %ymm1
+; CHECK-NEXT: vinserti128 $1, %xmm0, %ymm0, %ymm0
+; CHECK-NEXT: vpmullw %ymm1, %ymm0, %ymm0
+; CHECK-NEXT: ret{{[l|q]}}
+ %lo = mul <8 x i16> %a0, %a1
+ %hi = mul <8 x i16> %a0, %a2
+ %res = shufflevector <8 x i16> %lo, <8 x i16> %hi, <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>
+ ret <16 x i16> %res
+}
+
; Not beneficial to concatenate both inputs just to create a 256-bit palignr
define <32 x i8> @concat_alignr_unnecessary(<16 x i8> %a0, <16 x i8> noundef %a1, <16 x i8> %a2) nounwind {
; CHECK-LABEL: concat_alignr_unnecessary:
More information about the llvm-commits
mailing list