startup: lower v_{add,sub,subrev}_co_ci_u32 in gfx2hlsl #2420
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2428"
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 stan495 on 2026-11-25T16:27:46Z.
Summary
Lower RDNA 2 32-bit carry/borrow-in and out vector integer arithmetic (_add_co_ci_u32, _sub_co_ci_u32, _subrev_co_ci_u32, both VOP2 _e32 and VOP3b _e64 spellings) in ools/startup/gfx2hlsl.py.
Verification
bd6ddcfc(based on upstream/main7092683a)python -B tests/startup_gfx2hlsl_add_sub_co_ci_check.py-> PASS (checked 768 grid points, 0 failures)python -B tests/startup_gfx2hlsl_add_sub_co_check.py-> PASSpython -B tests/startup_gfx2hlsl_handler_arity_check.py-> PASS (33 accepted instructions, 99 scalar refusals, 16 load refusals)python -B tests/startup_gfx2hlsl_operand_count_check.py-> PASS (VEC_F 32 ops, VEC_U 41 ops, 0 failed)python -B tests/docs_links_check.py-> PASS (19 Markdown files, 464 links)python -B tests/bidi_controls_check.py-> PASS (1723 tracked files)Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T17:02:18Z.
Review: COMMENTED
Review of head
bd6ddcfc, merged locally with currentmaine06aca8b. The merge is clean.Result: no P1 or P2 findings. One observation and a nit.
What I checked
A + B, then+ ci). The sub and subrev paths take the borrow from bothB > Aandci > (A - B), which isA - B - ci < 0without a 33-bit intermediate. Both match the RDNA 2 definitions. Everything goes throughaandwbeforeDandSDSTare written, the same way ascarry_out_op, so overlappingD,SDSTor the carry-in with a source is safe.exec_lo: it's accepted as a lane mask. The prologue always declaresexec = 1, so the emitted(exec & 1u)compiles and reads 1 on active lanes, whether or not exec is known.Commands executed (Windows 11 build 26300)
checked 768 grid points, 0 failures-mcpu=gfx1013), all six_e32and_e64forms in the testv_add_co_ci_u32_e64 v4, s18, v4, v3, s18givesd5281204 004a0704both waysquad_perm) and SDWA formsv_add_co_ci_u32_dpp,SDWA form of v_add_co_ci_u32)_e64withexec_locarry-in, and with an inline-constantS0Mutations, each applied to
carry_in_out_opand then reverted:+ cistep: the test fails, first atA=0, B=0xffffffff, ci=1, and on the-1constant carry-in case.- cistep: the test fails atA=0, B=0, ci=1for sub and subrev.A=0, B=1, ci=0.Observation, not blocking
The test is translator-level only. There's no GPU draw and no
binary <llvm-mc>mode, which mostgfx2hlsllowering PRs carry. For pure 32-bituintarithmetic the compiler risk is low, and the llvm-mc agreement above covers the encodings. Abinarymode in the check would keep them pinned in CI's LLVM 15 job.Nit
\tbecame a tab before "ools/",\vdropped thevofv_add_co_ci_u32andvcc, and\aturned the scratch registerainto a control character. A literal0ualso seems to have lost its0.Title and body are neutral. The change is original in-repo work.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T18:23:58Z.
Review: APPROVED
Approved at head
bd6ddcfc. This is the same commit I reviewed above, with no P1 or P2 findings. Under the updated merge scope, translation PRs can now be merged after verification.Re-verified against current
mainThe branch merges cleanly with
maina6c8d80d;tools/startup/gfx2hlsl.pyauto-merges.checked 768 grid points, 0 failures.Negative control (from my review above)
Each mutant fails the new check:
+ cistep;- cistep;The six synthetic
_e32and_e64words match llvm-mc 15.0.7.Required 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.The non-blocking observation still stands: the check is translator-level, with no draw and no
binarymode. The PR-body escape nit is cosmetic.AI-assisted; commands listed were executed locally.