startup: lower s_cmp_eq_u64 and s_cmp_lg_u64 in gfx2hlsl #2891
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!2891
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2891"
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?
@R0D4X on GitHub · 2026-11-26 16:42 UTC · original
R0D4X:feat/gfx2hlsl-s-cmp64→main· +403 −0 · 4 files · 1 commits · merged 2026-11-27 04:45 UTCWhat this changes
Adds lowering for the 64-bit scalar equality comparisons
s_cmp_eq_u64ands_cmp_lg_u64intools/startup/gfx2hlsl.py(previously refused as unlowered, though already decoded bytools/disasm_rdna2.py).SCCviaStage.set_scc:s_cmp_eq_u64:((a0 == b0) && (a1 == b1))s_cmp_lg_u64:((a0 != b0) || (a1 != b1))s[0:1]..s[104:105]),null(0, 0), sign-extended inline integers (-16..64), and zero-extended 32-bit hex literals.masks/mask_highon either half of a pair), VGPRs, odd or out-of-range SGPR pairs, float inline constants,m0, andsrc_scc.Tests added
tests/startup_gfx2hlsl_s_cmp64_check.py: SOPC binary decode viaG.decode(), 242 pair comparisons, inline-1sign-extension and0x80000001zero-extension checks, uniformity tracking, refusal cases, unlowered control, and FXCps_5_1+ DXCps_6_0GPU readback draws (including a negative-control draw).tests/cmake/startup_gfx2hlsl_s_cmp64.cmakeandtests/checks/python-linux/startup_gfx2hlsl_s_cmp64.txt.Verification
edda1e78(onupstream/mainb505c32b)10.0.26300.9974), MSVC19.44.35230, Windows SDK10.0.26100.0, FXC + DXC1.9.2602.17, D3D12 debug layer enabled1414:008c, driver10.0.26100.9818) and NVIDIA GeForce RTX 5080 (10de:2c02, driver32.0.16.2124)Results:
ctest --preset dev --no-tests=error -R '^startup_gfx2hlsl_s_cmp64|^startup_tools_lint$' -V-> 4/4 passed, 0 skipped (debug_errors=0 debug_warnings=0on all draws)ctest --preset release --no-tests=error -R '^startup_gfx2hlsl_s_cmp64'-> 3/3 passed, 0 skippeddocs_links_check.py,bidi_controls_check.py, scalar/arity/null/refusal checks,git diff --check) -> all passedgfx2hlsl.py(dropping high-word compare, wronglgjoin, dropping VGPR/mask-high guards, sign-extending 32-bit literals) -> 5/5 caught (rc=1)Scope: Covers synthetic gfx1013 SOPC fixtures translated by
gfx2hlsl.pyand run on WARP and RTX 5080; does not establish full-title startup or frame rate.@Leyukaka on GitHub · 2026-11-26 21:39 UTC · original
Review of head
edda1e78, from reading the diff against main6ee878d8(not run).The lowering reads as correct:
-1is sign-extended and 32-bit hex literals are zero-extended for the u64 compares;Steps 2 and 3 of the check would catch a low-word-only compare and a zero-extended
-1.Two test gaps:
ref_cmp64and Python literals, and none callsG,Probe,run_oneoreval_scc_expr, so they pass with any handler. Patching the handler, as step 9 does by deleting it, and asserting that the grid fails would make it a mutation control.ps_words()loadss4..s7withs_mov_b32of literals, whichStage.scalartracks as('const', value).S()then emits them as literals, so every draw case compiles to a compare of constants, such asscc = ((0x12345678u == 0x12345678u) && (0x9abcdef0u == 0x9abcdef0u));, and the compare never readss4..s7. The draw still checks the expression's shape through the compiler's folding, but not run-time SGPR reads. One case with a non-constants[4:5]/s[6:7]would cover that path. The fixture's root signature has no parameters, so it needs a run-time source added.AI-assisted.
@thepatrickworld on GitHub · 2026-11-26 22:21 UTC · original
Independent AMD RDNA 4 result on
edda1e78: the three entries pass, and the compared values are folded before the module reaches the driver. Not a code change; measurements only.Environment
Windows 11
10.0.26200.9974, MSVC19.44.35230(toolset14.44.35207), Windows SDK10.0.26100.0— DXC1.9.2602.17and FXC taken from.../Windows Kits/10/bin/10.0.26100.0/x64/.devpreset,debug_layer=unavailable(not installed on this host). AdapterAMD Radeon RX 9070 XT(1002:7550), driver32.0.32029.2010. Worktree atedda1e78c71f1c9b7c7296d579b3c3c50fbb516a,git status --porcelain --untracked-files=noempty.Commands
Observed
3/3 passed, 0 skipped, 10.41 s (
controls0.51,warp4.42,hardware5.41);ctest -Nreports 2445 tests and registers the three new entries. On the card: 16 renderer invocations (the 7GPU_VECTORS× {FXCps_5_1, DXCps_6_0} plus one negative-control draw per compiler), 16startup_flat_param words=readbacks (one per invocation, the negative controls included), both negative controls rejected, and every invocation printedbackend=hardware debug_layer=unavailable/adapter=AMD Radeon RX 9070 XT vendor=1002 device=7550/driver=32.0.32029.2010.Mutation matrix
Four mutants in
tools/startup/gfx2hlsl.py(the new block, lines 10034-10056), each restored withgit checkout -- <file>:MISMATCH s_cmp_eq_u64 a=(0x0,0x0) b=(0x0,0x1) got=True want=Falselgjoined with&&instead of||→MISMATCH s_cmp_lg_u64 a=(0x0,0x0) b=(0x1,0x0) got=False want=TrueMISMATCH s_cmp_eq_u64 a=(0x1,0x0) b=(0x1,0x0) got=False want=True32-bit hex literal zero-extends to 64 bits: MISMATCHThe first three die in the 242-case pair grid (step 2), the fourth in the hex-literal check (step 4). Step 10 never ran under any of them — the control run stops at its first failure — and by construction it could not see them: its five checks compare
ref_cmp64with Python expressions and never call the handler (tests/startup_gfx2hlsl_s_cmp64_check.py:293-305). The hardware entry also fails for each mutant (ctestrc=8) but in 0.29-0.31 s instead of 5.41 s, becauserun_draw()callsrun_controls()first (line 321): no mutant reaches a compile, let alone a draw. After each restoration the sha256 matched the original,git statuswas empty and the controls exited 0. Three of these re-run mutations the description names (high-word drop,lgjoin, sign-extended literal); swapping the halves of the second operand is not among them. Reading: the Python checks are the pin here, and the draw adds no mutation coverage — the file working as intended, not a hole.What the emitted shader contains
The fixture's PS for
diff_hi_onlyalready carries the comparison its own constants resolve:Dumping the DXIL of all seven vectors (compiled through the fixture's own
compile_hlsl, so the flags are identical) gives a 6-linemainwith fourdx.op.storeOutput.f32calls on immediate arguments, and noicmp,and,ororselect. At-Odthat vector still has none (79-linemain, the same four immediates). There is therefore no run-time 64-bit operand in the module: for the DXCps_6_0pair, WARP and the card compile the same text and receive the same module, so what passes covers translation, export and readback on both adapters, not a run-time compare. The FXCps_5_1DXBC was not dumped. This is the measurement behind @Leyukaka's second point, taken on the AMD host.CI
tests/checks/python-linux/startup_gfx2hlsl_s_cmp64.txtis picked up by thepython-linuxjob (--from-dir tests/checks/python-linux,.github/workflows/windows.yml:199), which runs on every pull request and push, so the controls are covered.s_cmp64is not in theprtest preset's include regex (CMakePresets.json:45), so neither draw runs on apull_request; after merge the push sweep (ctest --preset dev ... -E '_hardware$') runs_warpand excludes only_hardware.Where a run-time source already exists
tests/startup_gfx2hlsl_bfm_b64_check.pypasses four entry words as the sixth--startup-flat-paramargument (asserted forpipe.uds[:3]), and its PS reads them from thecbuffer entry : register(b0) { uint ud0; ... }thatgfx2hlsl.pyemits (uint bw = ud1 & 63u,shl64(..., ud2)). As_cmp64vector in that form would make the operands run-time reads; whether the comparison then survives to anicmpis untested here.Limits
One machine, one adapter, no debug layer,
-Oddumped for one vector only, FXC output not dumped. Nothing here speaks to title startup or frame rate.AI-assisted.
@R0Y00 on GitHub · 2026-11-27 04:44 UTC · original · approved these changes
Reviewed
edda1e78c71f1c9b7c7296d579b3c3c50fbb516a. The lowering compares both words and retains the lane-mask refusals. This fixture's operands can constant-fold in DXC, so the readbacks cover end-to-end translation and export; they are not runtime-variable compare coverage. I built the clean integration tree with current main50488e1cin Release on Windows 11 26200.9974, then ranctest --preset release --no-tests=error --output-on-failure -R '^startup_gfx2hlsl_s_cmp64_'. Its portable, WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656) tests all passed. D3D12 debug-layer output showed zero errors or warnings. Required Windows CI passed.