[all-commits] [llvm/llvm-project] 0d74fd: [SLP][COST][X86]Improve cost model for masked gather.

cilkplus via All-commits all-commits at lists.llvm.org
Thu Jul 8 11:55:14 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0d74fd3fdf5013e72c9c1682a284b8de7973a805
      https://github.com/llvm/llvm-project/commit/0d74fd3fdf5013e72c9c1682a284b8de7973a805
  Author: Alexey Bataev <a.bataev at outlook.com>
  Date:   2021-07-08 (Thu, 08 Jul 2021)

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

  Log Message:
  -----------
  [SLP][COST][X86]Improve cost model for masked gather.

Revived 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. 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.

Differential Revision: https://reviews.llvm.org/D105042




More information about the All-commits mailing list