[PATCH] D154738: [SLP]Introduce isLegalVectorOp to check if the vector instruction is going to be scalarized.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 20 11:07:44 PDT 2023


ABataev added a comment.

In D154738#4519698 <https://reviews.llvm.org/D154738#4519698>, @reames wrote:

> I don't understand why this patch is in terms of *legality*.  The lowering choices should already be reflected in the *cost* returned for these operations.  Why do we need to directly access the lowering choices rather than using the existing cost based APIs?

Cost estimation works too late and affects th whole vectorization result. This patch prevents building of the nodes, which should not be tried for the vectorization at all, as later they are going to be scalarized. Cost model does not help here at all.

> In particular, if an intermediate sub-tree is illegal, but the cost of lowering is low enough, then vectorizing the entire tree (if the total cost accounting shows that being profitable) is the right answer.  You're spending a huge amount of additional work to reclaim that ability by hard failing the vectorization.

No. It prevents building the vector nodes, which will be scalarized and should be gather/buildvector nodes instead. If the operands could be vectorized for some reason, we need to vectorize it. Otherwise we actually may miss vectorization of some trees because of too high cost of those scalarized nodes.

> It's not really clear to me what your motivating case here is, but I suspect you've got an inaccurate cost model for one of the illegal operations.  I'd strongly prefer fixing that rather than taking this approach.

Again, no, it is not the cost, it is the check for legality here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154738



More information about the llvm-commits mailing list