[llvm] [X86] canCreateUndefOrPoisonForTargetNode/isGuaranteedNotToBeUndefOrPoisonForTargetNode - add X86ISD::VPERMV handling (PR #160845)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 26 03:11:33 PDT 2025
https://github.com/RKSimon created https://github.com/llvm/llvm-project/pull/160845
X86ISD::PSHUFB shuffles can't create undef/poison itself, allowing us to fold freeze(vpermps(x,y)) -> vpermps(freeze(x),freeze(y))
>From 0f4fca87cd0754099df7a7095229441aeab6e2b7 Mon Sep 17 00:00:00 2001
From: Simon Pilgrim <llvm-dev at redking.me.uk>
Date: Fri, 26 Sep 2025 11:05:06 +0100
Subject: [PATCH] [X86]
canCreateUndefOrPoisonForTargetNode/isGuaranteedNotToBeUndefOrPoisonForTargetNode
- add X86ISD::VPERMV handling
X86ISD::PSHUFB shuffles can't create undef/poison itself, allowing us to fold freeze(vpermps(x,y)) -> vpermps(freeze(x),freeze(y))
---
llvm/lib/Target/X86/X86ISelLowering.cpp | 2 ++
.../CodeGen/X86/vector-shuffle-combining-avx2.ll | 16 +++-------------
2 files changed, 5 insertions(+), 13 deletions(-)
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 57cf66e5275e3..69e430d29dbe9 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -45189,6 +45189,7 @@ bool X86TargetLowering::isGuaranteedNotToBeUndefOrPoisonForTargetNode(
case X86ISD::UNPCKL:
case X86ISD::UNPCKH:
case X86ISD::VPERMILPI:
+ case X86ISD::VPERMV:
case X86ISD::VPERMV3: {
SmallVector<int, 8> Mask;
SmallVector<SDValue, 2> Ops;
@@ -45255,6 +45256,7 @@ bool X86TargetLowering::canCreateUndefOrPoisonForTargetNode(
case X86ISD::UNPCKL:
case X86ISD::UNPCKH:
case X86ISD::VPERMILPI:
+ case X86ISD::VPERMV:
case X86ISD::VPERMV3:
return false;
// SSE comparisons handle all icmp/fcmp cases.
diff --git a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
index 06468f6414751..56c0b164b63d6 100644
--- a/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
+++ b/llvm/test/CodeGen/X86/vector-shuffle-combining-avx2.ll
@@ -934,19 +934,9 @@ entry:
}
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]}}
+; CHECK-LABEL: freeze_permps:
+; CHECK: # %bb.0:
+; CHECK-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>)
More information about the llvm-commits
mailing list