[PATCH] D105042: [SLP][COST][X86]Improve cost model for masked gather.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 28 10:39:20 PDT 2021


ABataev created this revision.
ABataev added reviewers: RKSimon, spatel, dtemirbulatov, anton-afanasyev, vdmitrie.
Herald added subscribers: pengfei, hiraditya.
ABataev requested review of this revision.
Herald added a project: LLVM.

Revived D101297 <https://reviews.llvm.org/D101297> in its original form + added some changes in X86
legalization cehcking for masked gathers.

This solution is the most stable and the most correct one. We have to
check the legality before trying to build the masked gather in SLP.
Without this check we have incorrect cost (for SLP) in case if the masked gather
is not legal/slower than the gather. And we're missing some
vectorization opportunities.

This can be fixed in the cost model, but in this case we need to add
special checks for the cost of GEPs for ScatterVectorize node, add
special check for small trees, etc., i.e. there are a lot of corner
cases here and there, which insrease code base and make it harder to
maintain the code.

> Can't we rely on cost model to deal with this? This can be profitable for futher vectorization, when we can start from such gather loads as seed.

The question from D101297 <https://reviews.llvm.org/D101297>. Actually, no, it can't. Actually, simple
gather may give us better result, especially after we started
vectorization of insertelements. Plus, like I said before, the cost for
non-legal masked gathers leads to missed vectorization opportunities.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105042

Files:
  llvm/lib/Target/X86/X86TargetTransformInfo.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/test/CodeGen/X86/masked_gather.ll
  llvm/test/CodeGen/X86/masked_gather_scatter.ll
  llvm/test/CodeGen/X86/masked_gather_scatter_widen.ll
  llvm/test/Transforms/LoopVectorize/X86/gather_scatter.ll
  llvm/test/Transforms/SLPVectorizer/X86/lookahead.ll
  llvm/test/Transforms/SLPVectorizer/X86/memory-runtime-checks.ll
  llvm/test/Transforms/SLPVectorizer/X86/pr47623.ll
  llvm/test/Transforms/SLPVectorizer/X86/pr47629-inseltpoison.ll
  llvm/test/Transforms/SLPVectorizer/X86/pr47629.ll
  llvm/test/Transforms/SLPVectorizer/X86/stores-non-ordered.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105042.354949.patch
Type: text/x-patch
Size: 306299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210628/4f93261f/attachment-0001.bin>


More information about the llvm-commits mailing list