[llvm] [AMDGPU] Use new CSR cost calculation (PR #219220)
Lukas Sommer via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 01:59:41 PDT 2026
================
@@ -109,7 +109,9 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo {
// Stack access is very expensive. CSRs are also the high registers, and we
// want to minimize the number of used registers.
- unsigned getCSRCost() const override { return 100; }
+ unsigned getCSRFirstUseCost(const MachineFunction &) const override {
+ return 27;
----------------
sommerlukas wrote:
> It might make sense to add a brief comment justifying 27.
I've expanded the comment (now moved to the `.cpp` file) to include the different factors.
> I'd also expect this needs to consider the calling convention. kernels don't have any CSRs
If the calling convention for the function doesn't have any CSR, the register allocator doesn't query the cost, so for a kernel the value returned here doesn't really matter. However, I'm now returning `0` in that case now to make this explicit.
https://github.com/llvm/llvm-project/pull/219220
More information about the llvm-commits
mailing list