[llvm] AMDGPU: VALU data fast-forwarding needs no s_delay (PR #205481)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 01:42:11 PDT 2026


jayfoad wrote:

Some points raised by an AI review of this PR:

1. Bug: VALU→SALU tracking still only looks at explicit defs. The pass tracks the last SGPR written by a VALU (LastSGPRFromVALU). When a later SALU with register operands has to wait for outstanding VALU SGPR writes anyway (instructionWaitsForSGPRWrites), the pass advances its state instead of emitting a delay. That tracking loop still uses MI.defs(), which is explicit defs only, while the PR switched the state update to MI.all_defs(). So an implicit SGPR def from a VALU (VCC from a VOP2 carry-out or an e32 compare, EXEC from v_cmpx) enters the state but never updates LastSGPRFromVALU, and a following SALU read gets a spurious VALU_DEP delay.
2. Wave32 inconsistency in the def-side filter. The use side maps VccReg to AMDGPU::VCC before checking the descriptor's implicit uses, but the def side calls hasImplicitDefOfPhysReg(Reg) with no register info. That's an exact match, so in wave32 implicit-def $vcc_lo doesn't match the descriptor's VCC and is skipped. So VOP2 carry-outs and e32 compares aren't tracked as producers in wave32, the default on gfx11/gfx12, but are in wave64.
3. Dead code in getVOPDComponentOpCode. The explicit-operand branch translates OpNo into the component's operand index and then throws it away, because OpNo is a by-value parameter and only the opcode is returned. The only explicit-operand consumer check (OpNo == Src2Idx, for VOP3 carry-in/cndmask) can't apply to VOPD components anyway, so the whole branch has no effect and can be removed. For implicit EXEC, both components match, so the code always picks X, which is harmless.
4. Minor: the V_READLANE_B32 and V_WRITELANE_B32 cases in the EXEC switch are unreachable. Their descriptors have no implicit EXEC use (V_READLANE_B32 parses without one), so the descriptor filter removes those operands first. Only the V_READFIRSTLANE_B32 case, which does read EXEC, matters.

https://github.com/llvm/llvm-project/pull/205481


More information about the llvm-commits mailing list