[llvm] [X86] Add test showing failure to fold freeze(vpermps(x, y)) -> vpermps(freeze(x),freeze(y)) (PR #160837)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 02:15:10 PDT 2025


https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/160837

None

>From 7bf0b29b2983d48a5f73063dea7cf1dc302265fd Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Fri, 26 Sep 2025 10:13:25 +0100
Subject: [PATCH] [X86] Add test showing failure to fold freeze(vpermps(x,y))
 -> vpermps(freeze(x),freeze(y))

---
 .../X86/vector-shuffle-combining-avx2.ll      | 20 +++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
index 298858a8fcc73..06468f6414751 100644
--- a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
+++ b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
@@ -933,6 +933,26 @@ entry:
   ret i32 %tmp6
 }
 
+define <8 x float> @freeze_permps(<8 x float> %a0) {
+; AVX2-LABEL: freeze_permps:
+; AVX2:       # %bb.0:
+; AVX2-NEXT:    vmovaps {{.*#+}} ymm1 = [7,6,5,4,3,2,1,0]
+; AVX2-NEXT:    vpermps %ymm0, %ymm1, %ymm0
+; AVX2-NEXT:    vpermps %ymm0, %ymm1, %ymm0
+; AVX2-NEXT:    ret{{[l|q]}}
+;
+; AVX512-LABEL: freeze_permps:
+; AVX512:       # %bb.0:
+; AVX512-NEXT:    vpmovsxbd {{.*#+}} ymm1 = [7,6,5,4,3,2,1,0]
+; AVX512-NEXT:    vpermps %ymm0, %ymm1, %ymm0
+; AVX512-NEXT:    vpermps %ymm0, %ymm1, %ymm0
+; AVX512-NEXT:    ret{{[l|q]}}
+  %s0 = call <8 x float> @llvm.x86.avx2.permps(<8 x float> %a0, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>)
+  %f0 = freeze <8 x float> %s0
+  %s1 = call <8 x float> @llvm.x86.avx2.permps(<8 x float> %f0, <8 x i32> <i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1, i32 0>)
+  ret <8 x float> %s1
+}
+
 define <32 x i8> @PR27320(<8 x i32> %a0) {
 ; CHECK-LABEL: PR27320:
 ; CHECK:       # %bb.0:



More information about the llvm-commits mailing list