[PATCH] D125918: [LV] Improve register pressure estimate at high VFs

Peter Waller via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 18 12:04:37 PDT 2022


peterwaller-arm created this revision.
peterwaller-arm added reviewers: fhahn, RKSimon, efriedma, nikic, dmgreen, sdesmalen, paulwalker-arm.
Herald added a subscriber: ctetreau.
Herald added a project: All.
peterwaller-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Previously, `getRegUsageForType` was implemented using
`getTypeLegalizationCost`.  `getRegUsageForType` is used by the loop
vectorizer to estimate the register pressure caused by using a vector
type.  However, `getTypeLegalizationCost` currently only appears to
understand splitting and not scalarization, so significantly
underestimates the register requirements.

Instead, use `getNumRegisters`, which understands when scalarization
can occur (via computeRegisterProperties).

This was discovered while investigating D118979 <https://reviews.llvm.org/D118979> (Set maximum VF with
shouldMaximizeVectorBandwidth), where under fixed-length 512-bit SVE the
loop vectorizer previously ends up costing an v128i1 as 2 v64i*
registers where it actually occupies 128 i32 registers.

I'm sending this patch early for comment, I'm still doing some sanity checking
with LNT.  I note that getRegisterClassForType appears to return VectorRC even
though the type in question (large vNi1 types) end up occupying scalar
registers. That might be worth fixing too.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125918

Files:
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/test/Transforms/LoopVectorize/AArch64/i1-reg-usage.ll
  llvm/test/Transforms/LoopVectorize/X86/i1-reg-usage.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125918.430471.patch
Type: text/x-patch
Size: 4472 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220518/1da48e96/attachment.bin>


More information about the llvm-commits mailing list