shader: lower s_sext_i32_i8/i16, s_cmov_b32/b64 and s_cmovk_i32 in gfx2hlsl (Part of #1723) #2064
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2071"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T00:01:10Z.
Part of #1723
What this unblocks: batch 3 item #2, five scalar opcodes (
s_sext_i32_i8,s_sext_i32_i16,s_cmov_b32,s_cmov_b64,s_cmovk_i32) that startup shaders hit and gfx2hlsl refused.s_sext_i32_i8/i16sign-extend the low 8/16 bits and set SCC toresult != 0.s_cmov_b32/b64ands_cmovk_i32writeSCC ? source : old destinationand leave SCC alone;s_cmovk_i32sign-extends its 16-bit immediate. Lane-mask operands,m0/exec/vccdestinations and the discard destination are refused.Verification:
python3 -B tests/startup_gfx2hlsl_s_sext_cmov_check.py->all ok(on origin/main the same test fails withAssertionError: refused: s_sext_i32_i8)python3 -B tests/startup_gfx2hlsl_s_lshl_add_check.py-> exit 0python3 -B tests/startup_gfx2hlsl_bit_alu_check.py-> exit 0python3 -B tests/startup_gfx2hlsl_op_refusals_check.py-> exit 0python3 -B tests/startup_gfx2hlsl_refusals_check.py-> exit 0startup_gfx2hlsl_s_sext_cmovin CMakeLists.txt.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:10:18Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
adf137b943ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:00:14Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:00:16Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:00:18Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:01:24Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
adf137bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:10:18Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1928For shaders that compare before
s_sext_i32_i8/i16and consume that condition afterward, these entries silently replace it with(result != 0). Both RDNA2 instructions preserve SCC, as the existingtools/pixel_aot.pyscalar table already models withNone. With incoming SCC=1, extending zero followed bys_cmov_b32therefore incorrectly keeps the old destination instead of moving the source. Set the SCC rule toNoneand update the new fixture to verify preservation of both incoming SCC states rather than asserting a nonzero-result flag.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:10:18Z.
Code review location:
tools/startup/gfx2hlsl.py; line 964For a register pair,
is_lane_mask()checks only its starting SGPR, so a mask stored in the high word bypasses this guard and is treated as a complete 32-bit scalar. With SCC=1, the LLVM-accepted sequences_mov_b32 s3, exec_lo; s_cmov_b64 s[4:5], s[2:3]; s_lshr_b32 s5, s5, 1produces zero instead of0x7fffffffon an all-active wave: the translator stores only the lane's EXEC bit ins3, then copies it into an untaggeds5. Check both registers of each source and destination pair before accepting the full-width move.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-25T00:10:18Z.
Code review location:
CMakeLists.txt; line 2204This adds five previously refused startup-translator instructions, but neither
README.mdnordocs/experiments.mdchanges with the public capability, contrary to the requirement inAGENTS.md. A documentation search finds existing notes for these mnemonics underpixel_aot, not this translator. Update the capability documentation with the supported/refused operand forms and thepython3 -B tests/startup_gfx2hlsl_s_sext_cmov_check.pyreproduction command, explicitly distinguishing CPU evaluation from Windows/D3D12 validation.AGENTS.md reference: AGENTS.md:L211-L212
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:00:14Z.
Code review location:
tools/startup/gfx2hlsl.py; line 1928SCC preservation was fixed in
f4ac3e62(rebased); both sext entries use SCC None and the fixture checks an unset SCC stays unchanged. Latest headdc7d54e2.AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_s_sext_cmov_check.py
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:00:16Z.
Code review location:
tools/startup/gfx2hlsl.py; line 964Fixed in
dc7d54e2: s_cmov_b32/b64 now check both halves of the source and destination pairs for a lane mask, with a regression test (fails before, passes after).AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_s_sext_cmov_check.py
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:00:17Z.
Code review location:
CMakeLists.txt; line 2204Fixed in
dc7d54e2: README row plus a docs/experiments.md section list supported and refused forms, the reproduction command, and state that this is CPU evaluation only, not Windows/D3D12 validation.AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_s_sext_cmov_check.py
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:35:38Z.
I resolved the CTest conflict and kept both registrations. The conditional move now uses the same signed SOPK immediate parser as the merged sign-extension change, and register pairs are checked for width, alignment, and range before use. On Windows the scalar sext/cmov, SOPK, cselect, mask overwrite, scalar arity, and documentation checks passed. The SOPK fixture still rejects an out-of-range immediate.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T01:52:04Z.
The overlapping updates left s_cmovk truncating out-of-range text and loosened pair checks. I kept your CTest update and restored the shared SOPK parser and exact pair validation, with five refusals in the dedicated cmov test. Valid binary cmov cases, SOPK, cselect, mask overwrite and scalar arity pass.