[llvm] [InstCombine] Explicitly match poison mask. NFCI (PR #141744)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed May 28 03:52:33 PDT 2025


https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/141744

This is a follow up from https://github.com/llvm/llvm-project/pull/141300#discussion_r2109109224

An undef mask element in a shufflevector is really poison, so explicitly match it here for clarity.


>From a22b8cc7923238fd05b83947d02609d7cee3bd12 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Wed, 28 May 2025 11:45:32 +0100
Subject: [PATCH] [InstCombine] Explicitly match poison mask. NFCI

This is a follow up from https://github.com/llvm/llvm-project/pull/141300#discussion_r2109109224

An undef mask element in a shufflevector is really poison, so explicitly match it here for clarity.
---
 llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index e01dafd36d30d..e101edf4a6208 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1422,7 +1422,7 @@ InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
   ArrayRef<int> Mask;
   auto *NonConstArg = find_if_not(II->args(), IsaPred<Constant>);
   if (!NonConstArg ||
-      !match(NonConstArg, m_Shuffle(m_Value(X), m_Undef(), m_Mask(Mask))))
+      !match(NonConstArg, m_Shuffle(m_Value(X), m_Poison(), m_Mask(Mask))))
     return nullptr;
 
   // At least 1 operand must have 1 use because we are creating 2 instructions.
@@ -1433,7 +1433,7 @@ InstCombinerImpl::foldShuffledIntrinsicOperands(IntrinsicInst *II) {
   SmallVector<Value *, 4> NewArgs;
   Type *SrcTy = X->getType();
   for (Value *Arg : II->args()) {
-    if (match(Arg, m_Shuffle(m_Value(X), m_Undef(), m_SpecificMask(Mask))) &&
+    if (match(Arg, m_Shuffle(m_Value(X), m_Poison(), m_SpecificMask(Mask))) &&
         X->getType() == SrcTy)
       NewArgs.push_back(X);
     else if (match(Arg, m_ImmConstant(C))) {



More information about the llvm-commits mailing list