Skip to content

test: pin the SDWA movrel source and destination selections - #1966

Closed
ChazY11 wants to merge 1 commit into
R0Y00:mainfrom
ChazY11:test/pin-sdwa-movrel-selections
Closed

ChazY11 wants to merge 1 commit into
R0Y00:mainfrom
ChazY11:test/pin-sdwa-movrel-selections

Conversation

@ChazY11

@ChazY11 ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

What

The positive case for the SDWA v_movrel* forms (#1934) asserted only that the output mentions the indexed words:

sdwa_hlsl = translate_int(uncompressed_export(SDWA_MOVREL_BODY))
assert "dpp_soff" in sdwa_hlsl and "dpp_doff" in sdwa_hlsl and "QuadRead" not in sdwa_hlsl

That establishes the instruction is accepted and is not lowered as a quad read, but nothing about the two SDWA selections being
applied. Dropping either call keeps those names in the text:

# tools/pixel_aot.py: replace one call with `pass`, rebuild nothing (pure Python)
swizzled = sdwa_source(swizzled, sdwa_sel[0], sdwa_sel[1])          -> pass   # test still passed
swizzled = sdwa_dest(swizzled, sdwa_sel[2], sdwa_sel[3], ...)       -> pass   # test still passed

With the source selection dropped the emitted line changes from

uint dpp_val49 = ((asuint(dpp_src49) >> 0u) & 0xffffu);

to

uint dpp_val49 = asuint(dpp_src49);

i.e. the raw word flows into the destination write — a wrong result, not a refused one.

Change

Three assertions on the existing positive case, one per selection shape it contains:

# Each selection must actually be applied: src0_sel:BYTE_3 with sext on the indexed source, and
# dst_sel:WORD_x on every indexed destination. A lowering that drops either call still emits dpp_soff
# and dpp_doff, so presence of those names is not enough.
assert "(((asuint(dpp_src27) >> 24u) & 0xffu)" in sdwa_hlsl, sdwa_hlsl
assert "((asuint(alu30) & 0xffff0000u) | ((dpp_val37 & 0xffffu) << 0u))" in sdwa_hlsl, sdwa_hlsl
assert "asuint(asint(asuint(alu34) << 8u) >> 24u)" in sdwa_hlsl, sdwa_hlsl

tests/pixel_aot_check.py only. No production change, no new file, no CMake change.

Tested

out/pe-env/Scripts/python.exe -B tests/pixel_aot_check.py            # exit 0
out/pe-env/Scripts/python.exe -B tests/startup_translator_check.py   # exit 0

Fail-first, both calls, each reverted afterwards:

mutation in tools/pixel_aot.py result
swizzled = sdwa_source(...) → pass exit 1
swizzled = sdwa_dest(...) → pass exit 1
restored exit 0

Before this change both mutations left the check green; that is the gap it closes.

Notes

  • AI-assisted.

The positive case for the SDWA v_movrel* forms only asserted that
dpp_soff and dpp_doff appear in the generated text, so a lowering that
dropped its sdwa_source or sdwa_dest call still passed while the raw word
flowed into the destination write.

@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 2ba4310 (tests/pixel_aot_check.py only, +6 lines).

Findings: P1 = 0, P2 = 0. Clean-room: test-only change, no new source or CMake edits.

Commands executed locally:

  • git merge-tree --write-tree --name-only origin/main HEAD: clean, no conflicts
  • python3 -I tests/docs_links_check.py: PASS
  • python3 -I tests/bidi_controls_check.py: PASS
  • git diff --check origin/main...HEAD: PASS
  • python3 -I tests/pixel_aot_check.py (inline controls, no args): PASS (rc 0)
  • Win2025 (--targets offscreen_check --regex pixel_aot_ --py-checks tests/pixel_aot_check.py): the py-check PASSED (rc 0), but CTest reported 2 failures out of 178 (pixel_aot_attribute_sampled_warp and _hardware, "whole_quad: unexpected result"). These tests are not touched by this PR. Only 1 of 2 phases completed, so Release /O2 was not verified on Win2025.
  • GitHub CI on this head: Windows build, Linux checks and gfx1013 fixtures pass.

Mutations (both reverted with git checkout -- .):

  1. tools/pixel_aot.py: drop the sdwa_source(...) call for SDWA movrel. Result: _check_controls_inline fails at the new assert (line 16923). Killed. The old presence-only checks for dpp_soff and dpp_doff would not catch it.
  2. tools/pixel_aot.py: drop the sdwa_dest(...) call on the indexed destination. Result: the controls fail (rc 1). Killed.

The pinned HLSL strings include SSA numbers (dpp_src27, alu30), so they will need an update when the emitter's numbering changes. That is acceptable for a pin test.

Not merged: the Win2025 Debug run shows 2 unrelated CTest failures and the Release /O2 phase did not complete. Happy to re-run once the node result is clean.

AI-assisted; commands listed were executed locally.

@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Good catch on the missing assertions. Please retain the three masking/shift/sign-extension checks, but capture or normalize the generated temporary suffixes. These suffixes are instruction indices, so inserting an unrelated fixture instruction could otherwise fail the test. Tie each capture to the corresponding source or destination expression so the checks still fail when either SDWA step is removed. #1917 remains open for its planned draw/readback evidence.

@R0Y00

R0Y00 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Thanks for finding the missing source/destination-selection coverage. #1979 credits your review and is now on main. It pins the same operations without the generated temporary numbers and catches the static and dynamic mutations. Closing this overlapping test patch. #1917 stays open for independently checking the native selection order.

@R0Y00 R0Y00 closed this Nov 24, 2026
@ChazY11

ChazY11 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing: main now pins the same three properties, and I verified it catches them

SDWA_MOVREL_PINS / check_sdwa_movrel_pins() landed in tests/pixel_aot_check.py while this PR was open, and it covers what this PR asserted —
with occurrence counts, which is stricter than my presence checks. I re-ran my own mutants against main 36a9a06f:

mutant in tools/pixel_aot.py main result
sdwa_source(...) dropped from the movrel path caught
sdwa_dest(...) dropped at the v_movrels site (line 5533) caught
sdwa_dest(...) dropped at the v_movreld site (line 5542) caught

That is exactly the gap I opened this PR for, pinned three ways instead of one, so there is nothing left for it to add. Keeping it open would only create
a conflict with the newer table.

The three assertions I proposed, for the record, were:

assert "(((asuint(dpp_src27) >> 24u) & 0xffu)" in sdwa_hlsl
assert "((asuint(alu30) & 0xffff0000u) | ((dpp_val37 & 0xffffu) << 0u))" in sdwa_hlsl
assert "asuint(asint(asuint(alu34) << 8u) >> 24u)" in sdwa_hlsl

startup_image_sample_a16_check.py-style regex tables such as SDWA_MOVREL_PINS are the better form: they survive register renumbering, and the
count field catches a lowering that applies the selection in one arm and not the other.

Thanks for landing it.

Notes

  • AI-assisted; closing my own PR after checking the replacement rather than assuming it was equivalent.

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.

3 participants