Repository navigation
startup: lower v_mul_hi_i32 and s_mul_hi_i32 in gfx2hlsl - #2405
Conversation
Six mutations, all caught — and the helper's formula checks out against a reference on 100 boundary pairs plus 20 000 random onesBaseline:
The last one is the one I did not expect to be pinned, because it guards a shape rather than a value; a check that only compared results would miss it. Independent arithmetic checkThe signed multiply-high is built on the unsigned one: uint mul_hi_i32(uint a, uint b) { return mul_hi_u32(a, b) - ((a >> 31) != 0u ? b : 0u)
- ((b >> 31) != 0u ? a : 0u); }I evaluated that identity in Python against So the formula is right, including Two things the check could add without touching production1. 2. The Neither is a blocker; the change is correct and the controls are stronger than most. AI-assisted; the six mutations and the arithmetic check were run locally on Windows 11 build 26300.9974. |
|
APPROVED: +12/-6 gfx2hlsl.py adding signed mul_hi_i32 via mul_hi_u32+sign correction. word_pack/mask_dest/arity guard updated. 303-line test with 361-pair grid, mutations, GPU draws. ChazY11 review verified formula on 20K pairs and 6 mutations. No game files. |
Closing the loop on the note above:
|
tedin7
left a comment
There was a problem hiding this comment.
Review of head 29536aa (comment only, no approval).
Code (tools/startup/gfx2hlsl.py): the signed correction mul_hi_u32(a,b) - (a<0 ? b : 0) - (b<0 ? a : 0) is the standard identity and is correct modulo 2^32. v_mul_hi_i32 (VEC_U) and s_mul_hi_i32 (SCA) sit next to their unsigned siblings. The whole-word, lane-mask, vcc/exec and bounds guards of s_mul_hi_u32 are reused. The new operand-count guard also covers the unsigned form. SCC stays unchanged, as for the unsigned op.
Test: the new check covers the helper over a 361-pair edge grid (INT_MININT_MIN, INT_MIN-1, -1*-1, mixed signs), refusals, and WARP/hardware readback with an unsigned-multiply mutation control. It is registered in CMakeLists.txt (controls, warp, hardware) and in both lists in windows.yml. The PR's own CI run exercised the changed workflow: pixel-binary, python-linux and the Windows build are green.
Siblings and duplicates: v_mul_hi_u32 and s_mul_hi_u32 are already handled. A search for other open or merged PRs on mul_hi_i32 found none. #532 (draft) and #1278 (merged) cover other integer multiplies. No "depends on" in the body.
Windows results: the body lists WARP and hardware runs on branch commit 29536aa, which is this exact head. I did not run Windows and did not re-check those results. No startup claim is made. The PR is 30 commits behind main and I did not update it, to keep the head SHA.
Commands run locally on this head:
- python3 -B tests/startup_gfx2hlsl_mul_hi_i32_check.py (all ok)
- git diff --check origin/main...HEAD (clean)
- python3 tests/docs_links_check.py (19 files, 464 links ok)
- python3 tests/bidi_controls_check.py (ok)
- Mutation 1: dropped the
bsign-correction term. The test fails at "emitted helper matches reference on 361 edge pairs". - Mutation 2: removed
s_mul_hi_i32from the whole-word list. The test fails at "mask-marked SGPR source refused". - Both mutations were reverted.
No blocking findings. Merge is left to @R0Y00 / MasterDomino.
AI-assisted; commands listed were executed locally.
# Conflicts: # tools/startup/gfx2hlsl.py
|
Pushed 570e4ea: merged current Conflicts resolved, keeping both sides:
Verification:
AI-assisted; commands listed were executed locally. |
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
R0Y00#2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
…2659) * startup: accept sample_b and get_lod under entry EXEC after a join image_sample_b and image_get_lod refused any prior branch target even when EXEC was still the entry mask (M200-01 B/L: outside straight-line with every lane active). Drop the blocks gate; keep the pixel + exec_known proof. Fixtures: uniform join before the op accepted; divergent EXEC refused; WARP draw of join-before sample_b bias -1. Refs #2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * startup: require wave-uniform CF for sample_b and get_lod Review on #2659: dropping only the blocks gate accepted vcc/exec branches before SampleBias / CalculateLevelOfDetail. Track uniform_cf (cleared by divergent s_cbranch_*), keep scc-uniform joins, and refuse vccz/vccnz/execz/execnz before the op in both fixtures. Refs #2618 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * startup: refuse sample_b and get_lod inside a loop with a divergent back edge A divergent backward branch after the read still lets lanes of one quad leave the loop at different passes, so the read runs again with uneven quads although no divergent branch precedes it in program order. Record the read sites and the divergent back edges and refuse a read that one of them spans. Tests: synthetic words with s_cbranch_vccnz/execnz right after the read, back to it (fail before, pass after). * test: allow s_mul_hi_* own-arity templates in scalar table check #2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> Co-authored-by: tedin7 <tommasoderosa94@gmail.com>
* shader: lower s_quadmask_b32 in gfx2hlsl (#1723) Port the pixel_aot nibble-collapse SOP1 (each 4-bit group to one bit of D). SCC is the nonzero test of the result. Lane masks and descriptor words are refused. CPU fixture with a negative control. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * test: add D3D12 WARP dispatch readback for s_quadmask_b32 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * docs: note s_quadmask_b32 WARP dispatch ctest Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * test: allow s_mul_hi_* own-arity templates in scalar table check #2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> Co-authored-by: tedin7 <tommasoderosa94@gmail.com>
#2630) * startup: lower constant-trip mesh57 loops outside exchanges (#2413 T6) Accept one proven constant-trip SCC back-edge in translate_mesh57 by unrolling it; keep data-dependent, EXEC-carrying, and unconditional loops refused by the existing named reason. Source-built fixture draws with a CPU rasteriser oracle; the once-through mutant fails that reference. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * tests: spell mesh57 loop branches as numeric SOPP offsets llvm-mc encodes labeled s_cbranch targets differently from the relative SIMM16 words the fixture embeds; match startup_mesh57_skeleton.s style. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * startup: tighten mesh57 loop trip signedness and once-through draw oracle Take compare signedness alone, refuse reversed s_sub trip steps, and require a real draw-reference mismatch for the once-through mutant. Refs #2413 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * test: allow s_mul_hi_* own-arity templates in scalar table check #2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
#2637) * startup: lower constant-lane writelane/readlane spills in translate_mesh57 Accept the #2127 constant-lane v_writelane_b32 / v_readlane_b32 idiom on the slot 57 mesh request path (Part of #2413 T7). Spill-only VGPRs become scalar slots; ordinary vector use, unwritten lanes and non-constant lanes stay refused. Source-built host checks and WARP/hardware draw fixtures cover the happy path and a mutant that zeroes the spilled colour word. AI-assisted. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * startup: fix mesh57 lane-spill WARP mutant and EXEC/exchange refusals Refuse raw EXEC writelane sources under the one-lane model, scan pre-skeleton instructions so exchange VGPRs stay spill-unsafe, park an ordinary scalar in lane 63, and mutate only the colour spill assignment so the multi-decl keeps sp30_63 for DXC. Refs #2413 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * test: allow s_mul_hi_* own-arity templates in scalar table check #2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> Co-authored-by: Royoo <3230853833@qq.com>
* shader: lower s_ff0_i32_b32 in gfx2hlsl (#1723) Port the pixel_aot find-first-zero SOP1 (firstbitlow of the complement). SCC is unchanged. Lane masks and descriptor words are refused. CPU fixture with a negative control. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * test: allow s_mul_hi_* own-arity templates in scalar table check #2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> Co-authored-by: tedin7 <110300616+tedin7@users.noreply.github.com>
* shader: lower s_quadmask_b64 in gfx2hlsl (#1723) Port the pixel_aot 64-bit nibble collapse (sixteen bits in D.lo, D.hi = 0). SCC follows the full result. Lane masks, descriptors, and odd pairs refused. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> * test: allow s_mul_hi_* own-arity templates in scalar table check #2405 added s_mul_hi_i32 (and an early arity refuse for both mul_hi forms). The negative control still expected only one non-IndexError survivor. Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com> Co-authored-by: Royoo <3230853833@qq.com>
Summary
v_mul_hi_i32VOP3A ands_mul_hi_i32SOP2, SCC unchanged) intools/startup/gfx2hlsl.py, completing the signed counterpart tos_mul_hi_u32(startup: lower s_mul_hi_u32 in gfx2hlsl #2176) andv_mul_hi_u32(startup: lower v_mul_hi_u32 in gfx2hlsl #1747).Pipeline.common()'s existingmul_hi_u32(uint a, uint b)helper via a one-line signed correction (mul_hi_i32(a, b) = mul_hi_u32(a, b) - ((a >> 31) != 0u ? b : 0u) - ((b >> 31) != 0u ? a : 0u)), avoiding any duplicate halfword-product helper.s_mul_hi_u32's whole-word, lane-mask,vcc/exec, symbolic-source, and bounds guards tos_mul_hi_i32, and add an explicit 3-operand count guard fors_mul_hi_{u,i}32so malformed forms raiseUnsupportedinstead ofIndexError.tests/startup_gfx2hlsl_mul_hi_i32_check.pywith:mul_hi_i32helper over a 361-pair edge grid (includingINT_MIN * INT_MIN,INT_MIN * -1,-1 * -1, mixed signs) against((s32(a) * s32(b)) >> 32) & 0xffffffff, sign-correction drop controls, unsigned-multiply mutation controls,exec-masked emission,s_mul_hi_i32SOP2 decode/lowering/mask-overwrite/refusals, and modifier/arity refusals.binary <llvm-mc>round-trip checks for the Ubuntupixel-binaryCI job.draw <dxc> <offscreen_check> <warp|hardware> [fxc]end-to-end FXCps_5_1+ DXCps_6_0offscreen readbacks across 3 draw sets (12 pairs) plus an unsigned-multiply GPU mutation control.startup_gfx2hlsl_mul_hi_i32_{controls,warp,hardware}inCMakeLists.txtand wiretests/startup_gfx2hlsl_mul_hi_i32_check.pyintopixel-binaryandpython-linuxin.github/workflows/windows.yml.Verification
7092683a(upstream/main)29536aa310.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_mul_hi_i32_check.py: 17/17 checks ok;docs_links_check.py: 19 files / 464 links ok;bidi_controls_check.py: 1723 files ok;startup_tools_lint: passed).drop_sign_a,v_unsigned,s_unsigned,drop_arity_guard) caught (rc=1) and reverted cleanly.dev): 3 passed, 0 skipped, 0 failed (3.47 s:controls0.17 s,warp0.78 s,hardware2.46 s,debug_errors=0 debug_warnings=0).release): 3 passed, 0 skipped, 0 failed (3.02 s:controls0.17 s,warp0.67 s,hardware2.13 s).tests/startup_gfx2hlsl_mul_hi_i32_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.v_mul_hi_i32/s_mul_hi_i32lowering and desktop GPU execution in isolation; they do not establish full-game startup.