Commit Graph

2 Commits

Author SHA1 Message Date
1c5b64defb translator: active runs under --wave64-emulate too (TRANSLATOR-W64-EMULATE-ACTIVE-RUNS)
Runs of lane-local VALU instructions go under one `if (active)` (184d78905) but were left out under
--wave64-emulate, on the assumption that its rounds split blocks at instruction boundaries. A round ends a
segment only at x_split (a cross-lane exchange, a barrier or a memory-ordering point), and a lane-local
instruction is none of these, so a run sits inside one segment. insns now checks that: an x_split inside a run
stops the translation instead of cutting the `if` in two.

test_active_runs: an emulated 64- and 128-thread compute if/else with a cross-half load between its runs
gets its runs and stores the same values as the per-write selects, in both scheduling orders.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 06:24:24 +05:00
184d789058 Translator: runs of lane-local VALU instructions under one if (active)
With EXEC as a per-invocation flag, dst() writes every VGPR as OpSelect(active, new, old). Outside straight-line
code the driver can't prove the lane active, so both values stay live and each write costs a v_cndmask: a pixel
shader with 8 divergent if/else regions of fma/mul/add/min/max runs 32% slower than the same program written
natively (RX 5700 XT, RADV).

In a shader that may write EXEC, a run of two or more lane-local VALU instructions now goes inside one
OpSelectionMerge / OpBranchConditional %active and writes its VGPRs directly. Each invocation is one lane, so
skipping the run in an inactive lane keeps the old value of everything it writes, as the selects did; the driver
then predicates it with its own EXEC. Lane-local leaves out cross-lane reads (DPP, readlane, writelane, permlane,
mbcnt), lane-mask, SCC and EXEC writes (v_cmp*), carry and other scalar results written in every lane (_co_,
div_scale, mad_u64), v_interp, and masks passing through a VGPR. Inside a run, an instruction that emits anything
but VGPR stores (a vote, a barrier, an image op, a store to VCC/SCC/an SGPR, ...) fails the translation instead of
losing its EXEC behaviour. Shaders that never write EXEC translate as before, and --wave64-emulate is unchanged.

RX 5700 XT, that bench: 0.851 -> 0.693 ms (native 0.647), VGPRs 80 -> 64, 12 -> 16 waves, same image.
tests/semantic/test_active_runs.py runs a wave32 and a wave64 if/else on every lane.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 16:36:43 -06:00