startup: lower the 32-bit scalar complement logic ops #1921

Closed
ChazY11 wants to merge 1 commit from upstream-pr/1928 into main
ChazY11 commented 2026-11-24 21:31:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T21:31:31Z.


Implements #1919.

Change

tools/startup/gfx2hlsl.py, three entries in SCA, with the shapes the 64-bit forms already use:

's_nand_b32': ('~({0} & {1})', '$ != 0'), 's_nor_b32': ('~({0} | {1})', '$ != 0'),
's_xnor_b32': ('~({0} ^ {1})', '$ != 0'),

Nothing else moves: s_andn2_b32 / s_orn2_b32 / s_not_b32 and every b64 form stay as they are.

Tested

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_scalar_m0_check.py
startup scalar m0 controls passed      exit 0

ctest --preset dev -R 'startup_gfx2hlsl|startup_translator|startup_flat_param'
100% tests passed, 0 tests failed out of 31

The new cases build SOP2 words from the decoder table (s_nand_b32 0x18, s_nor_b32 0x1a, s_xnor_b32 0x1c) and
translate them:

s_nand_b32 s28, s5, s6   ->  s28 = ~(0x00000004u & s6);  scc = s28 != 0;
s_nor_b32  s28, s5, s6   ->  s28 = ~(0x00000004u | s6);  scc = s28 != 0;
s_xnor_b32 s28, s5, s6   ->  s28 = ~(0x00000004u ^ s6);  scc = s28 != 0;

(I keep the assertion on the shape — s28 = ~( plus the operator, and the exact SCC line — because this fixture's stage
folds s5 to a constant, which is not what the case is about. s_and_b32 is asserted separately as the unchanged neighbour,
with no complement.)

Fail-first

Removing one entry at a time from SCA:

s_nand_b32  exit 1
s_nor_b32   exit 1
s_xnor_b32  exit 1
restored    exit 0

so each of the three is needed on its own; the fixture does not pass because the neighbours happen to be present.

Scope

Two files: +2 lines in the translator table, +16 in the existing scalar check. No new file, no CMake change, no draw mode.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6591822469 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1928). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T21:31:31Z. --- Implements #1919. ## Change `tools/startup/gfx2hlsl.py`, three entries in `SCA`, with the shapes the 64-bit forms already use: ```python 's_nand_b32': ('~({0} & {1})', '$ != 0'), 's_nor_b32': ('~({0} | {1})', '$ != 0'), 's_xnor_b32': ('~({0} ^ {1})', '$ != 0'), ``` Nothing else moves: `s_andn2_b32` / `s_orn2_b32` / `s_not_b32` and every b64 form stay as they are. ## Tested ```powershell out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_scalar_m0_check.py startup scalar m0 controls passed exit 0 ctest --preset dev -R 'startup_gfx2hlsl|startup_translator|startup_flat_param' 100% tests passed, 0 tests failed out of 31 ``` The new cases build SOP2 words from the decoder table (`s_nand_b32` `0x18`, `s_nor_b32` `0x1a`, `s_xnor_b32` `0x1c`) and translate them: ```text s_nand_b32 s28, s5, s6 -> s28 = ~(0x00000004u & s6); scc = s28 != 0; s_nor_b32 s28, s5, s6 -> s28 = ~(0x00000004u | s6); scc = s28 != 0; s_xnor_b32 s28, s5, s6 -> s28 = ~(0x00000004u ^ s6); scc = s28 != 0; ``` (I keep the assertion on the *shape* — `s28 = ~(` plus the operator, and the exact SCC line — because this fixture's stage folds `s5` to a constant, which is not what the case is about. `s_and_b32` is asserted separately as the unchanged neighbour, with no complement.) ## Fail-first Removing one entry at a time from `SCA`: ```text s_nand_b32 exit 1 s_nor_b32 exit 1 s_xnor_b32 exit 1 restored exit 0 ``` so each of the three is needed on its own; the fixture does not pass because the neighbours happen to be present. ## Scope Two files: `+2` lines in the translator table, `+16` in the existing scalar check. No new file, no CMake change, no draw mode. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 22:00:54 +00:00
ChazY11 commented 2026-11-24 22:01:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T21:45:41Z.


Closing: #1925 by @MasterDomino is the implementation, and the issue description says "I'd like to take this; PR to follow" — I
claimed it without reading that line, exactly the mistake I made on #1820/#1896. My fault, not theirs.

Their branch also does more than mine: 11 operand forms × 2,184 value pairs against an integer reference for result and SCC,
the lane-mask forms against their and/or/xor siblings, refusals for every still-unlowered SOP2 op, and an LLVM 15 round trip.
Mine was three table entries and three SOP2 words — a cross-check at best, not an implementation.

What I will do instead: run their branch through the encode_sop2 route I proposed, as they asked, and report it on #1925. If
that route disagrees with theirs anywhere, that is worth knowing; if it agrees, an independent second path is still worth
recording.

Two corrections to my earlier comments here, so the thread is not misleading:

  • The PR number I quoted (#1923) does not exist; the branch was #1928, now closed.

  • "Each entry is needed on its own" still holds for my three lines, but that is a property of my fixture, not evidence about
    theirs.

  • AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145352278 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1928#issuecomment-7145352278). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T21:45:41Z. --- Closing: #1925 by @MasterDomino is the implementation, and the issue description says "I'd like to take this; PR to follow" — I claimed it without reading that line, exactly the mistake I made on #1820/#1896. My fault, not theirs. Their branch also does more than mine: 11 operand forms × 2,184 value pairs against an integer reference for result and SCC, the lane-mask forms against their and/or/xor siblings, refusals for every still-unlowered SOP2 op, and an LLVM 15 round trip. Mine was three table entries and three SOP2 words — a cross-check at best, not an implementation. What I will do instead: run their branch through the `encode_sop2` route I proposed, as they asked, and report it on #1925. If that route disagrees with theirs anywhere, that is worth knowing; if it agrees, an independent second path is still worth recording. Two corrections to my earlier comments here, so the thread is not misleading: - The PR number I quoted (#1923) does not exist; the branch was #1928, now closed. - "Each entry is needed on its own" still holds for my three lines, but that is a property of my fixture, not evidence about theirs. - AI-assisted.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1921
No description provided.