[llvm] [InstCombine] Do not perform binop-of-shuffle when mask is poison (PR #82185)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 18 12:11:34 PST 2024
================
@@ -1870,14 +1870,16 @@ Value *InstCombinerImpl::SimplifyDemandedVectorElts(Value *V,
Value *ShufOp = MatchShufAsOp0 ? X : Y;
Value *OtherOp = MatchShufAsOp0 ? Y : X;
for (User *U : OtherOp->users()) {
- auto Shuf = m_Shuffle(m_Specific(ShufOp), m_Value(), m_ZeroMask());
+ ArrayRef<int> Mask;
+ auto Shuf = m_Shuffle(m_Specific(ShufOp), m_Value(), m_Mask(Mask));
if (BO->isCommutative()
? match(U, m_c_BinOp(Opcode, Shuf, m_Specific(OtherOp)))
: MatchShufAsOp0
? match(U, m_BinOp(Opcode, Shuf, m_Specific(OtherOp)))
: match(U, m_BinOp(Opcode, m_Specific(OtherOp), Shuf)))
- if (DT.dominates(U, I))
- return U;
+ if (match(Mask, m_ZeroMask()) && Mask[0] != PoisonMaskElem)
----------------
antoniofrighetto wrote:
I might be wrong, but I was not able to get a miscompiled example when the other elements are poisoned, due to the way the transformation works on the demanded elements.
https://github.com/llvm/llvm-project/pull/82185
More information about the llvm-commits
mailing list