amdgcn: Spill scalars to SGPRS instead of AVGPRs
Prefer SGPRs over AVGPRs for spilling scalars on AMD GPUs to improve performance and compatibility.
This change modifies the AMDGPU backend to spill scalar values to SGPRs instead of AVGPRs. AVGPRs are a more limited and expensive resource, especially around function calls. Using SGPRs for spills is more efficient and also ensures compatibility with devices lacking AVGPRs. Test cases were updated to reflect this change, with vector spills now tested for AVGPRs and scalar spills tested for SGPRs.
In Details
The AMDGPU backend's register allocator now prioritizes spilling scalar values to Scalar General-Purpose Registers (SGPRs) over Available General-Purpose Registers (AVGPRs). AVGPRs are a scarcer resource and incur higher save/restore costs around call sites. This change impacts the spill strategy in gcn_spill_class to leverage the more abundant SGPRs, improving code density and reducing call-clobbered register pressure. New test cases validate scalar spilling to SGPRs, while existing ones are adapted for vector spills to AVGPRs.
- SGPRs
- Scalar General-Purpose Registers on AMD GPUs. These registers hold scalar values and are plentiful and inexpensive to access.
- AVGPRs
- Available General-Purpose Registers on AMD GPUs. These registers can hold scalar or vector values but are a more limited resource and incur higher overhead for saving and restoring around function calls.
- Spill
- In compilers, spilling refers to the process of moving a register's value to memory when there are not enough registers available. The value is later reloaded from memory when needed.