[clang] [llvm] [InstCombine] Canonicalise Zero Vector operand to always be RHS of a shuffle vector (PR #237258)
Kieran B via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 9 02:14:04 PST 2026
================
@@ -2446,10 +2446,12 @@ Instruction *InstCombinerImpl::foldSelectShuffle(ShuffleVectorInst &Shuf) {
if (!Shuf.isSelect())
return nullptr;
- // Canonicalize to choose from operand 0 first unless operand 1 is undefined.
- // Commuting undef to operand 0 conflicts with another canonicalization.
+ // Canonicalize to choose from operand 0 first unless operand 1 is
+ // undefined/zero. Commuting undef/zero to operand 0 conflicts with other
+ // canonicalization.
unsigned NumElts = cast<FixedVectorType>(Shuf.getType())->getNumElements();
if (!match(Shuf.getOperand(1), m_Undef()) &&
+ !match(Shuf.getOperand(1), m_CombineOr(m_Zero(), m_AnyZeroFP())) &&
----------------
kieroxide wrote:
We guard here to prevent an infinite loop. No test regressions occur from this guard
https://github.com/llvm/llvm-project/pull/237258
More information about the cfe-commits
mailing list