[all-commits] [llvm/llvm-project] d57ae2: [AMDGPU] Optimize S_SETREG_IMM32_B32 piggybacking ...

Shilei Tian via All-commits all-commits at lists.llvm.org
Wed Mar 4 15:25:21 PST 2026


  Branch: refs/heads/users/shiltian/further-improve-piggyback
  Home:   https://github.com/llvm/llvm-project
  Commit: d57ae2999c6e10461144daf84a7382f18285fcbd
      https://github.com/llvm/llvm-project/commit/d57ae2999c6e10461144daf84a7382f18285fcbd
  Author: Shilei Tian <i at tianshilei.me>
  Date:   2026-03-04 (Wed, 04 Mar 2026)

  Changed paths:
    M llvm/lib/Target/AMDGPU/AMDGPULowerVGPREncoding.cpp
    M llvm/test/CodeGen/AMDGPU/vgpr-setreg-mode-swar.mir

  Log Message:
  -----------
  [AMDGPU] Optimize S_SETREG_IMM32_B32 piggybacking by treating it as a mode scope boundary

When `handleSetregMode` encounters an `S_SETREG_IMM32_B32` with `Size <= 12`,
the instruction's `imm32[12:19]` bits are "free" for VGPR MSB piggybacking.
Previously, the old mode was eagerly written into these bits, but the
`Rewritten` guard in `setMode` would then block subsequent piggybacking when the
next VGPR instruction needed a different mode, causing an unnecessary
`S_SET_VGPR_MSB` to be emitted.

Model the `S_SETREG_IMM32_B32` as the boundary of the old mode's control range:
reset `CurrentMode` and clear `bits[12:19]` to zero. This lets the next
`setMode` call freely piggyback the required mode without triggering
`Rewritten`.



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