Skip to content

startup: lower s_wqm exec, exec on a narrowed EXEC as a quad vote - #2747

Closed
tedin7 wants to merge 20 commits into
R0Y00:mainfrom
tedin7:x2w-texflow-wqm
Closed

tedin7 wants to merge 20 commits into
R0Y00:mainfrom
tedin7:x2w-texflow-wqm

Conversation

@tedin7

@tedin7 tedin7 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #1723

What this unblocks: image_sample_b / image_get_lod after s_wqm_b64 exec, exec on a lane-narrowed EXEC (a kill or cmpx followed by a whole-quad restore), which was refused as a lane-EXEC break.
Source: AMD "RDNA 2" Instruction Set Architecture reference guide, SOP1 instruction S_WQM_B64 (whole-quad mode of a mask) and the EXEC / quad rules of the MIMG sample instructions; Microsoft DirectX-Specs, D3D11 functional specification, sample_b and lod.

Stacked on #2736 (this branch contains its commits until that merges; the new work is the last two commits). Builds on #2659.

What changed

  • s_wqm exec, exec on a narrowed EXEC is lowered as exec = x2w_quad_any(exec) ? 1u : 0u;: the guest turns on every lane of a quad with an active lane, which is exactly the vote the branches already use. It is taken only where the quad runs the statement together (uniform_cf holds, no earlier lane-EXEC break, pixel program without a backward branch).
  • Before: recorded as a lane-EXEC break, so the op after it was refused. Other s_wqm forms (other operands) still break and stay refused.
  • A skipped EXEC-branch block that contains an s_wqm is still not voted (the startup: keep sample_b and get_lod past a divergent EXEC with a per-quad vote #2736 vector-only gate), so the op is refused there.

Tests

  • New draw fixture wqm (cmpx, then s_wqm_b64 exec, exec, then the subtraction, then the op) in startup_image_sample_b_flow_check.py and startup_image_get_lod_flow_check.py: u1 = 1/8 when the whole quad is back on, 5/8 if s_wqm were a no-op. Mutant "s_wqm as a no-op" must fail the draw. Words reassemble with llvm-mc.
  • The wqm_break refused fixture of startup: keep sample_b and get_lod past a divergent EXEC with a per-quad vote #2736 became this accepted fixture.

Verification (Linux only):

python3 -B tests/startup_image_sample_b_flow_check.py                 rc=0
python3 -B tests/startup_image_get_lod_flow_check.py                  rc=0
python3 -B tests/startup_image_sample_b_flow_check.py binary llvm-mc-19   fixtures reassemble
python3 -B tests/startup_image_get_lod_flow_check.py binary llvm-mc-19    fixtures reassemble
for every tests/startup_gfx2hlsl_*_check.py (no arguments)            all rc=0 except the two draw-only checks that need adapter arguments (untouched)

Win2025 WARP dev+release: pending Stage-2.

AI-assisted; commands listed were executed locally.

c1 added 8 commits November 26, 2026 07:23
- a voted block may hold only instructions whose destinations are VGPRs (no carry-out, compare, readlane);
- s_endpgm in a voted block only when no EXEC write follows the branch;
- a scalar EXEC write from a non-mask source (s_mov exec, 1) records a lane-exec break.
Three refused fixtures with recorded words; each fails on the previous head.
@tedin7

tedin7 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Withdrawn: shader translation is moving to the native C++ frontend (see #870), so we are not continuing this change to the Python translator. The branch stays available if any part is useful later. Thank you to everyone who reviewed and tested it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant