shader: lower s_sext_i32_i8/i16, s_cmov_b32/b64 and s_cmovk_i32 in gfx2hlsl (Part of #1723) #2071
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2071
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2071/head"
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?
@tedin7 on GitHub · 2026-11-25 00:01 UTC · original
tedin7:x2w-b3-s-sext-cmov→main· +202 −4 · 6 files · 5 commits · merged 2026-11-25 01:57 UTCPart 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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:01 UTC · original · edited 2026-11-25 00:10 UTC
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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:10 UTC · original
For 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 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:10 UTC · original
For 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 👍 / 👎.
@ -2260,1 +2260,4 @@"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sopk_signext_check.py")# Scalar sign-extends and conditional moves (batch 3 #2).add_test(NAME startup_gfx2hlsl_s_sext_cmov COMMAND "${INTAKE_PYTHON}" -B"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_s_sext_cmov_check.py")@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:10 UTC · original
This 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 👍 / 👎.
@tedin7 on GitHub · 2026-11-25 01:00 UTC · original
SCC preservation was fixed in f4ac3e62 (rebased); both sext entries use SCC None and the fixture checks an unset SCC stays unchanged. Latest head dc7d54e2.
AI-assisted; commands listed were executed locally: python3 -B tests/startup_gfx2hlsl_s_sext_cmov_check.py
@tedin7 on GitHub · 2026-11-25 01:00 UTC · original
Fixed 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
@ -2260,1 +2260,4 @@"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_sopk_signext_check.py")# Scalar sign-extends and conditional moves (batch 3 #2).add_test(NAME startup_gfx2hlsl_s_sext_cmov COMMAND "${INTAKE_PYTHON}" -B"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_s_sext_cmov_check.py")@tedin7 on GitHub · 2026-11-25 01:00 UTC · original
Fixed 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
@R0Y00 on GitHub · 2026-11-25 01:35 UTC · original
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.
@R0Y00 on GitHub · 2026-11-25 01:52 UTC · original
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.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:10 UTC · original · reviewed
💡 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".