Whole-wave sections: v_permlanex16 reads a disabled lane only with fetch-inactive (was taken as a wave OR) #296

Open
github-bot wants to merge 1 commit from github-bot/gh-296 into main AGit
Owner

@⁠sharan104 on GitHub · 2026-11-26 14:45 UTC · original
sharan104:fix/wave-emit → main · +48 −2 · 1 files · 1 commits · open

emit/wave.rs simulate models whole-wave sections (the scan and reduce code compilers emit) to recognise their results as wave-wide operations. Its v_permlanex16_b32 arm gave every lane the value of the lane it picks, whatever EXEC held. The hardware differs when the source lane is disabled and fetch-inactive (OP_SEL[0]) is off: the lane gets 0 if bound-control (OP_SEL[1]) is set, and otherwise keeps its old value. The general lowering outside sections already does this (lower.rs, the permlane arm). DPP inside a section is refused under a partial EXEC, but the permlane had no such check, so one opcode family was checked and the other wasn't (the same kind of slip as #286).

How it shows: set EXEC to 0xffff0000 inside the section, then run the permlane. The upper row then reads the disabled lower row. A v_readlane of lane 31 was taken as Shape::Active(Or, …) and lowered as a wave OR over every host lane. On the console, lane 31 holds its old v2 OR'd with the upper row: a miscompile. The compiler pattern I know (LLVM's DPP scans) runs the permlane with the full EXEC, so this is shown with a synthetic program.

Fix: a lane reads its source only when that source is enabled or fetch-inactive is set. Otherwise it's 0 with bound-control, or its old value.

Test: a_permlane_from_disabled_lanes_reads_them_only_with_fetch_inactive (synthetic wave32):

  • With op_sel:[1,0] (fetch-inactive), the result is still recognised as the whole wave's OR.
  • The plain form and the bound-control form are not recognised.

Before the fix it failed (Some(Active(Or, ..)) where None was expected). After it, the test passes, 10 runs out of 10.

Results:

  • cargo test -p victory-shader --locked: 303 passed, 0 failed, 4 ignored.
  • Clippy -D warnings is clean, with and without --all-features.

No open or closed PR touches wave.rs. The open wave64 PRs (#184, #173, #152, #109) only change the wave64 test and program files.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 14:45 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/296) `sharan104:fix/wave-emit` → `main` · +48 −2 · 1 files · 1 commits · open `emit/wave.rs` `simulate` models whole-wave sections (the scan and reduce code compilers emit) to recognise their results as wave-wide operations. Its `v_permlanex16_b32` arm gave every lane the value of the lane it picks, **whatever EXEC held**. The hardware differs when the source lane is disabled and fetch-inactive (`OP_SEL[0]`) is off: the lane gets 0 if bound-control (`OP_SEL[1]`) is set, and otherwise keeps its old value. The general lowering outside sections already does this (`lower.rs`, the permlane arm). DPP inside a section is refused under a partial EXEC, but the permlane had no such check, so one opcode family was checked and the other wasn't (the same kind of slip as #286). **How it shows:** set EXEC to `0xffff0000` inside the section, then run the permlane. The upper row then reads the disabled lower row. A `v_readlane` of lane 31 was taken as `Shape::Active(Or, …)` and lowered as a wave OR over every host lane. On the console, lane 31 holds its old `v2` OR'd with the upper row: a miscompile. The compiler pattern I know (LLVM's DPP scans) runs the permlane with the full EXEC, so this is shown with a synthetic program. **Fix:** a lane reads its source only when that source is enabled or fetch-inactive is set. Otherwise it's 0 with bound-control, or its old value. **Test:** `a_permlane_from_disabled_lanes_reads_them_only_with_fetch_inactive` (synthetic wave32): - With `op_sel:[1,0]` (fetch-inactive), the result is still recognised as the whole wave's OR. - The plain form and the bound-control form are not recognised. Before the fix it failed (`Some(Active(Or, ..))` where `None` was expected). After it, the test passes, 10 runs out of 10. **Results:** - `cargo test -p victory-shader --locked`: 303 passed, 0 failed, 4 ignored. - Clippy `-D warnings` is clean, with and without `--all-features`. No open or closed PR touches `wave.rs`. The open wave64 PRs (#184, #173, #152, #109) only change the wave64 test and program files. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The section simulation gave every lane of a v_permlanex16 the value of the
lane it picks, whatever EXEC held. Without fetch-inactive (OP_SEL[0]) a
lane whose source is disabled takes 0 with bound-control (OP_SEL[1]) or
keeps its old value, which is how the lowering outside sections already
treats the instruction; DPP in a section is refused under a partial EXEC,
but the permlane had no such check. A cross-row step run in one row alone
could so be taken for the whole wave's reduction and lowered as a wave OR
over every host lane, where the console's lanes hold something else.

Each lane now reads its source only when that lane is enabled or the
instruction fetches inactive lanes, and otherwise takes 0 or its old value
as the bits say. The new test (a wave32 OR whose permlane runs in the upper
row) fails before the change and passes after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 14:52:22 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/296/head:github-bot/gh-296'
git switch 'github-bot/gh-296'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-296'
git switch 'github-bot/gh-296'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-296'
git switch 'github-bot/gh-296'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-296'
git switch 'main'
git merge --squash 'github-bot/gh-296'
git switch 'main'
git merge --ff-only 'github-bot/gh-296'
git switch 'main'
git merge 'github-bot/gh-296'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.