shader: lower s_mulk_i32 and s_addk_i32 in gfx2hlsl (Part of #1723) #2025
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!2025
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2025/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-24 23:26 UTC · original
tedin7:x2w-r20-s-mulk-addk→main· +157 −0 · 3 files · 1 commits · closed without mergingPart of #1723
What this unblocks: Run 20 census #5 (79/77 pairs).
Lower
s_mulk_i32ands_addk_i32intools/startup/gfx2hlsl.py. Both read and write SDST and take a 16-bit immediate. The decoder prints it as unsigned hex, so it is sign-extended first, then routed through the existing two-source scalar lowering (s_mul_i32/s_add_i32).s_addk_i32also sets SCC to the signed overflow of the add, computed from the old destination before the result is written.s_mulk_i32leaves SCC alone. A destination that is not a plain SGPR (m0, exec, vcc) is refused, and so iss_addk_i32on descriptor data (SCC would depend on it).Verification:
python3 -B tests/startup_gfx2hlsl_s_mulk_addk_check.pyon this branch:PASS. The test builds SOPK words from the decoder layout, executes the emitted statements on 32-bit values and compares them with the architectural result for immediates 0, 1, 0x7fff, 0x8000, 0xfffe, 0xffff.tools/startup/gfx2hlsl.pyfromorigin/main: fails withUnsupported: s_mulk_i32.tests/startup_gfx2hlsl_*check.pyrun one by one on this branch: all pass.startup_gfx2hlsl_s_mulk_addkin CMakeLists.txt. These were run on Linux, not on Win2025. No ctest run.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:27 UTC · original · edited 2026-11-24 23:34 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
710b1cfℹ️ 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.
@ -1753,0 +1759,4 @@raise Unsupported('%s with %d operands' % (base, len(ops)))reg = reg_range(ops[0])if not reg or reg[0] != 's' or reg[1] != reg[2] or reg[1] > 105:raise Unsupported('%s destination %s' % (base, ops[0]))@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:34 UTC · original
When SDST holds a comparison mask, this validation accepts it even though
Stage.compare()stores only the current lane's 0/1 projection and records that fact inself.masks. For example, afterv_cmp_lt_i32_e64 s4, v0, v1produces a guest low mask of0x7fffffff,s_addk_i32 s4, 1must set SCC, but the emitted expression computes on 0/1 and sets SCC false in every invocation; a following scalar select or SCC branch therefore takes the wrong path. Reject mask-tagged SGPRs before either SOPK lowering, as the complement/pack handlers already do, or model the full mask instead of treating its projection as a numeric word.Useful? React with 👍 / 👎.
@ -1753,0 +1771,4 @@word = imm & 0xffffffffif base == 's_addk_i32':if self.sym.get(reg[1]):raise Unsupported('scc from descriptor data')@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:34 UTC · original
When SDST is initialized by an immediate move or supplied as a root constant,
self.symcontains a numericconstorudentry, not descriptor data. Consequently, the ordinary sequences_mov_b32 s4, 1; s_addk_i32 s4, 1raisesUnsupported('scc from descriptor data')through the productionStageconstructor instead of lowering the addition. Numericfixed_buffer_wordentries are rejected too. Restrict this guard to genuinely non-numeric symbols so the new instruction works on initialized scalar values; the added test misses this because it starts with an empty symbol table.Useful? React with 👍 / 👎.
@ -2159,1 +2159,4 @@"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_b64_shift_check.py")# The SOPK arithmetic forms s_mulk_i32 and s_addk_i32 (#1723).add_test(NAME startup_gfx2hlsl_s_mulk_addk COMMAND "${INTAKE_PYTHON}" -B"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_gfx2hlsl_s_mulk_addk_check.py")@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:34 UTC · original
The patch introduces startup-translator support and a new CTest, but updates neither
README.mdnordocs/experiments.md.AGENTS.mdrequires documentation updates when public capabilities or reproduction commands change; the existing SOPK paragraph documentspixel_aot, not this startup lowering. Add the new startup check and its measured scope to the public experiment documentation, distinguishing the Linux emitted-statement evaluation from Windows/DXIL or GPU validation.AGENTS.md reference: AGENTS.md:L209-L210
Useful? React with 👍 / 👎.
@tedin7 on GitHub · 2026-11-25 00:30 UTC · original
Closing as superseded by #2102 which also guards mask/descriptor destinations and adds mutation controls.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-24 23:34 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
710b1cf9deℹ️ 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".
Pull request closed