Repository navigation
xshader: lower s_quadmask, s_bitreplicate and nor/xnor/orn1 saveexec - #285
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds nine scalar forms that the translator refused.
Quad mask and bit replication:
s_quadmask_b32,s_quadmask_b64ands_bitreplicate_b64_b32. They use the existing ordinary-scalar proof inscalar_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_quadmasksets SCC from the result, ands_bitreplicateleaves SCC alone.wide_bit_resultnow countss_bitreplicate_b64_b32as a pair result, so the live-in analysis sees both destination words.Saveexec:
s_nor_saveexec,s_xnor_saveexecands_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
tools/check_scalar_masks_gpu.pyruns 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 acrosss_bitreplicate, and one in-places_quadmask_b64. Result on the RX 6950 XT: 192 inputs, 8,064 results, all correct.orn1combination fails 12 of 12 dispatches, and so does a quad bit shifted by one.tools/check_scalar_bits.pynow also covers the three scalar forms: 2,430 cases and 9,720 values, all correct (thenumericalsection of the existing scalar-bits receipt).scalar-masksis now part oftools/check_translator_gpu.py.python tuxbox.py checkon 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.