[llvm] [WIP][AMDGPU] Improve the handling of `inreg` arguments (PR #133614)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 22 10:28:29 PST 2026
================
@@ -3130,8 +3221,17 @@ SDValue SITargetLowering::LowerFormalArguments(
llvm_unreachable("Unexpected register class in LowerFormalArguments!");
EVT ValVT = VA.getValVT();
- Reg = MF.addLiveIn(Reg, RC);
- SDValue Val = DAG.getCopyFromReg(Chain, DL, Reg, VT);
+ SDValue Val;
+ // If an argument is marked inreg but gets pushed to a VGPR, it indicates
+ // we've run out of SGPRs for argument passing. In such cases, we'd prefer
+ // to start packing inreg arguments into individual lanes of VGPRs, rather
+ // than placing them directly into VGPRs.
+ if (RC == &AMDGPU::VGPR_32RegClass && Arg.Flags.isInReg()) {
+ Val = Spiller.readLane(Chain, DL, Reg, VT);
+ } else {
+ Reg = MF.addLiveIn(Reg, RC);
+ Val = DAG.getCopyFromReg(Chain, DL, Reg, VT);
----------------
shiltian wrote:
Yes indeed.
https://github.com/llvm/llvm-project/pull/133614
More information about the llvm-commits
mailing list