[PATCH] D111460: [X86][LoopVectorize] Fix `LoopVectorizationCostModel::getMemInstScalarizationCost()`

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 8 13:00:15 PDT 2021


lebedev.ri created this revision.
lebedev.ri added reviewers: fhahn, Ayal, delena, RKSimon, craig.topper, efriedma.
lebedev.ri added a project: LLVM.
Herald added subscribers: pengfei, arphaman, hiraditya.
lebedev.ri requested review of this revision.

We ask `TTI.getAddressComputationCost()` about the cost of computing vector address,
and then multiply it by the vector width. This doesn't make any sense,
it implies that we'd do a vector GEP and then scalarize the vector of pointers,
but there is no such thing in the vectorized IR, we perform scalar GEP's.

This is *especially* bad on X86, and was effectively prohibiting any scalarized
vectorization of gathers/scatters, because `X86TTIImpl::getAddressComputationCost()`
says that cost of vector address computation is `10` as compared to `1` for scalar.

The computed costs are similar to the ones with D111222 <https://reviews.llvm.org/D111222>+D111220 <https://reviews.llvm.org/D111220>,
but we end up without masked memory intrinsics that we'd then have to
expand later on, without much luck. (D111363 <https://reviews.llvm.org/D111363>)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111460

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/test/Analysis/CostModel/X86/gather-i16-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/gather-i32-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/gather-i64-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/gather-i8-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/interleaved-load-i32-stride-3-indices-0uu.ll
  llvm/test/Analysis/CostModel/X86/masked-scatter-i32-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/scatter-i16-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/scatter-i32-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/scatter-i64-with-i8-index.ll
  llvm/test/Analysis/CostModel/X86/scatter-i8-with-i8-index.ll
  llvm/test/Transforms/LoopVectorize/AArch64/gather-cost.ll
  llvm/test/Transforms/LoopVectorize/ARM/gather-cost.ll
  llvm/test/Transforms/LoopVectorize/X86/gather-cost.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-store-accesses-with-gaps.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111460.378340.patch
Type: text/x-patch
Size: 186319 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211008/3e9dd04c/attachment-0001.bin>


More information about the llvm-commits mailing list