Skip to content

test: pin constant VCC half writes in wave64 branches - #3282

Open
bobcatchris wants to merge 1 commit into
ItsNotRexed:mainfrom
bobcatchris:fix/wave64-vcc-branch-condition
Open

bobcatchris wants to merge 1 commit into
ItsNotRexed:mainfrom
bobcatchris:fix/wave64-vcc-branch-condition

Conversation

@bobcatchris

@bobcatchris bobcatchris commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Now a test-only PR against current main.

The branch_condition() wave64 VCCZ/VCCNZ fix from the original version of this PR is already on main, together with the SGPR-source semantic test. This branch has been reduced to the one piece that is still missing: the constant-write reproducer from @ray3242 (s_mov_b32 vcc_lo, 0 / s_mov_b32 vcc_hi, 0x8000000a).

What this adds

  • CONST_CASES builds the same six VCC low/high data pairs with constant writes instead of SGPR sources.
  • test_vcc_constant_writes_check_both_halves checks both s_cbranch_vccz and s_cbranch_vccnz for every pair.

Tested (CPU only, no GPU or game data)

  • Current main aa2988cc plus this commit: python -I tests/semantic/test_wave64_vcc_data_branch.py → 3/3 OK; compileall clean.
  • Pre-fix base 16282101 with the same test file: 4 failures, including the constant-write cases.
  • The earlier head of this PR (b88fdeaa) also passed 3/3 and had independent CPU and native GPU reviews; those remain on the PR thread as evidence for the underlying fix.

AI-assisted. No game files, keys or decryption.

@TheMrBeez

TheMrBeez commented Nov 22, 2026 •

Copy link
Copy Markdown

Corrected. The first version of this comment reported that the constant-write reproducer and two v_cmp mask cases still misbranch at this head. That was a mistake in my harness: those test shaders had no wave64 marker, so the translator treated them as wave32 (subgroup 32 in its index), and I compared that against wave64 hardware. Rerun with s_and_b64 s[12:13], exec, exec at the top of every shader, and checked that the index reports subgroup 64 for each one, the results below replace the old table. This PR matches the hardware in every case.

Tested a6d559c3 (base 16282101) on GPUs against native RDNA2. AI-assisted run, synthetic shaders only, no game files.

Each case is a hand-written wave64 compute shader, 64 threads, not part of this PR. After the VCC setup, s_cbranch_vccz 1 skips v_or_b32 v5, 1, v5 and s_cbranch_vccnz 1 skips v_or_b32 v5, 2, v5, so v5 = 1 means VCC is non-zero and 2 means zero. The reference is the same body run natively through tools/hw_oracle on an AMD Radeon iGPU (Ryzen 9 9950X3D, gfx1036, driver 25.10.30.02). Translated runs went through vk_compute_test on that iGPU (native wave64, subgroup 64) and on an RTX 5080 (621.01, --wave64-emulate); both GPUs gave the same words in every case, uniform across the wave.

VCC setup hardware base 16282101 this PR
s_mov_b32 vcc_lo, s4 / vcc_hi, s5 (VKC_SGPRS): (0, 0) 2 2 2 ✓
… (0, 1) and (0, 0x8000000a) 1 2 ✗ 1 ✓
… (1, 0) and (0xa, 0x8000000a) 1 1 1 ✓
s_mov_b32 vcc_lo, 0 / vcc_hi, 0x8000000a (constants, the finding's reproducer) 1 2 ✗ 1 ✓
s_mov_b32 vcc_lo, 0 / vcc_hi, 1 1 2 ✗ 1 ✓
constants (0, 0), (1, 0), (4, 4) 2, 1, 1 same same ✓
v_cmp_le_u32 vcc, 32, v0 (mask = lanes 32–63) 1 1 1 ✓
v_cmp_eq_u32 vcc, 0x20, (v0 & 0x23) (lanes ≥ 32 with lane % 4 == 0) 1 1 1 ✓
v_cmp_gt_u32 vcc, 0, v0 (empty mask) 2 2 2 ✓

So the high-only VCC cases, whether written from SGPRs or from constants, misbranch on the base and are fixed by this PR. The certified-mask cases are a whole-wave vote on both, as the PR says. tests/semantic/test_wave64_vcc_data_branch.py passes here.

@TheMrBeez

Copy link
Copy Markdown

Correction to my comment above (now edited): the two failures I reported were my harness's fault. Those shaders lacked a wave64 marker, so the translator built them as wave32 and I compared that with wave64 hardware. Rerun as true wave64, this PR gives the hardware result in every case, including @ray3242's constant-write reproducer and the certified-mask votes. Sorry for the noise.

@bobcatchris

Copy link
Copy Markdown
Contributor Author

Thanks for the correction and for the native RDNA2 / --wave64-emulate run — glad the wave32 harness mistake was the only issue.

I had already added the exact constant-write reproducer (s_mov_b32 vcc_lo, 0 / s_mov_b32 vcc_hi, 0x8000000a) to tests/semantic/test_wave64_vcc_data_branch.py at head b88fdeaa, pushed just now. The PR test is now 3/3: SGPR data, constant data, and a certified v_cmp mask control. On untouched 16282101 with only that test copied in, 4 subcases fail — the two high-only SGPR cases and the two high-only constant cases — so the new file pins both forms of @ray3242's finding. PR body updated with your corrected GPU verification.

@Flyander Flyander left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at b88fdeaacdefbd2e6242d8b7fd2fd16d5c68a735.

  • python -I -m unittest discover -s tests/semantic — 4,145 tests passed, 4 skipped.
  • git diff --check passed.
  • Negative control using main's tools/ with the PR regression test reproduced 4 failures for high-only VCC_HI values; the PR head passes. Synthetic inputs only; no game files or GPU used.

The new branch condition is limited to wave64 VCC values not certified as lane masks, and the certified-mask control is covered. The separate data-after-mask case is explicitly left to #2544. I found no correctness issue in this PR's stated scope. GitHub checks were still pending at review time.

@bobcatchris
bobcatchris force-pushed the fix/wave64-vcc-branch-condition branch from b88fdea to 357d835 Compare November 22, 2026 23:39
@bobcatchris bobcatchris changed the title rdna2spirv: test both VCC halves in wave64 VCCZ/VCCNZ branches test: pin constant VCC half writes in wave64 branches Nov 22, 2026
@bobcatchris

Copy link
Copy Markdown
Contributor Author

Head updated to 357d835f (force-push) because the underlying branch_condition() fix and SGPR-source test are now on main. This PR is now test-only: it adds @ray3242's constant-write reproducer cases to tests/semantic/test_wave64_vcc_data_branch.py.

  • Current main + this commit: 3/3 OK, compileall clean.
  • Pre-fix base 16282101 with the same test file: 4 failures, including the constant cases.

The earlier independent CPU/GPU verification comments on this thread still apply to the fix that is already merged. Sorry for the changed head; this keeps the remaining diff to one synthetic test file.

@ray3242

ray3242 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Re-checked the test-only head 357d835f on Linux with CPython 3.12.16: pass.

  • It merges cleanly with main aa2988cc, and python -I tests/semantic/test_wave64_vcc_data_branch.py passes 3/3.
  • With 16282101's tools/rdna2spirv.py swapped in, there are 4 failures. Two of them are the new test_vcc_constant_writes_check_both_halves cases with a high-only VCC (hi=0x1 and hi=0x8000000a), so the constant-write form is pinned through the translator.
  • main's copy of this file only covers SGPR-sourced s_mov_b32 vcc_lo/vcc_hi, so these constant cases are new coverage, not a duplicate.

AI-assisted.

@sperm

sperm commented Nov 23, 2026

Copy link
Copy Markdown

Tested 357d835 (a re-test at the new head) on AMD Radeon RX 9070 XT (RADV GFX1201, wave32/64) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.

No game files. AI-assisted.

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.

5 participants