Repository navigation
compute: treat scalar min, max and absdiff as SCC writers - #3301
Conversation
s_absdiff_i32, s_min_u32, s_min_i32 and s_max_i32 already write SCC in the direct lowering. uses_scc_after still treated them as readers, so a symbolic descriptor field ahead of them was refused. Classify them with the other overwrites. Refs R0Y00#3224 Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
Resolved: tests/native_direct_container_check.py (kept this branch's s_min/s_max/s_absdiff SCC-writer checks and main's s_or_saveexec checks, in that order).
|
I reviewed the diff (not run). Treating these ops as SCC writers looks right. The PR only changes the liveness list in
The branch also conflicts with AI-assisted. |
|
Merged Resolved conflict. What I ran on
Since then 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. |
pigalot
left a comment
There was a problem hiding this comment.
I reviewed 1fae35a5 merged over main bbf4687b. The merge is clean (tree d7e61802) and git diff --cached --check is clean. This is the first content review of this PR; the merge of main was pushed by another session. main has since moved to 336e1206 (#3014, #3302). Neither touches either changed file, and the merge is still clean.
Merge resolution. git show --remerge-diff 1fae35a5 shows that only tests/native_direct_container_check.py conflicted. Both sides are kept:
- this branch's four
descriptor-*-kills-scccases anddescriptor-absdiff-then-cselect; main'ss_or_saveexec_b32cases.
In uses_scc_after, the overwrites list now has both main's s_or_saveexec_b32 and 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:
- the min/max block writes
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 overwrites next to s_max_u32 is right. s_cselect, s_cmov and 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), writing s26 from s22, s23. 0x85191716 is s_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_reasons in dev and release, then ran:
ctest --test-dir out/build/<preset> --no-tests=error -j 4 -R '^native_' -E '_hardware'
python .agentic\scripts\with_gpu_lock.py ctest --test-dir out/build/<preset> --no-tests=error -j 1 -R '^native_.*(scalar|sop|scc|absdiff|min|max|direct|bytewin|descriptor).*_hardware$'- Non-hardware: 154 tests per preset. 136 pass and 18 skip with 77 (capability skips), in both Debug and Release
/O2.native_direct_containerandnative_bytewin_store_controlspass. - Hardware: 9/9 pass in both presets, including
native_descriptor_scc_hardware,native_absdiff_hardware,native_bytewin_store_hardwareandnative_int32_minmax3_hardware.
Mutants. check_scc_writer_mutant reads the .inl source, so a mutant of the list fails at its count == 1 assert 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 from overwrites, rebuilt compile_dxil in dev, and ran the copy:
| Mutant | Result |
|---|---|
s_min_u32 not an overwrite |
killed (its descriptor-…-kills-scc compile refuses) |
s_min_i32 not an overwrite |
killed |
s_max_i32 not an overwrite |
killed |
s_absdiff_i32 not an overwrite |
killed |
So 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 main pins those values. Each mutant below was rebuilt in dev and 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):
| Mutant | Result |
|---|---|
scalar min/max SCC from <=/>= (ties set SCC; D unchanged) |
survives |
| scalar min/max SCC not written | survives |
s_absdiff_i32 SCC inverted |
killed by native_absdiff_hardware |
This PR doesn't change those predicates. But it lets a later s_cselect consume 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_b32 of 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 Windows passes on 1fae35a5.
This reply was AI-assisted.
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 2e44056: 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)