[PATCH] D127073: [SLP] Treat undef as any other constant

Harald van Dijk via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 5 08:13:07 PDT 2022


hvdijk added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:7598
       if (isConstant(V)) {
         ReuseShuffleIndicies.emplace_back(UniqueValues.size());
         UniqueValues.emplace_back(V);
----------------
ABataev wrote:
> hvdijk wrote:
> > ABataev wrote:
> > > For undefs need to push `UndefMaskElem`:
> > > ```
> > > ReuseShuffleIndicies.emplace_back(isa<UndefValue>(V) ? UndefMaskElem : UniqueValues.size());
> > > ```
> > I commented in D126939 that if we use UndefMaskElem when we want undef results, we run into another issue later on where we mistakenly treat a shuffle mask as an identity mask and remove the shuffle.
> But here it should be a case? You're pushing original UndefValue to the UniqueValues vector. So, you have undervalue in the vector and can have UndefMaskElem for it in the mask.
I'm pushing UndefValue in the UniqueValues vector, and its index into ReuseShuffleIndicies, to ensure that that UndefValue I just pushed gets used. If we push UndefMaskElem into ReuseShuffleIndicies (that's what we did before when undef was covered by the earlier `if` block), we may end up getting another value from UniqueValues instead, and that other value from UniqueValues may be poison.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127073/new/

https://reviews.llvm.org/D127073



More information about the llvm-commits mailing list