Skip to content

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

Merged
tedin7 merged 1 commit into
R0Y00:mainfrom
triggered02:startup/cndmask-controls
Nov 24, 2026
Merged

tedin7 merged 1 commit into
R0Y00:mainfrom
triggered02:startup/cndmask-controls

Conversation

@triggered02

Copy link
Copy Markdown
Contributor

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).

Review nits on the merged R0Y00#1710: the PR text says a source absolute value stays refused and a negated mask cannot be assembled, but nothing pinned either. The encoder gains the abs bits and the mask negate bit, and the test now asserts that |v30| on either source (and both), and a decoder-produced -s0 mask, are refused. All four spellings are words the decoder produces but llvm-mc rejects, so the property under test is the refusal of the printed operand. Fail-first: routing the mask through u_src fails 'a negated mask is refused'; stripping the abs bars fails 'absolute values on both sources are refused'. 22 checks; startup_gfx2hlsl* dev family and the release test pass.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
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.

@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

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.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tedin7
tedin7 merged commit 3c92436 into R0Y00:main Nov 24, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants