[llvm] [VectorCombine] foldShuffleOfShuffles - fold "shuffle (shuffle x, undef), (shuffle y, undef)" -> "shuffle x, y" (PR #88743)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 22 03:24:51 PDT 2024


================
@@ -1552,6 +1553,86 @@ bool VectorCombine::foldShuffleOfCastops(Instruction &I) {
   return true;
 }
 
+/// Try to convert "shuffle (shuffle x, undef), (shuffle y, undef)"
+/// into "shuffle x, y".
+bool VectorCombine::foldShuffleOfShuffles(Instruction &I) {
+  Value *V0, *V1, *U0, *U1;
+  ArrayRef<int> OuterMask, InnerMask0, InnerMask1;
+  if (!match(&I, m_Shuffle(m_OneUse(m_Shuffle(m_Value(V0), m_Value(U0),
+                                              m_Mask(InnerMask0))),
+                           m_OneUse(m_Shuffle(m_Value(V1), m_Value(U1),
+                                              m_Mask(InnerMask1))),
+                           m_Mask(OuterMask))) ||
+      !isa<UndefValue>(U0) || !isa<UndefValue>(U1))
+    return false;
----------------
RKSimon wrote:

Sorry - which bit?

https://github.com/llvm/llvm-project/pull/88743


More information about the llvm-commits mailing list