Skip to content

xshader: lower s_quadmask, s_bitreplicate and nor/xnor/orn1 saveexec - #285

Merged
brcly merged 1 commit into
brcly:mainfrom
JohnVonWells:xshader/scalar-quad-masks
Nov 27, 2026
Merged

brcly merged 1 commit into
brcly:mainfrom
JohnVonWells:xshader/scalar-quad-masks

Conversation

@JohnVonWells

Copy link
Copy Markdown
Contributor

Adds nine scalar forms that the translator refused.

Quad mask and bit replication: s_quadmask_b32, s_quadmask_b64 and s_bitreplicate_b64_b32. They use the existing ordinary-scalar proof in scalar_bits.rs, so they translate only for ordinary scalar values. Applied to EXEC or VCC they are pixel-quad operations, and those stay refused. s_quadmask sets SCC from the result, and s_bitreplicate leaves SCC alone. wide_bit_result now counts s_bitreplicate_b64_b32 as a pair result, so the live-in analysis sees both destination words.

Saveexec: s_nor_saveexec, s_xnor_saveexec and s_orn1_saveexec, in b32 and b64 forms. They join the existing saveexec lowering, with the RDNA2 combinations ~(S0 | EXEC), ~(S0 ^ EXEC) and ~S0 | EXEC.

Checks

  • GPU control: tools/check_scalar_masks_gpu.py runs all nine forms on a D3D12 GPU against the ISA pseudocode. Operands and the starting EXEC are dynamic. It records the saved mask, the new mask, SCC, whether the invocation's lane stays active, SCC kept across s_bitreplicate, and one in-place s_quadmask_b64. Result on the RX 6950 XT: 192 inputs, 8,064 results, all correct.
  • Baseline: the previous translator refuses the program.
  • Negative controls: a wrong orn1 combination fails 12 of 12 dispatches, and so does a quad bit shifted by one.
  • CPU oracle: tools/check_scalar_bits.py now also covers the three scalar forms: 2,430 cases and 9,720 values, all correct (the numerical section of the existing scalar-bits receipt).

scalar-masks is now part of tools/check_translator_gpu.py. python tuxbox.py check on the RX 6950 XT passes completely: Lanes, the D3D12 regression controls and all translator checks. There is no run on an NVIDIA card yet.

Coverage of single decodable ALU instructions goes from 498 to 504 translated.

Evidence: evidence/scalar-masks-control.json.

AI-assisted.

Add s_quadmask_b32/b64 and s_bitreplicate_b64_b32 to the ordinary scalar
bit operations. They use the existing reaching-definition proof, so
they are translated only for ordinary scalar values; applied to EXEC or
VCC they are pixel-quad operations and stay refused. s_quadmask sets
SCC from the result; s_bitreplicate preserves it. wide_bit_result now
treats s_bitreplicate_b64_b32 as a pair result for the live-in and
symbolic analyses.

Add s_nor_saveexec, s_xnor_saveexec and s_orn1_saveexec in b32 and b64
forms to the existing saveexec lowering, with the RDNA2 combinations
~(S0 | EXEC), ~(S0 ^ EXEC) and ~S0 | EXEC.

tools/check_scalar_masks_gpu.py runs all nine forms on a D3D12 GPU
against the ISA pseudocode with dynamic operands and EXEC values,
recording saved and new masks, SCC and the invocation's lane: 192
inputs, 8,064 results, zero mismatches. A wrong orn1 combination or a
shifted quad bit fails it. The CPU scalar-bit oracle covers the three
new scalar forms: 2,430 cases, 9,720 values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NhDbTJdTcjebsL5u7pwFoY
@brcly
brcly merged commit ba7ea03 into brcly:main Nov 27, 2026
2 checks passed
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.

2 participants