[PATCH] D93129: [LV] Do not use vector type to compute cost of scalar address comp.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 11 09:51:12 PST 2020


fhahn created this revision.
fhahn added reviewers: RKSimon, spatel, dmgreen.
Herald added subscribers: pengfei, hiraditya, kristof.beyls.
fhahn requested review of this revision.
Herald added a project: LLVM.

Currently getMemInstScalarizationCost severely overestimates the cost of
computing the addresses for scalarized memory instructions. It computes
the cost of computing vector addresses for each scalar access.

This patch adjusts the address cost computation to use the scalar
pointer type. Unfortunately this means that we now prefer scalarization
over gather/scatters in some cases on X86. This is due to the fact that
we divide the cost for predicated memory instructions by the reciprocal
block frequency. This means the cost is usually lower than the masked
gather/scatters. I am not sure if there's an easy way to avoid that in
the short term. The problem is that we currently do not really consider
the cost overhead for the compares/branches of predicated blocks.

With this change, we now vectorize the gather-cost.ll tests. I checked
on both ARM64 and X86 (skylake), and the vectorized versions are roughly
2x faster than the scalar loops.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93129

Files:
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  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/invariant-store-vectorization.ll
  llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93129.311263.patch
Type: text/x-patch
Size: 119989 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201211/ffa592d2/attachment.bin>


More information about the llvm-commits mailing list