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

Open
sharan104 wants to merge 1 commit from upstream-pr/296 into main
sharan104 commented 2026-11-26 14:45:04 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by sharan104 on 2026-11-26T14:45:04Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:6629100113 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/296). Originally posted by [sharan104](https://github.com/sharan104) on 2026-11-26T14:45:04Z. --- `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)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/296:upstream-pr/296'
git switch 'upstream-pr/296'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/296'
git switch 'upstream-pr/296'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/296'
git switch 'upstream-pr/296'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/296'
git switch 'main'
git merge --squash 'upstream-pr/296'
git switch 'main'
git merge --ff-only 'upstream-pr/296'
git switch 'main'
git merge 'upstream-pr/296'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
avatarmanz/VIctory-7900XTX!296
No description provided.