[llvm] [VectorCombine] Fold permute of intrinsics into intrinsic of permutes: shuffle(intrinsic, poison/undef) -> intrinsic(shuffle) (PR #170052)
Jerry Dang via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 1 07:00:39 PST 2025
================
@@ -2960,6 +2961,93 @@ bool VectorCombine::foldShuffleOfIntrinsics(Instruction &I) {
return true;
}
+/// Try to convert
+/// "shuffle (intrinsic), (poison/undef)" into "intrinsic (shuffle)".
+bool VectorCombine::foldPermuteOfIntrinsic(Instruction &I) {
+ Value *V0, *V1;
+ ArrayRef<int> Mask;
+ if (!match(&I, m_Shuffle(m_OneUse(m_Value(V0)), m_Value(V1), m_Mask(Mask))))
----------------
kuroyukiasuna wrote:
I also considered merging them, but kept them separated for reasons mainly due to cleaness and readability. The permute code path and blend code path differs at both cost analysis and transform, I was trying to avoid having large blocks of `if (IsPermute) {}` branches in the code. While on the other hand merging and resuse also makes sense - if we feel strongly about merging the two functions I can do that too.
https://github.com/llvm/llvm-project/pull/170052
More information about the llvm-commits
mailing list