[PATCH] D113782: [SLP]Improve cost model for the shuffled extracts.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 1 06:03:32 PST 2021


ABataev added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:5425
+            } while (E == getTreeEntry(Base));
+          }
+          FirstUsers.push_back(VU);
----------------
RKSimon wrote:
> ABataev wrote:
> > RKSimon wrote:
> > > Should this be put inside the while() loop before the break? AFAICT that's the only time that cast<InsertElementInst>(Base) is valid.
> > No, not quite so. It can be insertelement also if `ScalarToTreeEntry.count(Base)` is true, i.e. there is a tree entry for this insertelement in the graph.
> I don't quite follow, this is what I had in mind:
> 
> ```
> // Find the insertvector, vectorized in tree, if any.
> Value *Base = VU;
> while (isa<InsertElementInst>(Base)) {
>   if (ScalarToTreeEntry.count(Base)) {
>     VU = Base;
> 
>     // Build the mask for the vectorized insertelement instructions.
>     if (const TreeEntry *E = getTreeEntry(Base)) {
>       do {
>         int Idx = E->findLaneForValue(Base);
>         ShuffleMask.back()[Idx] = Idx;
>         Base = cast<InsertElementInst>(Base)->getOperand(0);
>       } while (E == getTreeEntry(Base));
>     }
>     break;
>   }
>   Base = cast<InsertElementInst>(Base)->getOperand(0);
> }
> ```
Oh, I see. Actually, I was going to rework this block of code in a pretty similar way.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113782



More information about the llvm-commits mailing list