tests: pin the absolute-value and negated-mask refusals on the select #1769

Merged
triggered02 merged 1 commit from upstream-pr/1776 into main 2026-11-24 18:49:44 +00:00
triggered02 commented 2026-11-24 18:23:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-24T18:23:45Z.


Follow-up to the merged #1710, closing the two test-coverage nits from tedin7's re-review at f9e815d5. Tests only — no production change.

Nit 1 — the negated mask is refused, and now pinned

The reviewer asked for a decoder-produced -s0 mask control or a note on why it cannot be encoded. It can be decoded: setting w1[31] on the select makes the decoder print -s0 (LLVM will not assemble that spelling, which is why no fixture existed). Production already refuses it, because the mask goes through u():

v_cndmask_b32_e64 v31, v30, v30, -s0   -> REFUSED: operand '-s0'

The test now asserts that, with a comment stating the encoding is decoder-produced only.

Nit 2 — source absolute values are refused, and now pinned

The PR text said |v| stays refused but nothing pinned it. The encoder now carries the abs bits, and three cases cover it:

v_cndmask_b32_e64 v31, |v30|, v30, s0    -> REFUSED: operand '|v30|'
v_cndmask_b32_e64 v31, v30, |v30|, s0    -> REFUSED: operand '|v30|'
v_cndmask_b32_e64 v31, |v30|, |v30|, s0  -> REFUSED: operand '|v30|'

Verification

startup_gfx2hlsl_cndmask_neg: 22 checks, PASS
dev:     startup_gfx2hlsl* 10/10 passed
release: startup_gfx2hlsl_cndmask_neg Passed 0.14 s
docs_links_check, bidi_controls_check: pass

Fail-first, both new control classes fail when the property is broken:

route the mask through u_src      -> "a negated mask is refused" FAIL
strip the abs bars in u_src       -> "absolute values on both sources are refused" FAIL

Not in this PR

The reviewer's nit 3 — v_cndmask_b32_e64 … vcc_lo emitting (vcc & 1) — is pre-existing and they flagged it as out of scope; it stays untouched here.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588586141 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1776). Originally posted by [triggered02](https://github.com/triggered02) on 2026-11-24T18:23:45Z. --- Follow-up to the merged #1710, closing the two test-coverage nits from tedin7's re-review at `f9e815d5`. Tests only — no production change. ## Nit 1 — the negated mask is refused, and now pinned The reviewer asked for a decoder-produced `-s0` mask control or a note on why it cannot be encoded. It can be decoded: setting `w1[31]` on the select makes the decoder print `-s0` (LLVM will not assemble that spelling, which is why no fixture existed). Production already refuses it, because the mask goes through `u()`: ``` v_cndmask_b32_e64 v31, v30, v30, -s0 -> REFUSED: operand '-s0' ``` The test now asserts that, with a comment stating the encoding is decoder-produced only. ## Nit 2 — source absolute values are refused, and now pinned The PR text said `|v|` stays refused but nothing pinned it. The encoder now carries the abs bits, and three cases cover it: ``` v_cndmask_b32_e64 v31, |v30|, v30, s0 -> REFUSED: operand '|v30|' v_cndmask_b32_e64 v31, v30, |v30|, s0 -> REFUSED: operand '|v30|' v_cndmask_b32_e64 v31, |v30|, |v30|, s0 -> REFUSED: operand '|v30|' ``` ## Verification ``` startup_gfx2hlsl_cndmask_neg: 22 checks, PASS dev: startup_gfx2hlsl* 10/10 passed release: startup_gfx2hlsl_cndmask_neg Passed 0.14 s docs_links_check, bidi_controls_check: pass ``` Fail-first, both new control classes fail when the property is broken: ``` route the mask through u_src -> "a negated mask is refused" FAIL strip the abs bars in u_src -> "absolute values on both sources are refused" FAIL ``` ## Not in this PR The reviewer's nit 3 — `v_cndmask_b32_e64 … vcc_lo` emitting `(vcc & 1)` — is pre-existing and they flagged it as out of scope; it stays untouched here. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 19:01:27 +00:00
tedin7 commented 2026-11-24 19:01:27 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:48:12Z.

Review: COMMENTED


Reviewed at commit 8f333a8a406bfd39d09ba4e756d5218fc7782efd (tests/startup_gfx2hlsl_cndmask_neg_check.py).

Code Review

  • encode_vop2_e64 adds abs0/abs1 (w0[8]/w0[9]) and neg_mask (w1[31]), matching the VOP3A bit layout decoded by tools/disasm_rdna2.py.
  • The four new assertions pin refusals for abs0=1, abs1=1, abs0=1, abs1=1, and neg_mask=1 on v_cndmask_b32_e64.
  • Clean-room verified; 0 P1 / 0 P2 findings.

Verification

  • Linux:
    • git diff --check origin/main...HEAD: pass
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: pass (Checked 1303 tracked source, script and build/CI files: no bidirectional controls.)
    • /root/.local/share/x2w-rev-venv/bin/python -B tests/startup_gfx2hlsl_cndmask_neg_check.py: pass (22/22 checks, PASS)
  • Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev, ctest --preset dev -R '^startup_gfx2hlsl_cndmask_neg$' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.24s: startup_gfx2hlsl_cndmask_neg 0.15s)
    • Release /O2 (--preset release, ctest --preset release -R '^startup_gfx2hlsl_cndmask_neg$' --parallel 6 --no-tests=error --output-on-failure): 1/1 passed (0.25s: startup_gfx2hlsl_cndmask_neg 0.15s)
  • Local mutation checks (reverted after verification):
    1. Routing ops[3] mask through self.u_src(ops[3]) in tools/startup/gfx2hlsl.py: failed a negated mask is refused (exit code 1).
    2. Stripping |...| bars in u_src() in tools/startup/gfx2hlsl.py: failed all three absolute-value refusal checks (exit code 1).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045316655 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1776#pullrequestreview-6045316655). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:48:12Z. **Review:** COMMENTED --- Reviewed at commit `8f333a8a406bfd39d09ba4e756d5218fc7782efd` (`tests/startup_gfx2hlsl_cndmask_neg_check.py`). ### Code Review - `encode_vop2_e64` adds `abs0`/`abs1` (`w0[8]`/`w0[9]`) and `neg_mask` (`w1[31]`), matching the VOP3A bit layout decoded by `tools/disasm_rdna2.py`. - The four new assertions pin refusals for `abs0=1`, `abs1=1`, `abs0=1, abs1=1`, and `neg_mask=1` on `v_cndmask_b32_e64`. - Clean-room verified; 0 P1 / 0 P2 findings. ### Verification - **Linux**: - `git diff --check origin/main...HEAD`: pass - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: pass (`Checked 1303 tracked source, script and build/CI files: no bidirectional controls.`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/startup_gfx2hlsl_cndmask_neg_check.py`: pass (22/22 checks, `PASS`) - **Win2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - Debug (`--preset dev`, `ctest --preset dev -R '^startup_gfx2hlsl_cndmask_neg$' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`0.24s`: `startup_gfx2hlsl_cndmask_neg` `0.15s`) - Release `/O2` (`--preset release`, `ctest --preset release -R '^startup_gfx2hlsl_cndmask_neg$' --parallel 6 --no-tests=error --output-on-failure`): **1/1 passed** (`0.25s`: `startup_gfx2hlsl_cndmask_neg` `0.15s`) - **Local mutation checks** (reverted after verification): 1. Routing `ops[3]` mask through `self.u_src(ops[3])` in `tools/startup/gfx2hlsl.py`: failed `a negated mask is refused` (exit code 1). 2. Stripping `|...|` bars in `u_src()` in `tools/startup/gfx2hlsl.py`: failed all three absolute-value refusal checks (exit code 1). AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 19:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:24:06Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T18:26:00.305485Z 8f333a8 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140592898 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1776#issuecomment-7140592898). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:24:06Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8f333a8a406bfd39d09ba4e756d5218fc7782efd","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T18:26:00.305485Z">2026-11-24T18:26:00.305485Z</relative-time> | `8f333a8` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
ChazY11 commented 2026-11-24 19:01:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T18:26:05Z.


Ran it and tried to break each new case

At 8f333a8a, no device needed:

out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_cndmask_neg_check.py
PASS      (exit 0)

Five mutations, each restored afterwards. Every one is caught, and by the case you would expect:

mutation result
NEG bit test 1 << (29 + i) → 1 << (28 + i) caught
NEG bit test → 1 << (30 + i) caught
source == 255 dropped from the immediate range caught
raise Unsupported('v_cndmask_b32 with %s' % mods) → pass caught
u()'s raise Unsupported('operand %r' % tok) → `return self.u(tok.strip(' ').lstrip('-'))`

The last one is the interesting one for this PR: making the integer operand reader quietly strip | and - fails exactly
an absolute value on the second source is refused, absolute values on both sources are refused and
a negated mask is refused, i.e. the new cases are what stops a modifier from being silently dropped from the emitted text.

source == 255 being caught means the inline -1 boundary is pinned too, which matters because that is the value the
disassembler prints for both plain -1 and 1 with NEG — the ambiguity the comment in the decoder describes.

The encoder change

encode_vop2_e64 now takes abs0/abs1/neg_mask and places them at word 0 bits 8/9 and word 1 bit 31. Those
positions match the VOP3A layout the rest of the file uses (omod at 27, neg0/neg1 at 29/30, clamp at 15), so the
fixture and the decoder agree on the encoding rather than the fixture being tuned until it passes — which is the failure
mode I look for in a word-level test.

One suggestion, not a blocker

The five new cases come after case 7 with a comment block; the existing cases are numbered through 7 but the new ones are
not number 8+. If the numbering is deliberate for a later group, ignore this.

Verdict

Reviewed 8f333a8a. Every added case is load-bearing against a plausible edit, and the refusal the PR relies on
(u() refusing an unmodelled operand) is covered from both directions. No objections.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140639700 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1776#issuecomment-7140639700). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T18:26:05Z. --- ## Ran it and tried to break each new case At `8f333a8a`, no device needed: ```powershell out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_cndmask_neg_check.py ``` ```text PASS (exit 0) ``` Five mutations, each restored afterwards. Every one is caught, and by the case you would expect: | mutation | result | |---|---| | NEG bit test `1 << (29 + i)` → `1 << (28 + i)` | **caught** | | NEG bit test → `1 << (30 + i)` | **caught** | | `source == 255` dropped from the immediate range | **caught** | | `raise Unsupported('v_cndmask_b32 with %s' % mods)` → `pass` | **caught** | | `u()`'s `raise Unsupported('operand %r' % tok)` → `return self.u(tok.strip('|').lstrip('-'))` | **caught**, and the report names the three new cases | The last one is the interesting one for this PR: making the integer operand reader quietly strip `|` and `-` fails exactly `an absolute value on the second source is refused`, `absolute values on both sources are refused` and `a negated mask is refused`, i.e. the new cases are what stops a modifier from being silently dropped from the emitted text. `source == 255` being caught means the inline `-1` boundary is pinned too, which matters because that is the value the disassembler prints for both plain `-1` and `1` with NEG — the ambiguity the comment in the decoder describes. ## The encoder change `encode_vop2_e64` now takes `abs0`/`abs1`/`neg_mask` and places them at word 0 bits 8/9 and word 1 bit 31. Those positions match the VOP3A layout the rest of the file uses (`omod` at 27, `neg0`/`neg1` at 29/30, `clamp` at 15), so the fixture and the decoder agree on the encoding rather than the fixture being tuned until it passes — which is the failure mode I look for in a word-level test. ## One suggestion, not a blocker The five new cases come after case 7 with a comment block; the existing cases are numbered through 7 but the new ones are not number 8+. If the numbering is deliberate for a later group, ignore this. ## Verdict Reviewed `8f333a8a`. Every added case is load-bearing against a plausible edit, and the refusal the PR relies on (`u()` refusing an unmodelled operand) is covered from both directions. No objections. ## Notes - AI-assisted review.
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!1769
No description provided.