Skip to content

translate scalar bit replication into wave64 vcc - #8714

Closed
morvayo wants to merge 1 commit into
ProjectLeonida:mainfrom
morvayo:shader-wave64-bitreplicate-vcc
Closed

morvayo wants to merge 1 commit into
ProjectLeonida:mainfrom
morvayo:shader-wave64-bitreplicate-vcc

Conversation

@morvayo

@morvayo morvayo commented Nov 23, 2026

Copy link
Copy Markdown

SHADER-1289 coordination claim

A wave64 compute shader writing full VCC with s_bitreplicate_b64_b32 used to fail translation. Lower the scalar source to each lane's VCC bit and track the destination as a mask. The per-lane result uses source bit L / 2 and preserves EXEC and SCC. This covers the VCC destination; #8526 covers EXEC and changes the same lowering area independently.

Windows 11, RTX 4070 SUPER, NVIDIA 621.24, Khronos 1.4.357. With wave64 emulation on 32-wide subgroups, 12/12 synthetic Vulkan dispatches passed for six source masks and both SCC states, including a VCC copy to an SGPR pair before readback. All 768 VCC and 768 SCC values matched. Both native and emulated SPIR-V passed spirv-val --target-env vulkan1.2. Focused semantic suites passed 16 tests. The new regression is rejected on base as unsupported. The design-row suite reports the same duplicate rows in docs/README.md on both base and this change.

No game files. AI-assisted with Codex.

@fuzeofficlal

Copy link
Copy Markdown

Independent native AMD validation of 3c741ebefa4c59ab6a3debc6c8461faf86bc2af1 on Windows with Radeon gfx1036 (32.0.21042.62) and Khronos validation 1.4.369.

I translated a handwritten compute fixture with the exact PR tool and ran it in native 64-lane mode and 32-lane wave64 emulation. Both configurations tested six source masks, two initial SCC states and full versus half-masked EXEC. All 48 dispatches matched the CPU oracle: VCC had the expected replicated bit in each lane, SCC kept its previous value, and the saved EXEC population was 64 or 32 as expected before restoring EXEC for readback. No validation errors. All four modules passed spirv-val for Vulkan 1.2.

The focused Python file passed 9/9. Its VCC regression fails with Unsupported on the exact parent. AI-assisted (Codex). Synthetic inputs.

@trick-ye

Copy link
Copy Markdown

Tested 3c741ebef (based on main 867d922f0) on AMD Radeon RX 7800 XT (RDNA3), AMD 26.11.2 (Windows driver 32.0.32029.2010), Windows 11 26200: the native (non-emulated) wave64 module at a 64-wide subgroup: 12 of 12 dispatches match, every lane of VCC and of SCC. The description has the emulated module on 32-wide NVIDIA subgroups; this adds the non-emulated wave64 module on AMD's Windows driver, with the compute stage pinned to a 64-wide subgroup.

I ran the PR's new semantic test program as a local GPU fixture (not committed), with ; mattr: +wavefrontsize64,-wavefrontsize32 and ; rsrc2: 0x808c so that s4 and s5 are user SGPRs:

s_mov_b64 exec, -1
s_cmp_eq_u32 s5, 0
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
s_mov_b64 s[12:13], vcc
v_cndmask_b32_e64 v4, 0, 1, s[12:13]
v_mov_b32 v5, s6
v_lshlrev_b32 v6, 2, v0
buffer_store_dword v4, v6, s[0:3], 0 offen
buffer_store_dword v5, v6, s[0:3], 0 offen offset:256
s_endpgm
  • Built with runtime/test/shaders/build.py: on main 867d922f0 it is refused (s_bitreplicate_b64_b32 on a lane mask); on this head it translates and passes spirv-val.
  • Run as VKC_SUBGROUP_SIZE=64 VKC_SGPRS=<s4>,<s5> VKC_OUT_WORDS=128 vk_compute_test <spv> 1 dump, reading the whole buffer back with VKC_DUMP. The harness prints compute subgroup size: 64.
  • s4 = 0, 0x80000001, 0x0f0f0f0f, 0xffffffff, 0xaaaaaaaa, 0x12345678, each with s5 = 0 and 1. In all 12 dispatches lane L holds bit L / 2 of s4 (64 of 64 lanes) and the SCC word is 1 exactly when s5 is 0 (64 of 64 lanes). For example 0x80000001 gives the lane mask 0xc000000000000003 and 0x12345678 gives 0x030c0f30333c3fc0.
  • Two full passes of the 12 dispatches gave the same output. With VKC_SUBGROUP_SIZE=32 on the same .spv (the non-emulated wave64 lowering, not an emulation test): also 12 of 12.
  • The lowering takes the lane from LocalInvocationIndex and uses no subgroup operations, so the result does not depend on the subgroup width (the 32-wide run is identical). This checks the per-lane arithmetic and AMD's compilation of it, not wave-wide behaviour.
  • Not run: the semantic tests, the full GPU suite and --wave64-emulate.
  • vk_compute_test built from main 867d922f0 (the PR changes no C++). MSVC 14.42 (VS 2022), Vulkan SDK 1.4.363.0, llvm-mc 23.1.6, Python 3.13, LEONIDA_VK_DEVICE=7800. Hand-written fixture only, no game files.

AI-assisted (Claude Code).

@TG0000

TG0000 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Hardware verification (gfx1030)

Head 3c741ebefa4c, trial-merged into origin/main 867d922 (clean merge). GPU: AMD Radeon RX 6800 (gfx1030), Windows 11, AMD 26.11.2, Vulkan 1.4.363

  • compileall: ok
  • tests/semantic/test_salu_b32_lane_masks.py: 9 tests OK (1 skipped)
  • PR adds no GPU test.
  • Full scripts/run_gpu_tests.py: 224/241 passed, 17 skipped, 0 failed
  • Baseline origin/main (867d922) on the same build: 223/241 passed, 17 skipped, 1 fail (ms_wave_info_s3, a known intermittent flake on this card).

No regressions. AI-assisted run (Claude Code).

@Digit4w

Digit4w commented Nov 23, 2026

Copy link
Copy Markdown

Tested 3c741ebe (based on current main 867d922f) on an AMD gfx1036 iGPU (RDNA2, native wave64), AMD driver 25.10.42, and an RTX 4070 SUPER (NVIDIA 621.01). Windows 11 build 26200.9974, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8 built with scripts/build_llvm_mc.ps1: pass.

This adds the native wave64 run the PR didn't have; its own check was the wave64 emulation on NVIDIA.

GPU check. A hand-written wave64 compute fixture, local only, source below. It writes s_bitreplicate_b64_b32 vcc, S0 and reads VCC back per lane. Each word counts the lanes whose bit differs from S0 >> (L/2) & 1, plus set lanes << 8 and SCC << 16. Cases:

  • five source words with both SCC states;
  • a run under partial EXEC (lanes 16-31): the SALU write must still set all 64 bits, and EXEC must be kept;
  • a read through s_mov_b64 s[12:13], vcc with VCC cleared before the v_cndmask.
Run out[0..7]
expected (ISA pseudocode) 66560 8192 81920 0 72192 8192 16 73728
AMD gfx1036, native wave64 (VKC_SUBGROUP_SIZE=64 --require-wave64, subgroup 64 confirmed) 66560 8192 81920 0 72192 8192 16 73728
AMD gfx1036, LEONIDA_W64_EMULATE=1 66560 8192 81920 0 72192 8192 16 73728
RTX 4070 SUPER, LEONIDA_W64_EMULATE=1 66560 8192 81920 0 72192 8192 16 73728

Every case has 0 mismatching lanes, and SCC and EXEC are kept. Both builds pass spirv-val. On main the same input is rejected with s_bitreplicate_b64_b32 on a lane mask.

CPU. test_salu_b32_lane_masks.py (9 tests) and test_salu_quadmask_bitreplicate.py (7) pass.

Code read. The lowering (lane L takes bit L >> 1, through mask_dst) and the lane_masks.py change look right to me. vcc_lo/vcc_hi, EXEC, non-compute stages and wave32 still raise Unsupported, as the description says.

One doc nit: the edited docs/design.md row now says it was verified with emulation, but it still ends with **Not GPU-verified.**. That ending was already there and contradicts the row's own cs_w32_new_ops sentence. The native gfx1036 result above could go in that row.

Coordination note: #8842 (Cryptoteep, claimed SHADER-1289 at 19:26) also covers the wave64 VCC destination and changes the same lowering. The claim for this PR is older (19:16).

Fixture source (hand-written, no game data)
; Scratch check for PR #8714 (not committed): s_bitreplicate_b64_b32 vcc, S0 in wave64 compute.
; Lane L's VCC bit must be S0 bit L/2 (ISA: D[2i] = D[2i+1] = S0[i]); SCC kept.
; Per case: word = (lanes whose bit differs from S0 >> (L/2) & 1) | (set lanes) << 8 | SCC << 16.
;   out[0] 0x80000001, SCC 1  -> 0 | 4<<8  | 1<<16 = 66560
;   out[1] 0x0F0F0F0F, SCC 0  -> 0 | 32<<8          = 8192
;   out[2] 0xFFFFFFFF, SCC 1  -> 0 | 64<<8 | 1<<16 = 81920
;   out[3] 0,          SCC 0  -> 0
;   out[4] 0x12345678, SCC 1  -> 0 | 26<<8 | 1<<16 = 72192
;   out[5] EXEC = lanes 16-31 while it runs, 0xA5A5A5A5, SCC 0 -> 0 | 32<<8 = 8192 (SALU writes all 64 bits)
;   out[6] s_bcnt1 of EXEC right after case 5 -> 16 (EXEC kept)
;   out[7] 0x0000FFFF, SCC 1, read back through s_mov_b64 s[12:13], vcc then vcc cleared -> 0 | 32<<8 | 1<<16 = 73728
; mattr: +wavefrontsize64,-wavefrontsize32
s_mov_b32 s5, 0
v_lshrrev_b32_e32 v20, 1, v0
; case 0
s_mov_b64 exec, -1
s_mov_b32 s4, 0x80000001
s_cmp_eq_u32 s5, 0
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
v_cndmask_b32_e64 v30, 0, 1, vcc
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s40, s7, s6
; case 1
s_mov_b32 s4, 0x0f0f0f0f
s_cmp_eq_u32 s5, 1
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
v_cndmask_b32_e64 v30, 0, 1, vcc
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s41, s7, s6
; case 2
s_mov_b32 s4, -1
s_cmp_eq_u32 s5, 0
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
v_cndmask_b32_e64 v30, 0, 1, vcc
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s42, s7, s6
; case 3
s_mov_b32 s4, 0
s_cmp_eq_u32 s5, 1
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
v_cndmask_b32_e64 v30, 0, 1, vcc
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s43, s7, s6
; case 4
s_mov_b32 s4, 0x12345678
s_cmp_eq_u32 s5, 0
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
v_cndmask_b32_e64 v30, 0, 1, vcc
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s44, s7, s6
; case 5 and 6: partial EXEC while it runs
s_mov_b32 s4, 0xa5a5a5a5
s_mov_b64 exec, 0xffff0000
s_cmp_eq_u32 s5, 1
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
s_bcnt1_i32_b64 s46, exec
s_mov_b64 exec, -1
v_cndmask_b32_e64 v30, 0, 1, vcc
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s45, s7, s6
; case 7: through an SGPR pair copy, VCC cleared before the read
s_mov_b32 s4, 0xffff
s_cmp_eq_u32 s5, 0
s_bitreplicate_b64_b32 vcc, s4
s_cselect_b32 s6, 1, 0
s_mov_b64 s[12:13], vcc
s_mov_b64 vcc, 0
v_cndmask_b32_e64 v30, 0, 1, s[12:13]
v_mov_b32_e32 v22, s4
v_lshrrev_b32_e32 v21, v20, v22
v_and_b32_e32 v21, 1, v21
v_cmp_ne_u32_e32 vcc, v21, v30
s_bcnt1_i32_b64 s7, vcc
v_cmp_ne_u32_e32 vcc, 0, v30
s_bcnt1_i32_b64 s8, vcc
s_lshl_b32 s8, s8, 8
s_lshl_b32 s6, s6, 16
s_or_b32 s7, s7, s8
s_or_b32 s47, s7, s6
; store out[0..7] from lane 0
v_cmpx_eq_u32_e32 0, v0
v_mov_b32_e32 v1, s40
v_mov_b32_e32 v2, 0
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s41
v_mov_b32_e32 v2, 4
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s42
v_mov_b32_e32 v2, 8
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s43
v_mov_b32_e32 v2, 12
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s44
v_mov_b32_e32 v2, 16
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s45
v_mov_b32_e32 v2, 20
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s46
v_mov_b32_e32 v2, 24
buffer_store_dword v1, v2, s[0:3], 0 offen
v_mov_b32_e32 v1, s47
v_mov_b32_e32 v2, 28
buffer_store_dword v1, v2, s[0:3], 0 offen
s_endpgm

AI-assisted (Claude).

@DaviTostes

Copy link
Copy Markdown

Tested 3c741ebef (as pushed, based on main 867d922f0) on AMD Radeon RX 9060 XT (RDNA4, gfx1200), RADV Mesa 26.3.1-arch1.3, Vulkan 1.4.363, Linux 7.3.5-arch1-1: pass. This is the native 64-wide module on RADV/Linux, next to @trick-ye's native AMD Windows run (RDNA3) and the emulated 32-wide evidence in the description.

The case: I took the PR's own asm out of tests/semantic/test_salu_b32_lane_masks.py (test_bitreplicate_writes_wave64_vcc_and_preserves_exec_and_scc), translated it as a compute shader with the test's own FSSM header (bytes(0x138) + <0x8090, 64, 1, 1> so s4/s5 stay user SGPRs), assembled with spirv-as --target-env vulkan1.2, and ran it natively (no --wave64-emulate) with vk_compute_test <spv> 1 dump, VKC_SGPRS="<s4>,<s5>" and VKC_DUMP reading the 128 words back.

source mask compare VCC lanes (64) SCC (64) spirv-val
0x00000000 0, 1 word >> (i/2) & 1 exact preserved 0
0x80000001 0, 1 exact preserved 0
0x0F0F0F0F 0, 1 exact preserved 0
0xFFFFFFFF 0, 1 exact preserved 0

8/8 dispatches exact, and one pair of the table exercises the s_cselect_b32 s6 SCC capture after the bit-replicate.

  • tests/semantic/test_salu_b32_lane_masks.py: OK; with LEONIDA_TOOLS_DIR at 867d922f0's tools/, the new regression errors (negative control).
  • Full scripts/run_gpu_tests.py: 225/241 passed, 16 skipped, 0 failed native and LEONIDA_W64_EMULATE=1. Baseline 867d922f0 here: 224/241 both modes (the known ms_wave_info_s3 flake on one side); every other PASS/SKIP line is identical, and all 250 translated modules are byte-identical, so the suite itself does not reach this lowering — the dispatch above does.

First thing worth knowing from my run: my initial attempt with ; rsrc2 0x8088 instead of 0x8090 made the translator treat s4 as the workgroup id and read 0, so the test's header value is load-bearing for a GPU fixture of this case.

Counts and pass/fail only; no game files. AI-assisted (DeepSeek V4.1 Flash coding agent).

@altLov3r

Copy link
Copy Markdown

Tested 3c741ebef on Intel Arc A770 (Alchemist / Xe-HPG, PCI 0x8086:0x56a0, subgroup 8..32, 32-wide GPU, Windows 11, Intel driver 32.0.101.9150, Vulkan 1.4.359), llvm-mc 23.1.6, SPIRV-Tools 2026.4, Python 3.14.4: PASS.

  • python -m unittest discover -s tests/semantic -p test_salu_b32_lane_masks.py -v: 9/9 OK (15.52 s), including test_bitreplicate_writes_wave64_vcc_and_preserves_exec_and_scc and test_spirv_val_native_and_wave64_emulate.
  • LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py --build runtime\build --filter cs_wm_ --require-pass: 4/4 translated & pass spirv-val; 4/4 passed (cs_wm_bfm64, cs_wm_half_cmp, cs_wm_half_ops, cs_wm_scc_rfl).

No game files. AI-assisted (Antigravity / Gemini 4 Neon).

@trigger337

Copy link
Copy Markdown

Tested 3c741eb on AMD Radeon RX 6900 XT (RADV Navi 21, Mesa 26.2.5, Linux 7.3.1 CachyOS): pass

  • PYTHONPATH=tests/semantic python -I tests/semantic/test_salu_b32_lane_masks.py: 9/9 passed.
  • LEONIDA_W64_EMULATE=1 python scripts/run_gpu_tests.py --build runtime/build/linux --filter w64: 26/26 passed.
  • python scripts/run_gpu_tests.py --build runtime/build/linux: 224/241 passed, 16 skipped, 0 failures.
  • scripts/check_no_game_data.py: clean.

AI-assisted: yes
agent: yes

@slint6614-dev

Copy link
Copy Markdown
Contributor

AMD RDNA2 GPU-suite check of 3c741ebef (AI-assisted): full scripts/run_gpu_tests.py with this branch's translator, against the same run on main 867d922f. Ryzen 5 9600X iGPU "AMD Radeon(TM) Graphics" (gfx1036, the console's RDNA2 family), native wave32/wave64, AMD Adrenalin 26.11.2 (Vulkan driver 2.0.353), Windows 11 26300, Python 3.12; test programs from a fresh RelWithDebInfo build of main 867d922.

Same per-fixture results as main: 247 translated, 247 pass spirv-val; 224/241 passed, 17 skipped, 0 failed on both. No fixture changes status (this suite has no fixture aimed at the new rule, so the rule itself is covered only by the semantic test).

@CreaCloudz

Copy link
Copy Markdown

Independent CPU-only check of 3c741eb (no game data, no GPU): looks correct.

Verified the guard is self.stage != "cs" or not self.wave64, so it stays scoped to wave64 compute - a wave32 s_bitreplicate_b64_b32 vcc, ... still raises Unsupported (checked directly against this head). The written value is 0 - bit through mask_dst, i.e. a real 0/0xFFFFFFFF mask rather than a bare 0/1: a follow-up s_not_b64 vcc, vcc after the write flips the right lanes for source 0x1 (lanes 0-1 off -> on, 2-63 on -> off), matching the ISA's D[2i+1] = D[2i] = S0[i] formula read as one mask bit per lane. tools/lane_masks.py's MASK tracking for the destination looks right too.

For comparison, #8842's OpStore %vcc {bit} (no 0/0xFFFFFFFF normalization) fails that same NOT-after-write check; this PR's mask_dst path doesn't have that problem.

Ran this PR's own test_bitreplicate_writes_wave64_vcc_and_preserves_exec_and_scc plus the NOT check above; both pass.

AI-assisted review.

@SpaghettiMaster545

Copy link
Copy Markdown

Tested 3c741ebef merged onto main 867d922f0 (clean merge) on Windows 11 IoT Enterprise LTSC 2024 (26100), MSVC 14.50 (VS 2026) RelWithDebInfo + Ninja, Vulkan SDK 1.4.363.0, llvm-mc 23.1.6. Test programs were built from main; the PR changes no C++. Synthetic tests only, no game files.

Local fixture (not committed): wave64, group 64. It runs s_cmp_eq_u32 s5, 0; s_bitreplicate_b64_b32 vcc, s4; s_cselect_b32, then reads VCC per lane (via v_cndmask_b32_e32 and via an s_mov_b64 copy), SCC, and s_bcnt1_i32_b64 of EXEC and VCC. Inputs: s4 ∈ {0, 0x80000001, 0x0F0F0F0F, 0xFFFFFFFF, 0x12345678, 0xA5A5A5A5} × s5 ∈ {0, 1}, all 64 lanes checked. main's build.py refuses it (s_bitreplicate_b64_b32 on a lane mask); with this head it translates and passes spirv-val, native and --wave64-emulate.

  • AMD Radeon Graphics (Ryzen 7 9800X3D iGPU, RDNA2 gfx1036), AMD 24.10.24 (Vulkan 2.0.302), LEONIDA_PC_TAIL_UBO=1:
    • Fixture: native wave64 (subgroup 64 confirmed) 12/12 and LEONIDA_W64_EMULATE=1 12/12, three times each.
    • Full run_gpu_tests.py, native: 219/241 (20 skipped), twice. Every fixture has the same status as on main.
  • NVIDIA GeForce RTX 5070 Ti, 621.24:
    • Fixture: emulated 12/12, three times; native is skipped.
    • Full suite: native 192/241 (48 skipped), emulated 223/241 (17 skipped). Both identical to main.
  • Semantic tests: test_salu_b32_lane_masks.py 9/9; the new test errors with Unsupported on main's translator. test_salu_quadmask_bitreplicate.py 7/7. The full suite fails the same files as main, with the same counts.

Partial-wave note (outside this PR's scope, and not a regression, since main refuses the op): in a 40-thread group, the per-lane VCC bits, SCC and EXEC are right, but s_bcnt1_i32_b64 of VCC counts only the launched lanes. 0x12345678 gives 18 where the SOP1 definition (all 64 bits) gives 26, and 0xFFFFFFFF gives 40, not 64. That is the same on AMD native and NVIDIA emulated, and unchanged with #8747 merged on top: #8747's never-launched shadow is reset by this VCC write. It may be worth a line in the design row, or a follow-up once #8747 lands.

Pass. AI-assisted (Claude Code).

@boraswim

Copy link
Copy Markdown
Contributor

Tested 3c741ebef (merged onto main 867d922) on the AMD Radeon iGPU of a Ryzen 5 7600X (gfx1036, native wave64), driver 32.0.21045.29003, Windows 11 26300: pass. This is the first run at a native 64-wide subgroup; the PR body's run was emulated on NVIDIA.

I took the program from test_bitreplicate_writes_wave64_vcc_and_preserves_exec_and_scc, translated it with translate_cs(..., 64), and ran it with vk_compute_test (main build). vk_compute_test reports AMD Radeon(TM) Graphics, compute subgroup size 64, under --require-wave64.

Mode Dispatches Mismatches
native wave64 (VKC_SUBGROUP_SIZE=64) 32 0
emulate=True, subgroup 32 32 0
  • 16 source words, each with s5 = 0 and s5 = 1. The words: 0, 0xFFFFFFFF, 0x80000001, 0x0F0F0F0F, 0xAAAAAAAA, 0x55555555, 0x00010000, 0x80000000, and 8 seeded random words.
  • Each dispatch checks every lane's VCC bit (word >> (lane / 2) & 1) and the SCC copy, 64 + 64 words.
  • Both modules pass spirv-val --target-env vulkan1.2.
  • python -m unittest discover -s tests/semantic -p test_salu_b32_lane_masks.py: 9 pass.

No game files. AI-assisted.

@OlaiFG7

OlaiFG7 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Reviewed 3c741eb, code read (CPU), AI-assisted: looks good (sound wave64 compute VCC lowering, clean contract update).

Verified (Windows, CPython 3.14.3 -I, no game data):

  • tests/semantic/test_salu_b32_lane_masks.py: 8 passed, 1 skipped (spirv-as/spirv-val not on PATH); tests/semantic/test_salu_quadmask_bitreplicate.py: 7/7 pass; tests/test_semantic_translator_use.py: 3/3 pass; tests/test_design_contract_rows.py: 4/4 pass; scripts/check_no_game_data.py and compileall: clean; merges cleanly onto origin/main.
  • Negative control on parent (867d922f0): test_bitreplicate_writes_wave64_vcc_and_preserves_exec_and_scc fails as expected with rdna2spirv.Unsupported: s_bitreplicate_b64_b32 on a lane mask.
  • Implementation & edge checks:
    • tools/rdna2spirv.py:6836-6849 properly gates on op == "s_bitreplicate_b64_b32", d["t"] == "vcc", self.stage == "cs", and self.wave64, computes bit = (word >> (lane >> 1)) & 1 and canonical 0/0xFFFFFFFF (OpISub 0 bit) into self.mask_dst(d, mask), and preserves both EXEC and SCC. tools/lane_masks.py:218-219 tracks vcc as MASK in wave64 so copies like s_mov_b64 s[12:13], vcc stay lane-mask tracked.
    • Extra local checks passed: --wave64-emulate translation, partial EXEC (exec_lo=0x55555555, exec_hi=0xAAAAAAAA) + s_not_b64 vcc, vcc (inactive lanes still receive replicated VCC bits, EXEC & SCC preserved, 0/0xFFFFFFFF inverts cleanly), immediate source (0x80000001), and Unsupported rejection for wave32 vcc, wave64 exec/vcc_lo/vcc_hi, mask sources (exec_lo / mask SGPR), and wave64 ps.

Overlap & minor non-blocking notes:

  • Coordination overlap: touches the same _insn block as rdna2spirv: lower scalar bit replication into EXEC #8526 (exec destination, currently draft/conflicting) and directly overlaps fix(rdna2spirv): lower s_bitreplicate_b64_b32 to EXEC and wave64 VCC (SHADER-1289) #8842 (same SHADER-1289, covering both exec and vcc/vcc_lo; note that this PR's 0/0xFFFFFFFF OpISub encoding is cleaner for downstream bitwise mask ops like s_not_b64 than storing raw 0/1).
  • Minor gaps: the added regression starts with exec = -1 (a partial-EXEC case and a wave32/vcc_lo negative control would strengthen the test), and code_w64 (tools/rdna2spirv.py:16502) only checks _b64-suffixed ops so FSSM/FSPX-less synthetic listings without another _b64 marker would not infer wave64 from s_bitreplicate_b64_b32 vcc, ... alone (all FSSM/FSPX shaders are unaffected).

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.