[all-commits] [llvm/llvm-project] 130080: [AMDGPU] Skip register uses in AMDGPUResourceUsage...

Diana Picus via All-commits all-commits at lists.llvm.org
Tue Jun 3 02:21:09 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 130080fab11cde5efcb338b77f5c3b31097df6e6
      https://github.com/llvm/llvm-project/commit/130080fab11cde5efcb338b77f5c3b31097df6e6
  Author: Diana Picus <Diana-Magda.Picus at amd.com>
  Date:   2025-06-03 (Tue, 03 Jun 2025)

  Changed paths:
    M llvm/docs/AMDGPUUsage.rst
    M llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUResourceUsageAnalysis.cpp
    M llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.h
    M llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
    M llvm/lib/Target/AMDGPU/SIRegisterInfo.h
    M llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll
    M llvm/test/CodeGen/AMDGPU/amdgpu-no-agprs-violations.ll
    M llvm/test/CodeGen/AMDGPU/amdhsa-kernarg-preload-num-sgprs.ll
    M llvm/test/CodeGen/AMDGPU/amdpal-callable.ll
    M llvm/test/CodeGen/AMDGPU/amdpal-elf.ll
    M llvm/test/CodeGen/AMDGPU/attr-amdgpu-flat-work-group-size.ll
    M llvm/test/CodeGen/AMDGPU/attr-amdgpu-waves-per-eu.ll
    M llvm/test/CodeGen/AMDGPU/call-alias-register-usage-agpr.ll
    M llvm/test/CodeGen/AMDGPU/call-alias-register-usage0.ll
    M llvm/test/CodeGen/AMDGPU/call-alias-register-usage1.ll
    M llvm/test/CodeGen/AMDGPU/call-alias-register-usage2.ll
    M llvm/test/CodeGen/AMDGPU/call-alias-register-usage3.ll
    M llvm/test/CodeGen/AMDGPU/call-graph-register-usage.ll
    M llvm/test/CodeGen/AMDGPU/coalescer_remat.ll
    M llvm/test/CodeGen/AMDGPU/code-object-v3.ll
    M llvm/test/CodeGen/AMDGPU/elf-notes.ll
    M llvm/test/CodeGen/AMDGPU/flat-scratch-reg.ll
    M llvm/test/CodeGen/AMDGPU/function-resource-usage.ll
    M llvm/test/CodeGen/AMDGPU/hsa-metadata-kernel-code-props.ll
    M llvm/test/CodeGen/AMDGPU/hsa.ll
    A llvm/test/CodeGen/AMDGPU/init-whole-wave-vgpr-count-large.ll
    A llvm/test/CodeGen/AMDGPU/init-whole-wave-vgpr-count-leaf.ll
    A llvm/test/CodeGen/AMDGPU/init-whole-wave-vgpr-count-use-inactive.ll
    A llvm/test/CodeGen/AMDGPU/init-whole-wave-vgpr-count.ll
    M llvm/test/CodeGen/AMDGPU/ipra.ll
    M llvm/test/CodeGen/AMDGPU/mcexpr-knownbits-assign-crash-gh-issue-110930.ll
    M llvm/test/CodeGen/AMDGPU/multi-call-resource-usage-mcexpr.ll
    M llvm/test/CodeGen/AMDGPU/pal-metadata-3.0-callable.ll
    M llvm/test/CodeGen/AMDGPU/ps-shader-arg-count.ll
    M llvm/test/CodeGen/AMDGPU/register-count-comments.ll
    M llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
    M llvm/test/CodeGen/AMDGPU/schedule-amdgpu-tracker-physreg.ll
    M llvm/test/CodeGen/AMDGPU/schedule-amdgpu-trackers.ll
    M llvm/test/CodeGen/AMDGPU/schedule-regpressure-limit2.ll
    M llvm/test/CodeGen/AMDGPU/stack-realign-kernel.ll
    M llvm/test/CodeGen/AMDGPU/tid-kd-xnack-any.ll
    M llvm/test/CodeGen/AMDGPU/tid-kd-xnack-off.ll
    M llvm/test/CodeGen/AMDGPU/tid-kd-xnack-on.ll
    M llvm/test/CodeGen/AMDGPU/unnamed-function-resource-info.ll
    M llvm/test/CodeGen/AMDGPU/vgpr-agpr-limit-gfx90a.ll
    A llvm/test/CodeGen/AMDGPU/vgpr-count-compute.ll
    A llvm/test/CodeGen/AMDGPU/vgpr-count-graphics.ll

  Log Message:
  -----------
  [AMDGPU] Skip register uses in AMDGPUResourceUsageAnalysis (#133242)

Don't count register uses when determining the maximum number of
registers used by a function. Count only the defs. This is really an
underestimate of the true register usage, but in practice that's not
a problem because if a function uses a register, then it has either
defined it earlier, or some other function that executed before has
defined it.

In particular, the register counts are used:
1. When launching an entry function - in which case we're safe because
   the register counts of the entry function will include the register
   counts of all callees.
2. At function boundaries in dynamic VGPR mode. In this case it's safe
   because whenever we set the new VGPR allocation we take into account
   the outgoing_vgpr_count set by the middle-end.

The main advantage of doing this is that the artificial VGPR arguments
used only for preserving the inactive lanes when using the
llvm.amdgcn.init.whole.wave intrinsic are no longer counted. This
enables us to allocate only the registers we need in dynamic VGPR mode.

---------

Co-authored-by: Thomas Symalla <5754458+tsymalla at users.noreply.github.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list