Description
Target branch cpp-migration. Part of #2935 (instruction coverage). I am taking this; please say if you already have it locally and I will drop it.
Gap: the direct C++ compute path lowers v_readfirstlane_b32 but not v_readlane_b32 or v_writelane_b32. Those two exist only inside pixel full-wave islands (gfx1013_direct_graphics.inl). On top of that, the decoder refuses a lane read whose scalar destination is above s105, so vcc_lo gets "invalid scalar lane read destination" (gfx1013_compute_native.cpp:361-365). The usual source of these instructions is SGPR spilling into VGPR lanes.
Measured on a local capture of 2,689 compute requests (counts and instruction shape only). Occurrences are static instruction counts in each program up to its s_endpgm, not executed counts. A request counts once per row if it contains at least one such instruction, and can appear in several rows.
| Form | Requests | Occurrences |
|---|---|---|
v_readlane_b32 to an SGPR, constant lane |
1,066 | 411,343 |
v_writelane_b32, constant lane |
887 | 417,790 |
v_readlane_b32 to vcc_lo, constant lane |
686 | 13,022 |
v_readlane_b32 to an SGPR, lane in an SGPR |
72 | 3,375 |
I also ran compile_dxil --jobs 8 gfx1013-direct-cs@36 --requests over the same capture. Its request reader was patched locally to main's 28cs revision (the change in #2939), and #2937 was applied. 625 requests stop first at "invalid scalar lane read destination".
Plan (in gfx1013_compute_native.cpp and gfx1013_direct_compute.inl, next to v_readfirstlane_b32):
v_readlane_b32 sD, vS, lane:waveReadLaneAt(vS, lane & 31)for wave32;- for a split guest wave64, take the half that
lane & 63selects, withexchange_halvesasv_readfirstlane_b32does; - the lane is a constant, or an SGPR read as a uniform value.
v_writelane_b32 vD, sS, lane: writesStovDonly in the selected lane; other lanes keepvD. Per the RDNA2 ISA description,v_writelane_b32ignores EXEC, and the test checks that.- Accept
vcc_lo(106) as the destination ofv_readlane_b32andv_readfirstlane_b32in direct compute, written like the other scalar writes to VCC. In wave64 only 106 is written and 107 is kept.- The decoder check at line 361 is shared, so it is relaxed and 106 is refused again in the graphics paths and in the HLSL-native compute path (
gfx1013_compute_native.cpp:1062). vcc_hi,exec,m0and the rest stay refused.
- The decoder check at line 361 is shared, so it is relaxed and 106 is refused again in the graphics paths and in the HLSL-native compute path (
- Add
v_readlane_b32to the multi-wave64 convergence guard (gfx1013_compute_native.cpp:1474), since it usesexchange_halves. - Refuse when the selected lane may have no host thread: a thread count that is not a multiple of 32, or a constant lane beyond the wave's thread count. A lane held in an SGPR requires full waves.
- Keep refused: modifiers, a lane source that is not a constant or an SGPR, and VGPR ranges out of bounds.
- Scope: values are lowered numerically.
transferclears the destination symbol (gfx1013_compute_native.cpp:504-507), so a spilled descriptor, pointer or lane mask does not keep its symbol through a refill. Carrying the symbol through is a follow-up; main needed startup: spill descriptors, pointers and lane masks to VGPR lanes in compute #2759 for the same thing. Some of the 625 requests will therefore stop later on that.
Tests, in the style of native_dpp_mirror_check.py, on hardware against a CPU reference, with a capability skip where 32-lane waves are unavailable:
- spill and refill round trips through several lanes;
- a readlane into
vcc_lothat then feedsv_cndmask; - a lane held in an SGPR;
v_writelanewith lanes disabled by EXEC;- refusals for a partial wave and for
vcc_hi.
Mutants: read lane lane ^ 1, and let v_writelane honour EXEC.
AI-assisted.
Activity
Leyukaka commentedon Nov 26, 2026
Scope change in the pull request for this issue:
vcc_hiis accepted as a lane-read destination in direct compute after all. In wave32 it is ordinary scalar data (s107), and a 64-bit read of VCC reads s106:s107. The measured programs refill a spilled VCC pair withv_readlane_b32 vcc_lofollowed byv_readlane_b32 vcc_hi, so keepingvcc_hirefused would stop them one instruction later. In wave64 s107 stays the high half of VCC; the graphics and HLSL paths still refuse both.AI-assisted.
shader: lower v_readlane_b32 and v_writelane_b32 in the direct C++ co…
MasterDomino commentedon Nov 26, 2026
Closed by #2950, merged into
cpp-migrationas641add96.native_lane_access_hardwarepasses on an RTX 5080 (author) and on an RX 9070 XT, and a lane-^1 mutation fails it. AI-assisted.