Repository navigation
startup: guard and verify 64-bit VOP3 shifts in gfx2hlsl - #1783
Conversation
97e556d to
e899a9b
Compare
tedin7
left a comment
There was a problem hiding this comment.
Peer review of head e899a9bd373c591652da3052afdac78df6b73fef (PRODUCTION_REVIEW_ONLY, technical comment only).
Result: no P1/P2 defects found in the local verification.
Checked by reading the diff and the surrounding translator code:
lshl_b64,lshr_b64,ashr_i64(tools/startup/gfx2hlsl.py): the shift amount is masked to 6 bits. Thesb == 0carry case is guarded, so there is no>> 32undefined shift. The>= 32branch is correct for all three (zero fill for the logical ones, sign fill for the arithmetic one).- The
r64temporary is written once and then split into both destination registers. A partial overlap such asv[3:4] <- v[2:3]therefore reads the sources before either destination is written. - Operand validation refuses modifiers, odd or unaligned SGPR pairs,
vcc/execpairs, float-inline shift amounts, and 64-bit inline constants outside -16..64. These are rejected asUnsupported, not mis-lowered. - The new test is registered in CMake (controls + warp + hardware) and in both windows.yml lists.
Non-blocking note: the PR is CONFLICTING against current main (58de158). git merge-tree reports content conflicts in .github/workflows/windows.yml and CMakeLists.txt (adjacent test registrations). tools/startup/gfx2hlsl.py merges cleanly. A rebase is needed before merge. The technical review above is against the PR head.
Local mutations (Linux, then restored with git checkout -- .):
uint2(ah, sf)->uint2(ah, 0u)inashr_i64:startup_gfx2hlsl_shift64_check.pyfails with "v_ashrrev_i64: emitted helper matches reference on 648 cases".sh < 32u->sh <= 32uinlshl_b64: the same check fails with "v_lshlrev_b64: emitted helper matches reference on 648 cases".
Commands run:
git diff --check <merge-base>...HEAD: cleantests/bidi_controls_check.py: passtests/startup_gfx2hlsl_shift64_check.py: passtests/startup_gfx2hlsl_operand_count_check.py,tests/startup_gfx2hlsl_bit_alu_check.py,tests/startup_translator_check.py: pass- docs_links_check: not applicable, no docs touched
- Windows Server 2025 (build 26100, MSVC 14.44, WARP) at the same commit
e899a9bd, targetsoffscreen_check, regexstartup_gfx2hlsl_shift64_controls|_warp|startup_translator, py-checkstartup_gfx2hlsl_shift64_check.py:- Debug (
--preset dev): 3/3 tests passed - Release
/O2(--preset release): 3/3 tests passed - Python check: ok
- Debug (
- The 298
*_hardwaretests were not run (the VM exposes WARP only).
AI-assisted; commands listed were executed locally.
|
#1818 is now on main with the three shift helpers. This branch still has distinct value in its binary round-trip, partial-overlap and masked-write checks, exact WARP/hardware draws, and malformed operand controls. Please carry those forward on main using the landed helpers. Keep a small production guard where a control finds a real gap, for example a register pair extending beyond the architectural range. Avoid carrying a second helper implementation. The scoped follow-up can keep your commits and evidence here. |
e899a9b to
2857ddc
Compare
tedin7
left a comment
There was a problem hiding this comment.
Re-review of head 2857ddc4c40710468c8fd367397be6bdb602bfe5 (startup: guard and verify 64-bit VOP3 shifts in gfx2hlsl), checked out at exactly that SHA. Verdict: no P1, no P2. The earlier findings are closed.
What the branch is now
After #1818 landed, this branch no longer adds helpers: the diff against current origin/main is 18 lines in tools/startup/gfx2hlsl.py (guards), the 389-line tests/startup_gfx2hlsl_shift64_check.py, three CMake registrations and two windows.yml entries. That follows the maintainer's request to carry the checks forward without a second helper implementation.
Earlier findings
- Previous review (
e899a9bd): the only open point wasCONFLICTINGagainst main.git merge-tree --write-tree HEAD origin/mainnow reports 0 conflicts. - My review of #1818 (P2):
shift64did not clearuniform_vfor the destination pair, so a laterv_readfirstlane_b32could accept a register that now holds a lane-varying shift result. This head addsself.uniform_v.discard(dst[1])anddiscard(dst[2]), and the test64-bit shift invalidates uniform_v for both destination registerschecks it. Closed.
What I checked in the guards
i64_words: VGPR pairs must end at or belowv255; SGPR pairs must start even and end at or belows105; the inline integer regex is now0|-?[1-9]\d*within -16..64, so spellings like-0,00or+1are refused; everything else (literals, floats,vcc,exec, other ranges) raisesUnsupported.shift64: exactly three operands; destination pair a VGPR pair ending at or belowv255; the shift amount is a single register in range (not a pair), notvcc/exec, not a float inline constant. A float inline constant as a count is refused although the hardware would use its raw bits; that is conservative, not wrong.- The helpers themselves are the ones already on main (checked in my #1818 review), and the test evaluates the emitted text on 648 cases per operation against an independent 64-bit reference, with the three per-operation mutations and a partial-overlap control (
v[3:4] <- v[2:3]). - Clean-room and title-neutral: source-built fixtures only; no title is named.
Commands run (Linux, exactly 2857ddc4)
python3 -B tests/startup_gfx2hlsl_shift64_check.py -> rc=0, every check ok (helpers, overlap, accepted forms, 37 refusals, uniform_v)
for t in tests/startup_gfx2hlsl*_check.py -> all pass
git diff --check origin/main...HEAD -> clean
python3 -B tests/docs_links_check.py -> Checked 18 Markdown files and 376 links
python3 -B tests/bidi_controls_check.py -> no bidirectional controls
git merge-tree --write-tree HEAD origin/main -> 0 conflicts
Mutations of tools/startup/gfx2hlsl.py (each restored; git status clean)
| mutation | result |
|---|---|
| SGPR pair even-alignment check removed | test FAILS (refusal list) |
both uniform_v.discard calls removed |
test FAILS (64-bit shift invalidates uniform_v) |
VGPR destination upper bound (dst[2] > 255) dropped |
test FAILS (refusal list) |
vcc/exec/float shift-count guard dropped |
test FAILS (refusal list) |
| operand-count guard removed | test FAILS (IndexError, an error rather than a refusal, so the guard is exercised) |
| inline constant range widened to 128 | test FAILS (refusal list) |
P3
- The
startup_gfx2hlsl_shift64_{warp,hardware}draws and thebinarymode (llvm-mc-15) were not run here.
Limits
No dxc/fxc, renderer or llvm-mc on this host, so the draw and binary-round-trip parts of the test were not run, and the generated HLSL was not compiled. Those need the Windows CI job. The PR changes no C++.
AI-assisted; commands listed were executed locally.
Ran the new check, then broke each guard it claimsAt the PR head, device-free: out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_shift64_check.py
pointer-holding SGPR pair refused: ok
modifiers, invalid operands and wrong counts refused (37 cases): ok
exit 0
out/pe-env/Scripts/python.exe -B tests/startup_gfx2hlsl_b64_shift_check.py
exit 0Four mutations to the guards this PR adds, each reverted; the new check goes red for every one while the landed
The last one is the one I would have expected to slip through: forgetting to invalidate the high half of a written pair is a Scope of what I checkedI mutated the four guards; I did not re-derive the 389-line fixture's binary round-trip or its WARP/hardware draw modes — Small thing
VerdictReviewed. Every guard the description lists is pinned by the new check, and the shared lowering is untouched (the second Notes
|
Refs #1723
Summary
Scoped follow-up on top of #1818 (
shl64,shr64u,shr64ialready landed onmain), carrying forward the binary round-trip, partial-overlap,exec-masked, WARP/hardware draw, and malformed-operand coverage without duplicating the shift helpers:tools/startup/gfx2hlsl.py):i64_words(): enforce architectural pair bounds (vup tov255, even-alignedsup tos105) and refuse malformed decimal tokens.shift64(): enforce exact operand count (len(ops) == 3), architectural destination bound (dst[2] <= 255), valid 32-bit shift amount (ops[1]not a register pair, withinv255/s105, notvcc/execor a float inline constant), and invalidateuniform_vfor both overwritten destination VGPRs.shl64/shr64u/shr64ihelpers and{ uint2 t = ...; vX = t.x; vY = t.y; }emission untouched (startup_gfx2hlsl_b64_shiftstays green).tests/startup_gfx2hlsl_shift64_check.py):shl64,shr64u,shr64i) against an independent 64-bit Python reference across 648(lo, hi, amount)cases per op (1,944 total, covering all shifts0..63plus wrapped counts>= 64), static shift-count< 32checks, partial-overlap corruption controls (v[3:4] <- v[2:3]), inline sign-extension (-1,1),exec-masked emission,uniform_vinvalidation, pointer-SGPR-pair refusal, and 37 malformed-operand/modifier/count refusals.binary <llvm-mc>round-trip verification of all fixture encodings for the Ubuntupixel-binaryCI job.draw <dxc> <offscreen_check> <warp|hardware> [fxc]end-to-end FXCps_5_1+ DXCps_6_0offscreen readbacks covering both disjoint (v[12:13]) and partially overlapping (v[3:4] <- v[2:3]) shifts across boundary shift counts (0, 1, 31, 32, 33, 63, 64, 0xffffffc1), plus per-op GPU mutation controls (dropped cross-word carry forshl64/shr64u, logical shift forshr64i).CMakeLists.txt,.github/workflows/windows.yml): registerstartup_gfx2hlsl_shift64_{controls,warp,hardware}and addtests/startup_gfx2hlsl_shift64_check.pytopixel-binary(binary llvm-mc-15) andpython-linux.Verification
df40e4bc(upstream/main, includes startup: lower the 64-bit vector shifts #1818)10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0, FXC + DXC1.9.2602.17Microsoft Basic Render Driver(1414:008c), driver10.0.26100.9818, D3D12 debug layer enabledNVIDIA GeForce RTX 5080(10de:2c02), driver32.0.16.2124, D3D12 debug layer enabledCommands and Observed Results
startup_gfx2hlsl_b64_shift_check.py: PASS;startup_gfx2hlsl_shift64_check.py: 1,944 helper evaluations, 3 draw-0 mutations, 3 partial-overlap controls,uniform_vinvalidation, 38 refusals ok;startup_gfx2hlsl_operand_count_check.py:0 failed;docs_links_check.py: 18 files / 376 links ok;bidi_controls_check.py: 1326 files ok).startup_gfx2hlsl_b64_shift: passed (0.09 s)startup_gfx2hlsl_shift64_controls: passed (0.13 s)startup_gfx2hlsl_shift64_warp: passed (2.09 s), FXCps_5_1and DXCps_6_0matched all 12 draws per compiler and rejected all 3 deliberate mutations with exact expected mutated words,debug_errors=0 debug_warnings=0.startup_gfx2hlsl_shift64_hardware: passed (7.91 s) onNVIDIA GeForce RTX 5080(driver32.0.16.2124, D3D12 debug layer enabled), identical readbacks and mutation failures for FXCps_5_1and DXCps_6_0,debug_errors=0 debug_warnings=0.Observed: 4 passed, 0 skipped, 0 failed (9.61 s:
b64_shift0.09 s,controls0.13 s,warp1.93 s,hardware7.43 s).Note:
tests/startup_gfx2hlsl_shift64_check.py binary llvm-mc-15was not run locally (llvm-mcis not installed on this Windows host); fixture words were cross-checked againsttools/disasm_rdna2.py/gfx2hlsl.decode()and are exercised by the Ubuntupixel-binaryCI job.Scope note: these passing fixtures verify 64-bit shift guards, helper semantics, and desktop GPU execution in isolation; they do not establish full-game startup.