Skip to content

tests: add supplemental SDWA 32-bit integer compare draws and refusal controls - #1923

Merged
MasterDomino merged 1 commit into
R0Y00:mainfrom
KomaGuy:shader/sdwa-int-compares
Nov 25, 2026
Merged

MasterDomino merged 1 commit into
R0Y00:mainfrom
KomaGuy:shader/sdwa-int-compares

Conversation

@KomaGuy

@KomaGuy KomaGuy commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Rebased onto current main (214ed093) after #1790 landed all 46 non-cmpx SDWA comparisons in tools/pixel_aot.py and tools/scan_unsupported_shaders.py, keeping the supplemental per-predicate 32-bit integer draw and refusal test coverage:

What this adds

  • Per-predicate draw coverage (tests/pixel_aot_check.py, CMakeLists.txt): four 4-channel groups (i32_lo, i32_hi, u32_lo, u32_hi) covering all 16 v_cmp_*_{i32,u32}_sdwa forms across all 7 src0_sel/src1_sel selectors, zero/sign extension (sext()), and SGPR/VGPR source pairs, with 41 targeted single-channel negative controls (pixel_aot_sdwa_int_compare_{warp,hardware}) and LLVM binary round-trip fixtures in check_binary.
  • Additional static lowering & refusal controls (check_sdwa_int_compare_lowering): whole-dword equivalence with e32, single-register destination enforcement (vcc/vcc_lo/s52 accepted, SGPR pairs s[52:53]/s[51:52]/s[105:106] and out-of-range s106 rejected), low16 VGPR source rejection, pending sample and pending scalar source/destination rejection, non-entry mask rejection, float modifiers (-s44, |v18|, abs(v18), sext(-s44)), clamp, dst_sel, and remaining unlowered SDWA compare neighbours (i64, v_cmpx).
  • Docs (docs/experiments.md): notes the supplemental fixture alongside shader: lower the 46 non-cmpx SDWA comparisons #1790's entry.

Verification (Linux)

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts.
  • python3 tests/pixel_aot_check.py: PASS.
  • python3 tests/docs_links_check.py: PASS (19 files, 457 links).
  • python3 tests/bidi_controls_check.py: PASS (1641 files).
  • python3 tests/rdna2_tools_check.py: PASS (156 tests OK, 19 skipped).
  • git diff --check origin/main...HEAD: clean.

Windows draws (pixel_aot_sdwa_int_compare_{warp,hardware}) and LLVM 15 check_binary run in CI.

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head f81ecee36e093d04be1d7e7a4b0ce857103090e0 (first review). Verdict: not mergeable as it stands, no merge.

Blocking:

  • The PR conflicts with main: git merge-tree --write-tree --name-only origin/main HEAD reports a content conflict in tests/pixel_aot_check.py (GitHub: CONFLICTING/DIRTY). Please rebase.
  • Overlap: open PRs #1670 ("lower the integer SDWA comparisons") and #1790 ("lower the 46 non-cmpx SDWA comparisons") cover the same v_cmp_*_i32/u32_sdwa forms. Please say which of them this PR replaces or builds on, so only one lands.

Read of the diff (no P1/P2 found in the code itself):

  • tools/pixel_aot.py: new SDWA_INT_CMP_OPERANDS and a lowering branch that applies sdwa_source to both sources and reuses INT_COMPARE; asint for i32, raw words for u32; refuses an unbalanced sext(), pending/masked state and untracked registers.
  • tools/scan_unsupported_shaders.py: SDWA_INT_SOURCE moved above its first use; new supported-instruction pattern for the sixteen forms.
  • CMakeLists.txt adds only the registration of pixel_aot_sdwa_int_compare_.
  • docs/experiments.md: the new paragraph states the semantics come from LLVM 15 and are not measured on a console. It does not report a hardware or WARP run of the new draw tests.

Commands run locally (Linux):

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: rc=0
  • python3 tests/bidi_controls_check.py: rc=0
  • python3 tests/pixel_aot_check.py: rc=0
  • python3 tests/rdna2_tools_check.py TestRdna2Scanner: rc=0, 51 tests OK

Mutation (reverted with git checkout -- ., tree clean):

  1. scanner pattern for the new forms narrowed from (i32|u32) to (i32): rdna2_tools_check fails (rc=1), v_cmp_gt_u32_sdwa counted unsupported (3, 2, 1) instead of (3, 3, 0).

Not done: the Windows draw tests (pixel_aot_check.py draw-sdwa-int-compare) were not run, since the conflict blocks a merge anyway. No GitHub checks are reported for the branch. No receipt, no merge.

AI-assisted; commands listed were executed locally.

@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks for the distinct signed/unsigned draw and refusal cases. The 16 production forms overlap #1670 and #1790, which are already under review. Please hold this branch while we reconcile the shared implementation. The single-register destination follows the actual SDWA encoding; an aligned SGPR pair accepted by the textual parser does not establish an encodable form. If a new fixture survives the overlap review, it can land as supplemental coverage with your attribution.

@KomaGuy

KomaGuy commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Understood — I'll hold this branch while #1670 and #1790 are reconciled, and noted on the single-register SDWA destination encoding. Happy to rebase any surviving supplemental draw or refusal cases if useful.

@thepatrickworld

Copy link
Copy Markdown
Contributor

Same collision as #1747/#1793, this time on the SDWA integer comparisons: this and #1670 both add a v_cmp_*_sdwa branch to tools/pixel_aot.py, and git merge-tree pr1670 pr1923 conflicts in tests/pixel_aot_check.py, tests/rdna2_tools_check.py and tools/scan_unsupported_shaders.py. Both are dirty against main.

The two are not identical in what they cover:

  • this one matches v_cmp_(...)_(i32|u32)_sdwa only;
  • shader: lower the integer SDWA comparisons #1670 matches (i32|u32|i16|u16), so it also lowers the 16-bit comparisons;
  • this one carries the larger test surface (304 lines in pixel_aot_check.py against 198, plus form_coverage_check.py).

So the union is worth more than either alone. @R0Y00, which one do you want to land? If it is #1670, the extra cases here are worth porting; if it is this one, the i16/u16 kinds need adding.

AI-assisted.

@KomaGuy

KomaGuy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for comparing #1923 and #1670! Note that #1790 ("shader: lower the 46 non-cmpx SDWA comparisons") has since been merged into main, which already covers all 16 32-bit integer SDWA comparisons from this PR as well as the 16-bit integer and binary16/class forms.

I'm keeping this branch held per @R0Y00's earlier note — happy to close it or extract any surviving extra refusal/draw cases if useful.

@tedin7

tedin7 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

@KomaGuy could you rebase this branch onto current main and force-push?

GitHub reports head f81ecee3 as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (b1a644ae):

  • tests/pixel_aot_check.py
  • tests/rdna2_tools_check.py
  • tools/pixel_aot.py
  • tools/scan_unsupported_shaders.py

Commands run locally:

git fetch origin main pull/1923/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 1923 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

… controls

Rebase R0Y00#1923 onto current main (after R0Y00#1790 landed all 46 non-cmpx SDWA
comparisons in tools/pixel_aot.py and tools/scan_unsupported_shaders.py)
and keep the supplemental per-predicate 32-bit integer test coverage:

- Four 4-channel draw programs (i32_lo, i32_hi, u32_lo, u32_hi) covering
  all 16 v_cmp_*_{i32,u32}_sdwa forms with 41 targeted single-channel
  negative controls (signed vs unsigned, sext vs zero-extend, byte/word
  selectors, predicate swaps) registered as
  pixel_aot_sdwa_int_compare_{warp,hardware} and included in check_binary.
- Additional static lowering and refusal checks: whole-dword equivalence
  with e32, single-register destination enforcement (refusing SGPR pairs
  and out-of-range s106), low16 VGPR source refusal, pending sample and
  pending scalar source/destination refusal, non-entry mask refusal, float
  modifiers, clamp, dst_sel, and remaining unlowered SDWA compare
  neighbours (i64, v_cmpx).
@KomaGuy
KomaGuy force-pushed the shader/sdwa-int-compares branch from f81ecee to db10c4a Compare November 25, 2026 13:30
@KomaGuy KomaGuy changed the title shader: lower SDWA forms of 32-bit integer comparisons in pixel_aot tests: add supplemental SDWA 32-bit integer compare draws and refusal controls Nov 25, 2026
@KomaGuy

KomaGuy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@tedin7 Rebased onto current main (214ed093) and force-pushed db10c4ac.

Since #1790 already landed the production lowering and scanner entries for all 46 non-cmpx SDWA comparisons (including the 16 32-bit integer forms and single-register destination enforcement), this rebased head drops the duplicate tools/pixel_aot.py, tools/scan_unsupported_shaders.py, tests/rdna2_tools_check.py, and tests/form_coverage_check.py changes and keeps the supplemental per-predicate 32-bit integer draw coverage (pixel_aot_sdwa_int_compare_{warp,hardware}, 4 groups with 41 single-channel negative controls, plus check_binary) and additional refusal controls (low16 VGPR source, pending sample/scalar loads, non-entry mask, SGPR pair destinations, float modifiers, clamp, whole-dword e32 equivalence).

Verified locally on Linux (pixel_aot_check.py, docs_links_check.py, bidi_controls_check.py, rdna2_tools_check.py, git merge-tree clean, git diff --check clean). Ready for re-check once CI finishes!

@tedin7 tedin7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of head db10c4aca4cb7e5b75f2c8c90d2fa2325826e665. Verdict: 0 P1, 0 P2. This is a clean result.

Changes since my earlier review of f81ecee3:

  • The patch is different (patch-id changed), so this is a full re-review. The tools/ changes are gone; the lowering for v_cmp_*_{i32,u32}_sdwa is already on main (tools/pixel_aot.py, the INT_COMPARE branch). The PR now only adds tests.
  • The branch merges cleanly with main (git merge-tree --write-tree origin/main HEAD rc=0). The earlier conflict is resolved.
  • The overlap I raised before no longer applies to code: this PR adds no lowering. #1670 remains open on the same forms, so whichever lands second should check its tests against these.

Read of the diff (CMakeLists.txt, docs/experiments.md, tests/pixel_aot_check.py):

  • draw-sdwa-int-compare covers all 16 i32/u32 predicates in four groups, with 41 single-channel negative controls that must report a mismatch.
  • Static refusal checks cover low16 sources, pending loads, masked regions, float modifiers, clamp and SGPR-pair destinations.
  • CMake registers pixel_aot_sdwa_int_compare_<adapter> next to pixel_aot_sdwa_cmp_<adapter>, with the same timeout, skip code and coverage record.
  • The docs paragraph states that the semantics are not measured on a console.

Commands run locally (Linux):

  • git diff --check origin/main...HEAD: rc=0
  • python3 tests/docs_links_check.py: pass (19 files, 457 links)
  • python3 tests/bidi_controls_check.py: pass
  • python3 -B tests/pixel_aot_check.py: rc=0
  • Mutation 1: in tools/pixel_aot.py, asint selection changed from i32 to u32. check_sdwa_int_compare_lowering failed. Killed.
  • Mutation 2: operands swapped (values[::-1]) and asint replaced with asuint. The same check failed. Killed.
  • Mutations reverted with git checkout -- ..

Windows Server 2025 (D3D12 WARP):

  • Debug: ctest --preset dev -R '^(pixel_aot_sdwa_int_compare_warp|pixel_aot_sdwa_cmp_warp)$': 2/2 passed.
  • Release /O2: the same regex with --preset release: 2/2 passed.
  • tests/vk_offscreen.py: ok.
  • GitHub CI: Build and test on Windows = SUCCESS.

AI-assisted; commands listed were executed locally.

@Makto94

Makto94 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Hardware run and Windows 11 MSVC build at head db10c4ac.

Environment: Windows 11 Pro build 26300.9974, Debug (dev preset), MSVC 19.44.35230.0 (cl 14.44.35207), driver 32.0.16.2101 (the test does not print it; the value comes from another hardware test log on the same machine in the same session). The passing test does not print the adapter name; the only hardware adapter in this machine is an NVIDIA GeForce RTX 3070 Ti. The runs were serial (-j1); the hardware run was on an idle machine.

Build: cmake --build --preset dev exited 0. This PR changes no C++ source.

Tests:

  • ctest --preset dev --no-tests=error -j1 -R 'pixel_aot_sdwa_int_compare_warp' -V: 1/1 passed.
  • ctest --preset dev --no-tests=error -j1 -R 'pixel_aot_sdwa_int_compare_hardware' -V: 1/1 passed (draw-sdwa-int-compare). 0 capability skips (77).

offscreen_check enables the D3D12 debug layer when it is available, and other runs of the same renderer on this machine print debug_layer=enabled. The passing test log does not print the debug-layer state; debug-layer status for this run is therefore not stated.

Not covered by this run: AMD hardware, and the LLVM 15 binary path (pixel_aot_check.py binary).

@MasterDomino MasterDomino left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at head db10c4ac. The change is test-only after the rebase: tests/pixel_aot_check.py, one CTest registration and one docs line. This adds an AMD run and a lowering mutant to @tedin7's review and @Makto94's RTX 3070 Ti run.

Environment

  • Windows 11 build 26300, --preset dev (Debug), DXC from SDK 10.0.26100.
  • offscreen_check built at db10c4ac.
  • The only hardware adapter in this machine is an AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010). The passing draw doesn't print the adapter, but in this session the startup-stream drivers enumerate only this card and WARP.

Commands executed

ctest --preset dev --no-tests=error -R '^pixel_aot_sdwa_(int_compare|cmp)_(warp|hardware)$' -V
python -B tests/pixel_aot_check.py
  • At db10c4ac: pixel_aot_sdwa_int_compare_{warp,hardware} and the neighbouring pixel_aot_sdwa_cmp_{warp,hardware} pass, 4/4, with no skips.
  • Merged with current main (a96874a6, clean merge): the same 4/4 pass. The no-argument controls exit 0; they include check_sdwa_int_compare_lowering.

Negative control on the lowering

The 41 wrong-word channels in the batches are the built-in controls. On top of those, I mutated the lowering itself: in tools/pixel_aot.py, the v_cmp_*_{i32,u32}_sdwa branch changed from values = [f"asint({word})" if kind == "i32" else word ...] to values = [word ...], so i32 compares become unsigned. The emitted i32_lo and i32_hi compares then lose their asint.

  • Hardware draw with the mutant: fails with Expected ['pass', 'pass', 'mismatch', ...], got ['mismatch', 'pass', 'mismatch', ...], so the first i32_lo row is now wrong.
  • After reverting: 2/2 pass again.

I didn't run binary mode locally. CI's LLVM 15 job ("Assemble and translate gfx1013 fixtures") passed at this head.

Merge checks: required CI passed at this head ("Build and test on Windows" and both Linux jobs). The /O2 and coverage skips come from explicit workflow conditions. There are no unresolved review threads.

Note for routing: #1670 is still open on the same forms with tools/ changes. Per @tedin7's earlier note, whichever lands second should reconcile its tests with these. That PR changes translation, so it stays with the maintainer.

AI-assisted; commands listed were executed locally.

@MasterDomino
MasterDomino merged commit 8e5dcb6 into R0Y00:main Nov 25, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants