[all-commits] [llvm/llvm-project] cc8a34: [InlineCost][TargetTransformInfo][AMDGPU] Consider...
Juan Manuel Martinez Caamaño via All-commits
all-commits at lists.llvm.org
Thu Jun 29 00:51:58 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: cc8a346e3fa362c2b1319cca9883182fbf36b6db
https://github.com/llvm/llvm-project/commit/cc8a346e3fa362c2b1319cca9883182fbf36b6db
Author: Juan Manuel MARTINEZ CAAMAÑO <juamarti at amd.com>
Date: 2023-06-29 (Thu, 29 Jun 2023)
Changed paths:
M llvm/include/llvm/Analysis/TargetTransformInfo.h
M llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
M llvm/include/llvm/CodeGen/BasicTTIImpl.h
M llvm/lib/Analysis/InlineCost.cpp
M llvm/lib/Analysis/TargetTransformInfo.cpp
M llvm/unittests/Analysis/InlineCostTest.cpp
Log Message:
-----------
[InlineCost][TargetTransformInfo][AMDGPU] Consider cost of alloca instructions in the caller (1/2)
On AMDGPU, alloca instructions have penalty that can
be avoided when SROA is applied after inlining.
This patch introduces the default implementation of
TargetTransformInfo::getCallerAllocaCost.
Reviewed By: mtrofin
Differential Revision: https://reviews.llvm.org/D149740
Commit: dd1df099ae37c2a68a20c96615b7ed7474eacec4
https://github.com/llvm/llvm-project/commit/dd1df099ae37c2a68a20c96615b7ed7474eacec4
Author: Juan Manuel MARTINEZ CAAMAÑO <juamarti at amd.com>
Date: 2023-06-29 (Thu, 29 Jun 2023)
Changed paths:
M llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.cpp
M llvm/lib/Target/AMDGPU/AMDGPUTargetTransformInfo.h
M llvm/test/CodeGen/AMDGPU/amdgpu-inline.ll
M llvm/test/Transforms/Inline/AMDGPU/amdgpu-inline-alloca-argument-cost.ll
Log Message:
-----------
[InlineCost][TargetTransformInfo][AMDGPU] Consider cost of alloca instructions in the caller (2/2)
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.
Reviewed By: scchan
Differential Revision: https://reviews.llvm.org/D149741
Compare: https://github.com/llvm/llvm-project/compare/9e37142dc12a...dd1df099ae37
More information about the All-commits
mailing list