[PATCH] D149741: [InlineCost][TargetTransformInfo][AMDGPU] Consider cost of alloca instructions in the caller (2/2)

Juan Manuel Martinez CaamaƱo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 3 05:23:06 PDT 2023


jmmartinez created this revision.
Herald added subscribers: kosarev, foad, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl, arsenm.
Herald added a project: All.
jmmartinez requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

Before this patch, the compiler gave a bump to the inline-threshold
when the total size of the allocas passed as arguments to the
callee was below 256 bytes.
This heuristic ignores that some of these allocas could have be removed
by SROA if inlining was applied.

Ideally, this bonus would be attributed to the threshold once the
size of all the allocas that could not be handled by SROA is known:
at the end of the InlineCost analysis.
However, we may never reach this point if the inline-cost analysis exits
early when the inline cost goes over the threshold mid-analysis.

This patch proposes:

- Attribute the bonus in the inline-threshold when allocas are passed as arguments (regardless of their total size).
- Assigns a cost to each alloca proportional to its size, such that the cost of all the allocas cancels the bonus.

Potential problems:

- This patch assumes that removing alloca instructions with SROA is always profitable. This may not be the case if the total size of the allocas is still too big to be promoted to registers/LDS.
- Redundant calls to getTotalAllocaSize
- Awkwardly, the threshold attributed contributes to the single-bb and vector bonus.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149741

Files:
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
  llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll
  llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-alloca-argument-cost.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149741.519038.patch
Type: text/x-patch
Size: 8393 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230503/539db720/attachment.bin>


More information about the llvm-commits mailing list