Wave64 on Wave32: s_cbranch_scc0 after s_and_b64 branches per lane #66
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/DoubleGhosty--cool_fox#66
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@steven-seagull27 on GitHub · 2026-11-27 05:45 UTC · original
On
963f7195, a generated Wave64 compute program translates and runs on a Wave32 host, but a scalar conditional branch acts on each lane’s own comparison. A separate program that consumes the same SCC withs_cselect_b32produces the expected wave-wide value.The fixture uses 64 threads. It narrows EXEC to lanes below a supplied limit and compares the remaining lane IDs with one selected ID.
s_and_b64 s[18:19], vcc, execsets SCC when any active lane matched. The branch-only control usess_cbranch_scc0to choose between storing literal 1 and literal 2. Neither arm changes EXEC. When the selected lane is active, all active lanes should store 2. When it is absent, all active lanes should store 1. Inactive output stays zero. These scalar instruction and EXEC rules are documented in the AMD RDNA 2 ISA guide, §§3.9, 7.3, 12.1 and 12.5.For example, with 48 active lanes and lane 37 selected, lane 37 stored 2. Lanes 0, 31, 32 and 47 stored 1 instead of 2. Lane 48 kept zero. Across nine inputs, every branch-only word matched the lane-local predicate. The group-wide HLSL matched the independent CPU expectation for every word. Windows inbox WARP advertised only Wave4 and ran zero Wave32 comparisons.
The direct lowerer refused the combined fixture with
a lane mask exchanged where not every lane runs. The normal emitter accepted it through thewithout skipsWave32 retry. The tests use generated instruction words, a scalar descriptor-load wait, and a fresh zeroed UAV for each readback. The reference above is the documented ISA calculation and independent HLSL; a physical AMD ISA run would provide another comparison.The test-only commit and HLSL source apply to
963f7195. On Windows:The second command prints every actual vector and fails its equality check on the affected build. The independent HLSL check can be run separately:
AI-assisted investigation and verification.
github-bot referenced this issue2026-11-27 08:16:47 +00:00
@DoubleGhosty on GitHub · 2026-11-27 08:41 UTC · original
Fixed in commit
9a4aa8d3. Non-EXEC s_cbranch_scc0/1 branches reading scc_some now lower via wave_wide (waveAnyTrue + Wave32 half-exchange) instead of per-lane evaluation. Verified on Wave32 hardware (both_halves_observe_the_same_mask_scc_on_a_wave32_device: 0/64 mismatches across all Combined/Branch/Select cases) and victory-shader unit tests.@steven-seagull27 on GitHub · 2026-11-27 09:08 UTC · original
I confirmed
9a4aa8d3fixes the original branch, scalar-select, and combined cases on both the RTX 5080 and WARP 1.0.22. Each case had 0/576 incorrect readbacks on each adapter.Moving the store into each branch arm exposed a separate EXEC issue. With 48 lanes active and lane 37 matched, lanes 48–63 wrote
2even though their output should have stayed0. The branch decision was correct across the whole wave, but the stores still needed each lane's EXEC guard. With the follow-up patch, boths_cbranch_scc0ands_cbranch_scc1went from 127/576 wrong to 0/576 on each adapter. Patch and regression tests in #78.