compute: treat scalar min, max and absdiff as SCC writers #3301
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3301"
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 SimSalabimse on 2026-11-28T06:25:39Z.
Refs #3224.
uses_scc_after treated s_absdiff_i32, s_min_u32, s_min_i32 and s_max_i32 as SCC readers. The direct lowering already writes SCC for them: the min/max compare, and D != 0 for s_absdiff_i32. A symbolic byte-window descriptor field immediately before one of those ops was refused with "numeric SCC from a symbolic descriptor field".
They are now overwrites, next to s_max_u32. s_cselect, s_cmov and an SCC branch stay readers. A field whose result can be zero is still refused when a later instruction actually reads that SCC.
Tests. tests/native_direct_container_check.py adds source-built compute containers shaped like descriptor-sop1-preserves-scc: the address-field rewrite, then each of the four ops, then a use of the destination. descriptor-absdiff-then-cselect reads the SCC those ops just wrote. descriptor-sop1-before-scc-read still refuses s_cselect with no writer in between. check_scc_writer_mutant deletes the four overwrite entries from a copy of the list; each new case is then live and would refuse.
Linux ran that mutant and a syntax check of the test. The container compile needs the Windows test PC:
ctest --preset dev --no-tests=error -j 1 -R '^(native_direct_container|native_bytewin_store_controls)$'
Windows test PC at
2e44056f: native_direct_container and native_bytewin_store_controls both passed (2/2), and again on a second run (exit 0 both times).AI-assisted (Cursor)
Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-11-28T06:48:53Z.
I reviewed the diff (not run). Treating these ops as SCC writers looks right. The PR only changes the liveness list in
uses_scc_after. The SCC predicates in the lowering are unchanged, and neither the existing nor the new checks read the flag back:s22 = s23 = 0and checks that the container is produced. With equal operands, min, max and absdiff all give D = 0 and SCC = 0. The existing lowering would still pass if it set SCC from<=instead of<, or did not write SCC at all.descriptor-absdiff-then-cselectselects between two zero registers intos25, which nothing reads.v_movreadss26. So the select result does not depend on SCC either.s_cselect_b32between distinct constants. Useful operand pairs:0xffffffffagainst 1, which separates signed from unsigned min and max;0x80000000against 0, for absdiff.The branch also conflicts with
mainnow:mainaddeds_or_saveexec_b32on the sameoverwritesline.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T06:54:09Z.
Merged
main48ca9ab1into this branch as1fae35a5(a merge commit, no rebase) so the PR can merge again.Resolved conflict.
tests/native_direct_container_check.py: this branch's SCC-writer checks (SCC_WRITERS,check_scc_writer_mutant, thedescriptor-<name>-kills-sccanddescriptor-absdiff-then-cselectcases) andmain'sdescriptor-or-saveexec-killandor-saveexec-exec-destinationchecks are both kept, in that order.src/gfx1013_direct_compute.inlmerged without conflict, and each new writer name appears once in theuses_scc_afteroverwriteslist.What I ran on
1fae35a5.devandrelease/O2.python -B tests/native_direct_container_check.pypasses, including the SCC-writer mutant step (each new case fails once itsoverwritesentry is removed).ctest --test-dir out/build/<preset> --no-tests=error -j 8 -R '^native_' -E '_hardware$'gives 158 tests in each preset: 140 pass, 0 fail and 18 are capability skips.native_direct_containerpasses.native_wave_request_hardware,native_descriptor_scc_hardwareandnative_or_saveexec_hardwarepass 3/3 in each preset at-j 1, with no skips.ctest --test-dir out/build/dev --no-tests=error -j 8 -E '(startup_audio|_hardware$)'gives 2042 tests: 1982 pass, 0 fail and 60 are capability skips.Since then
mainhas moved tobbf4687b(#3295, #3293).1fae35a5still merges cleanly over it, and #3295's one hunk insrc/gfx1013_direct_compute.inladds a new lowering away from the SCC liveness code.This is not a review. Because I pushed the merge, another reviewer should review the PR.
Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; Python 3.12.10; wave32; debug layer off.
This reply was AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-28T07:06:16Z.
Review: APPROVED
I reviewed
1fae35a5merged overmainbbf4687b. The merge is clean (treed7e61802) andgit diff --cached --checkis clean. This is the first content review of this PR; the merge ofmainwas pushed by another session.mainhas since moved to336e1206(#3014, #3302). Neither touches either changed file, and the merge is still clean.Merge resolution.
git show --remerge-diff 1fae35a5shows that onlytests/native_direct_container_check.pyconflicted. Both sides are kept:descriptor-*-kills-scccases anddescriptor-absdiff-then-cselect;main'ss_or_saveexec_b32cases.In
uses_scc_after, theoverwriteslist now has bothmain'ss_or_saveexec_b32and this PR's four ops.What I traced. The RDNA 2 ISA defines how these ops set SCC:
S_MIN_I32/S_MIN_U32/S_MAX_I32setSCC = (S0 < S1)or(S0 > S1);S_ABSDIFF_I32setsSCC = (D != 0).The direct lowering already writes SCC for all four:
zext(pred)to SCC whenscalar;s_absdiff_i32takes the scalar tail'scmp ne z, 0.None of them reads the incoming SCC, so moving them into
overwritesnext tos_max_u32is right.s_cselect,s_cmovand an SCC branch remain readers.The new words decode as SOP2 ops 6, 7, 8 and
0x2c(s_min_i32,s_min_u32,s_max_i32,s_absdiff_i32), writings26froms22,s23.0x85191716iss_cselect_b32 s25, s22, s23.What I ran. I built
compile_dxil native_store_replay offscreen_check native_compute_ir_dump native_global_srv_heap_replay native_compute_manifest_reasonsindevandrelease, then ran:/O2.native_direct_containerandnative_bytewin_store_controlspass.native_descriptor_scc_hardware,native_absdiff_hardware,native_bytewin_store_hardwareandnative_int32_minmax3_hardware.Mutants.
check_scc_writer_mutantreads the.inlsource, so a mutant of the list fails at itscount == 1assert before any container compiles. To see whether the compiled cases catch the change on their own, I removed that call from a scratch copy of the test. Then I dropped one entry at a time fromoverwrites, rebuiltcompile_dxilindev, and ran the copy:s_min_u32not an overwritedescriptor-…-kills-scccompile refuses)s_min_i32not an overwrites_max_i32not an overwrites_absdiff_i32not an overwriteSo each new case would also fail on
main, where all four entries are missing.Non-blocking: nothing pins the SCC values these ops write. Leyukaka is right that the new cases only compile. I checked whether anything else on
mainpins those values. Each mutant below was rebuilt indevand run against all non-hardware^native_tests, then against the six hardware tests above (absdiff,descriptor_scc,int32_minmax3,scalar_lds,bytewin_store,lane_spill_descriptor):<=/>=(ties set SCC; D unchanged)s_absdiff_i32SCC invertednative_absdiff_hardwareThis PR doesn't change those predicates. But it lets a later
s_cselectconsume the min/max SCC after a symbolic field, where that program used to be refused. So the unpinned min/max flag now matters in more programs.A small readback dispatch would pin it. Store D and
s_cselect_b32of two distinct constants on the flag for:S0 < S1,S0 > S1andS0 == S1;0xffffffffagainst1, which separates signed from unsigned.That would fit a follow-up for #3224; it doesn't need to block this PR.
Verdict: approve on
1fae35a5.Environment: NVIDIA GeForce RTX 5090 driver 32.0.16.1088 and WARP, Windows 11 25H2 build 26200.9974, MSVC 19.52.37029, Windows SDK 10.0.28000.0 DXC, Python 3.12.10, wave32; I did not check the debug-layer status.
CI:
Build and test on Windowspasses on1fae35a5.This reply was AI-assisted.