[llvm] [InstCombine] Fold shuffled intrinsic operands with constant operands (PR #141300)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 05:52:32 PDT 2025


================
@@ -1419,9 +1418,11 @@ foldShuffledIntrinsicOperands(IntrinsicInst *II,
   }
 
   Value *X;
+  Constant *C;
   ArrayRef<int> Mask;
-  if (!match(II->getArgOperand(0),
-             m_Shuffle(m_Value(X), m_Undef(), m_Mask(Mask))))
+  auto *NonConstArg = find_if_not(II->args(), IsaPred<Constant>);
+  if (!NonConstArg ||
+      !match(NonConstArg, m_Shuffle(m_Value(X), m_Undef(), m_Mask(Mask))))
----------------
nikic wrote:

Might want to replace m_Undef -> m_Poison in a followup, for clarity.

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


More information about the llvm-commits mailing list