tests: pin cmp16 refusals for neg/abs, literals, 16-bit conditions #2418
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2426"
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 Makto94 on 2026-11-25T16:26:10Z.
Refs #1723
Problem
tests/startup_gfx2hlsl_cmp16_check.py(added in #2369, Part of #1723) fixes the accepted 16-bit VOPC compares well, but its "Refusals" section left three guards of the lowering unpinned:_e64NEG/ABS guard incheck_encoding(). The decoder prints NEG on inline 1 as-1, the same text as inline -1 (v_cmp_lt_i16_e64 s4, -1, v2for both; ABS prints|1|). Only the raw word tells them apart, so the guard is the only protection against reading-1for1. The check exercised it forv_cmp_lt_i16_e64only.-16 <= value <= 0xffff). Only values inside the range were tried.t,lg,nlg,nlt,nle,ngt,nge,neq,o,u). Onlyv_cmp_f_i16_e64was checked.Mutants of
tools/startup/gfx2hlsl.pythat break these guards passed the check onmain(7092683a).Change
Test-only; 20 added lines in the "Refusals" section of
controls(). No file undertools/changes.neg/absfor all 24 opcodes (v_cmp/v_cmpxx 6 relations x i16/u16,_e64): 48 cases.0xffffis accepted and0x10000is refused (wider than 16 bits) for i16 and u16.v_cmp/v_cmpx(_e64): 40 cases, each with the expectedv_cmp[x]_<cond>_<type>reason.The check is already in the Linux list of
.github/workflows/windows.yml(jobpython-linux, line 259), so CI runs the new cases without a workflow change.Mutants
Each mutant edits one expression in
tools/startup/gfx2hlsl.pyat7092683a. "main check" is the unmodified check frommain; "new check" is this PR.0xffff, i16/u160xffff->0xfffeliteral 0xffff {i16,u16} accepted0x10000, i16/u16wider than 16 bits0xffff->0x10000literal 0x10000 {i16,u16}v_cmpx_*-1/|1|)x?, sov_cmpxis unguardedneg/absolute on inline 1 in v_cmpx_*i16neg/absolute on inline 1 in v_cmp[x]_*_u16neneneg/absolute on inline 1 in v_cmp[x]_ne_*v_cmp[x]_t_{i16,u16}_e64tallowedv_cmp_t_i16_e64,v_cmpx_t_i16_e64, and the u16 pairv_cmp[x]_lg_{i16,u16}_e64lgallowedv_cmp_lg_i16_e64,v_cmpx_lg_i16_e64, and the u16 pairv_cmp_lt_i16_e64lt_i16_e64onlyneg/absolute on inline 1 in v_cmp[x]_*for every other opcodeReference for M10 (decoder output, not the translator):
v_cmp_lt_i16_e64with inline 1 and NEG decodes (tools/disasm_rdna2.py,decode_instruction) tov_cmp_lt_i16_e64 s4, -1, v2, with ABS tov_cmp_lt_i16_e64 s4, |1|, v2, and with inline -1 tos4, -1, v2. The NEG and inline -1 texts are identical, so without the raw-word guard the translator would read-1where the source holds1.Verification
Commit under test:
fa464666on7092683a. Windows 11, Python 3.12, no GPU used.Expected and observed:
163 refusals: ok...PASS, exit 0 (unmodifiedmaincheck:71 refusals: ok, exit 0). With each mutant in the table applied, themaincheck still exits 0, and the new check exits 1 with163 refusals: MISMATCHfollowed by the case names listed above.Limits
binarymode (LLVM 15llvm-mc) and the draw cases were not run; the added cases do not use them.tools/.low16_onlyswitched off in the register source) cannot be told apart inProbe, so it is not covered here.maincheck and are killed by this PR; the other 17 were not re-run for this PR.gedropped from the guard,o/uallowed, upper bound< 0xffff) are also killed only by the new cases, and one (lgtable entry) is equivalent becauselgis refused first. It also confirmed againsttools/disasm_rdna2.pyanddocs/coverage/gfx1013.tsvthat i16/u16 compares exist only for lt/eq/le/gt/ne/ge.Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T17:13:06Z.
Review: APPROVED
Approved at head
fa464666. The change is test-only: 20 lines in the "Refusals" section oftests/startup_gfx2hlsl_cmp16_check.py.Commands executed (Windows 11 build 26300, Python 3.13; no GPU needed)
fa464666:163 refusals: ok, thenPASS.main38468ab8: same result, and the merge is clean.Negative control
I applied five of the listed mutants, one at a time, to
tools/startup/gfx2hlsl.py, then reverted each. Each ran against this PR's check and againstmain's check:maincheckv_cmpx?changed tov_cmp163 refusals: MISMATCH[iu]16changed toi16<= 0x10000<= 0xfffetallowedThis matches the table in the description. I also checked that the three guards the new cases target exist in
gfx2hlsl.pyas described: the NEG/ABS raw-word guard, the-16..0xffffsource bound, and the six-relation filter.Merge checks: CI passed at this head ("Build and test on Windows" and both Linux jobs). The
/O2and coverage skips come from explicit workflow conditions. There are no review threads.AI-assisted; commands listed were executed locally.