Shaders: v_writelane_b32 is dropped when its lane is outside EXEC (failing test on a branch) #111

Open
opened 2026-11-26 03:36:20 +00:00 by github-bot · 4 comments
Owner

@⁠marketingwithlux on GitHub · 2026-11-24 21:34 UTC · original

Branch with the failing test and this write-up: https://github.com/marketingwithlux/victory-fork/tree/repro/writelane-outside-exec (one commit on top of main at 4e17478; docs/fork-writelane-outside-exec.md). Found while looking into #62.

Nothing from the game is attached; the test program is synthetic. AI-assisted (Claude Code).

Status: reproduced, not fixed. Written so that a person or a coding agent can pick it up.

What is wrong

On the console v_writelane_b32 vN, sX, K writes lane K whatever EXEC is. The translator
lowers it as an ordinary vector write, under the guard of the lane that runs it
(crates/victory-shader/src/emit/lower.rs, the "v_writelane_b32" arm, then
write_placed). So when lane K is outside EXEC, or does not reach the block, the write is
lost and a later v_readlane_b32 sY, vN, K gives the old value.

The compiler uses this pair to park scalars in VGPR lanes. ir::unspill
(crates/victory-shader/src/ir.rs) turns the pairs into scalar moves, but only for a VGPR
whose every use is such a pair with a constant lane. A VGPR with any other use keeps its
lane writes, and those are the ones affected.

Reproduce

cargo test -p victory-shader --lib a_lane_write_reaches_its_lane_outside_exec -- --ignored --nocapture

The test is in crates/victory-shader/src/emit/wave64_tests.rs. It needs a hardware device
with shader model 6.6; without one it prints not run and passes, which is not a result.
On Windows 10 the in-box D3D12 stops at 6.5 (PR #69 adds the newer runtime).

Program: one console wave of 64, if (t > s0) { v_writelane_b32 v9, s6, 0 } with s6 = 5 and
v9 = 7 before, then every thread stores v_readlane_b32 of lane 0.

s0 threads inside expected got (RTX 3090, 32-lane waves)
10 11..63, lane 0 outside 5 7
62 63, lane 0 outside 5 7
63 none (the wave skips) 7 7

The same in all three forms: as is, ir::without_skips(p, false), ir::without_skips(p, true).
The control with lane 0 inside (t < s0) gives 5 and 7 as it should.

"Expected" is the instruction's documented behaviour (it ignores EXEC), which unspill
already relies on. It has not been measured on a console.

What a fix must do

Lane K takes the scalar exactly when the console wave executes the instruction:

  • some lane of the console wave is in EXEC there: write, even if lane K is not;
  • no lane is (the console took the s_cbranch_execz skip): do not write. Making the write
    unconditional breaks the s0 = 63 row in the forms without skips.

Two ways, cheapest first:

  1. At translation time: let unspill take a parking VGPR that has other uses when the
    parked lanes' live ranges do not overlap those uses. No cost per frame, and the program
    may then not need 64-lane waves at all.
  2. At run time: write under "some lane of the console wave is in EXEC" (a ballot; across
    two host waves an exchange, which costs group barriers). Only where 1 cannot apply.

Done when

  • the test passes without #[ignore] on a 32-lane card and on a 64-lane one;
  • cargo test --workspace passes;
  • victory translate --validate over a title's shaders translates no fewer programs than before.

Not known yet

Whether this is what makes the 14 CS_ShadowRenderTiled* programs wrong in the "without
skips, scalars followed" form (issue #62). To check: VICTORY_HOST_WAVE=32 VICTORY_WAVE_WHY=1 victory translate --list and see whether those programs name v_writelane / v_readlane.

Ruled out for #62: a loop running to the loop limit inside a region whose skip was left
out. A conditional back edge leaves the loop at the limit and the program goes on.

**@⁠marketingwithlux** on GitHub · 2026-11-24 21:34 UTC · [original](https://github.com/fxceless/victory-fork/issues/111) Branch with the failing test and this write-up: https://github.com/marketingwithlux/victory-fork/tree/repro/writelane-outside-exec (one commit on top of `main` at 4e17478; `docs/fork-writelane-outside-exec.md`). Found while looking into #62. Nothing from the game is attached; the test program is synthetic. AI-assisted (Claude Code). Status: reproduced, not fixed. Written so that a person or a coding agent can pick it up. ## What is wrong On the console `v_writelane_b32 vN, sX, K` writes lane K whatever EXEC is. The translator lowers it as an ordinary vector write, under the guard of the lane that runs it (`crates/victory-shader/src/emit/lower.rs`, the `"v_writelane_b32"` arm, then `write_placed`). So when lane K is outside EXEC, or does not reach the block, the write is lost and a later `v_readlane_b32 sY, vN, K` gives the old value. The compiler uses this pair to park scalars in VGPR lanes. `ir::unspill` (`crates/victory-shader/src/ir.rs`) turns the pairs into scalar moves, but only for a VGPR whose every use is such a pair with a constant lane. A VGPR with any other use keeps its lane writes, and those are the ones affected. ## Reproduce ``` cargo test -p victory-shader --lib a_lane_write_reaches_its_lane_outside_exec -- --ignored --nocapture ``` The test is in `crates/victory-shader/src/emit/wave64_tests.rs`. It needs a hardware device with shader model 6.6; without one it prints `not run` and passes, which is not a result. On Windows 10 the in-box D3D12 stops at 6.5 (PR #69 adds the newer runtime). Program: one console wave of 64, `if (t > s0) { v_writelane_b32 v9, s6, 0 }` with s6 = 5 and v9 = 7 before, then every thread stores `v_readlane_b32` of lane 0. | s0 | threads inside | expected | got (RTX 3090, 32-lane waves) | |----|----------------|----------|-------------------------------| | 10 | 11..63, lane 0 outside | 5 | 7 | | 62 | 63, lane 0 outside | 5 | 7 | | 63 | none (the wave skips) | 7 | 7 | The same in all three forms: as is, `ir::without_skips(p, false)`, `ir::without_skips(p, true)`. The control with lane 0 inside (`t < s0`) gives 5 and 7 as it should. "Expected" is the instruction's documented behaviour (it ignores EXEC), which `unspill` already relies on. It has not been measured on a console. ## What a fix must do Lane K takes the scalar exactly when the console wave executes the instruction: * some lane of the console wave is in EXEC there: write, even if lane K is not; * no lane is (the console took the `s_cbranch_execz` skip): do not write. Making the write unconditional breaks the `s0 = 63` row in the forms without skips. Two ways, cheapest first: 1. At translation time: let `unspill` take a parking VGPR that has other uses when the parked lanes' live ranges do not overlap those uses. No cost per frame, and the program may then not need 64-lane waves at all. 2. At run time: write under "some lane of the console wave is in EXEC" (a ballot; across two host waves an exchange, which costs group barriers). Only where 1 cannot apply. ## Done when * the test passes without `#[ignore]` on a 32-lane card and on a 64-lane one; * `cargo test --workspace` passes; * `victory translate --validate` over a title's shaders translates no fewer programs than before. ## Not known yet Whether this is what makes the 14 `CS_ShadowRenderTiled*` programs wrong in the "without skips, scalars followed" form (issue #62). To check: `VICTORY_HOST_WAVE=32 VICTORY_WAVE_WHY=1 victory translate --list` and see whether those programs name `v_writelane` / `v_readlane`. Ruled out for #62: a loop running to the loop limit inside a region whose skip was left out. A conditional back edge leaves the loop at the limit and the program goes on.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:20 +00:00
Author
Owner

@⁠kappalegoat on GitHub · 2026-11-25 01:57 UTC · original

The three open PRs for this issue, against its reproduction test, on an RTX 5070. None of them makes the test pass: all three refuse the program instead of writing the lane.

I took a_lane_write_reaches_its_lane_outside_exec from @⁠marketingwithlux's branch (repro/writelane-outside-exec), without its #[ignore], and appended it to wave64_tests.rs on each head. RTX 5070 (Blackwell, driver 621.24), Windows 11, cargo test -p victory-shader --locked --no-fail-fast:

head the reproduction test rest of victory-shader
main 2119b0e fails (the write is dropped), as the issue says 210 passed, 0 failed
#219 refused: Unsupported { offset: 56, what: "a lane written or read where not every lane runs" } 212 passed, 0 failed
#139 refused: "a lane write where not every lane runs" 211 passed, 0 failed
#119 refused: "a lane write where not every lane runs" 211 passed, 0 failed

So each PR turns the silent wrong value into a refusal for this program (the console's one wave of 64, the write inside if (t > s0)). That is safer than main, but the program then does not run at all, which for the shadow programs of #62 means they are dropped rather than fixed. Whichever is merged, the reproduction test would still need the lowering that writes lane K whatever EXEC is.

The three PRs also conflict with each other pairwise (git merge-tree); #219 is on current main, #139 and #119 are 2 commits behind and merge cleanly with it.

No game files used; the test program is synthetic. AI-assisted (Claude Code).

**@⁠kappalegoat** on GitHub · 2026-11-25 01:57 UTC · [original](https://github.com/fxceless/victory-fork/issues/111#issuecomment-7150163674) **The three open PRs for this issue, against its reproduction test, on an RTX 5070.** None of them makes the test pass: all three refuse the program instead of writing the lane. I took `a_lane_write_reaches_its_lane_outside_exec` from @⁠marketingwithlux's branch (`repro/writelane-outside-exec`), without its `#[ignore]`, and appended it to `wave64_tests.rs` on each head. RTX 5070 (Blackwell, driver 621.24), Windows 11, `cargo test -p victory-shader --locked --no-fail-fast`: | head | the reproduction test | rest of `victory-shader` | |---|---|---| | `main` `2119b0e` | fails (the write is dropped), as the issue says | 210 passed, 0 failed | | #219 | **refused**: `Unsupported { offset: 56, what: "a lane written or read where not every lane runs" }` | 212 passed, 0 failed | | #139 | **refused**: `"a lane write where not every lane runs"` | 211 passed, 0 failed | | #119 | **refused**: `"a lane write where not every lane runs"` | 211 passed, 0 failed | So each PR turns the silent wrong value into a refusal for this program (the console's one wave of 64, the write inside `if (t > s0)`). That is safer than `main`, but the program then does not run at all, which for the shadow programs of #62 means they are dropped rather than fixed. Whichever is merged, the reproduction test would still need the lowering that writes lane K whatever EXEC is. The three PRs also conflict with each other pairwise (`git merge-tree`); #219 is on current `main`, #139 and #119 are 2 commits behind and merge cleanly with it. No game files used; the test program is synthetic. AI-assisted (Claude Code).
Author
Owner

@⁠kappalegoat on GitHub · 2026-11-25 01:59 UTC · original

The three open PRs for this issue, against its reproduction test, on an RTX 5070. None of them makes the test pass: all three refuse the program instead of writing the lane.

I took a_lane_write_reaches_its_lane_outside_exec from @⁠marketingwithlux's branch (repro/writelane-outside-exec), without its #[ignore], and appended it to wave64_tests.rs on each head. RTX 5070 (Blackwell, driver 621.24), Windows 11, cargo test -p victory-shader --locked --no-fail-fast:

head the reproduction test rest of victory-shader
main 2119b0e fails (the write is dropped), as the issue says 210 passed, 0 failed
#219 refused: Unsupported { offset: 56, what: "a lane written or read where not every lane runs" } 212 passed, 0 failed
#139 refused: "a lane write where not every lane runs" 211 passed, 0 failed
#119 refused: "a lane write where not every lane runs" 211 passed, 0 failed

So each PR turns the silent wrong value into a refusal for this program (the console's one wave of 64, the write inside if (t > s0)). That is safer than main, but the program then does not run at all, which for the shadow programs of #62 means they are dropped rather than fixed. Whichever is merged, the reproduction test would still need the lowering that writes lane K whatever EXEC is.

The three PRs also conflict with each other pairwise (git merge-tree); #219 is on current main, #139 and #119 are 2 commits behind and merge cleanly with it.

No game files used; the test program is synthetic. AI-assisted (Claude Code).

**@⁠kappalegoat** on GitHub · 2026-11-25 01:59 UTC · [original](https://github.com/fxceless/victory-fork/issues/111#issuecomment-7150195133) **The three open PRs for this issue, against its reproduction test, on an RTX 5070.** None of them makes the test pass: all three refuse the program instead of writing the lane. I took `a_lane_write_reaches_its_lane_outside_exec` from @⁠marketingwithlux's branch (`repro/writelane-outside-exec`), without its `#[ignore]`, and appended it to `wave64_tests.rs` on each head. RTX 5070 (Blackwell, driver 621.24), Windows 11, `cargo test -p victory-shader --locked --no-fail-fast`: | head | the reproduction test | rest of `victory-shader` | |---|---|---| | `main` `2119b0e` | fails (the write is dropped), as the issue says | 210 passed, 0 failed | | #219 | **refused**: `Unsupported { offset: 56, what: "a lane written or read where not every lane runs" }` | 212 passed, 0 failed | | #139 | **refused**: `"a lane write where not every lane runs"` | 211 passed, 0 failed | | #119 | **refused**: `"a lane write where not every lane runs"` | 211 passed, 0 failed | So each PR turns the silent wrong value into a refusal for this program (the console's one wave of 64, the write inside `if (t > s0)`). That is safer than `main`, but the program then does not run at all, which for the shadow programs of #62 means they are dropped rather than fixed. Whichever is merged, the reproduction test would still need the lowering that writes lane K whatever EXEC is. The three PRs also conflict with each other pairwise (`git merge-tree`); #219 is on current `main`, #139 and #119 are 2 commits behind and merge cleanly with it. No game files used; the test program is synthetic. AI-assisted (Claude Code).
Author
Owner

@⁠pr0vId3nce on GitHub · 2026-11-25 14:57 UTC · original

A native measurement of what this issue takes as documented behaviour, and the PR runs from kappalegoat's table, repeated on two more GPUs.

What RDNA2 does. I ran v_writelane_b32 v9, s6, 0 (and lane 33 in wave64) on a Ryzen 7900X's gfx1036 iGPU, assembled and launched through the AMD driver's own amd_comgr_2.dll and amdhip64_6.dll, with v9 = 7, s6 = 5 and four EXEC values: lanes 11 and up, only the last lane, lanes 0-9, and EXEC = 0. In all eight cases (wave32 and wave64) the named lane becomes 5 and no other lane changes. So the write ignores EXEC entirely, even an empty EXEC. The expected column here (5, 5, 7) holds because the test program branches around the write with s_cbranch_execz.

kappalegoat's table holds here too, on an RTX 4080 and on the gfx1036 iGPU (main 0b0074e, #119 481569b, #139 3c408b4, #219 ad4022f; the test from 6a274bc appended without its #[ignore]). main fails with 7 for s0 = 10 and 62 in all three forms. Each PR fails with the refusal. The refusal comes from the test's last part, the lane-0-inside control, which lowers the form with the skip through lowered(...).expect("lower"). In the loop above it, the test prints the same refusal for "as is" and moves on, and on every PR head both forms without the skip give 5, 5, 7.

The refusal also doesn't drop the program. "... where not every lane runs" is the refusal emit() answers by retrying with the skips left out. I passed the issue's program through super::emit for a 32-lane host, which is how a title's program gets translated. It translates on all three PRs and gives 5, 5, 7 on both GPUs. On main it translates and gives 7, 7, 7. So for this program the PRs fix the value. What fails is the issue test's control. Each PR's own copy of the test keeps the name and passes: #139 and #219 move the control to the form without the skip, and #119 goes through emit().

One case the three share. All three write when some lane of the console wave is in EXEC (#219 notes the gap: "a wave that walks on with EXEC empty and no skip writes too"). With this issue's program and the s_cbranch_execz replaced by s_nop, #119 on both GPUs gives 5 with threads 11 and up inside. With no thread inside it gives 7, where the hardware writes 5. I have not run that variant on #139 or #219. Whether any title program reaches a lane write with EXEC empty and no skip, I can't tell (no game data here).

Synthetic programs only. AI-assisted (Claude Code).

**@⁠pr0vId3nce** on GitHub · 2026-11-25 14:57 UTC · [original](https://github.com/fxceless/victory-fork/issues/111#issuecomment-7166078923) A native measurement of what this issue takes as documented behaviour, and the PR runs from kappalegoat's table, repeated on two more GPUs. **What RDNA2 does.** I ran `v_writelane_b32 v9, s6, 0` (and lane 33 in wave64) on a Ryzen 7900X's gfx1036 iGPU, assembled and launched through the AMD driver's own `amd_comgr_2.dll` and `amdhip64_6.dll`, with v9 = 7, s6 = 5 and four EXEC values: lanes 11 and up, only the last lane, lanes 0-9, and EXEC = 0. In all eight cases (wave32 and wave64) the named lane becomes 5 and no other lane changes. So the write ignores EXEC entirely, even an empty EXEC. The expected column here (5, 5, 7) holds because the test program branches around the write with `s_cbranch_execz`. **kappalegoat's table holds here too**, on an RTX 4080 and on the gfx1036 iGPU (main 0b0074e, #119 481569b, #139 3c408b4, #219 ad4022f; the test from 6a274bc appended without its `#[ignore]`). main fails with 7 for s0 = 10 and 62 in all three forms. Each PR fails with the refusal. The refusal comes from the test's last part, the lane-0-inside control, which lowers the form *with* the skip through `lowered(...).expect("lower")`. In the loop above it, the test prints the same refusal for "as is" and moves on, and on every PR head both forms without the skip give 5, 5, 7. The refusal also doesn't drop the program. "... where not every lane runs" is the refusal `emit()` answers by retrying with the skips left out. I passed the issue's program through `super::emit` for a 32-lane host, which is how a title's program gets translated. It translates on all three PRs and gives 5, 5, 7 on both GPUs. On main it translates and gives 7, 7, 7. So for this program the PRs fix the value. What fails is the issue test's control. Each PR's own copy of the test keeps the name and passes: #139 and #219 move the control to the form without the skip, and #119 goes through `emit()`. **One case the three share.** All three write when some lane of the console wave is in EXEC (#219 notes the gap: "a wave that walks on with EXEC empty and no skip writes too"). With this issue's program and the `s_cbranch_execz` replaced by `s_nop`, #119 on both GPUs gives 5 with threads 11 and up inside. With no thread inside it gives 7, where the hardware writes 5. I have not run that variant on #139 or #219. Whether any title program reaches a lane write with EXEC empty and no skip, I can't tell (no game data here). Synthetic programs only. AI-assisted (Claude Code).
Author
Owner

@⁠studiostephe on GitHub · 2026-11-26 01:48 UTC · original

A lowering that writes the lane whatever EXEC is, checked against the reproduction test.

Against main at 44bff61b. AI-assisted (Claude Code).

What the patch does

lower.rs, the v_writelane_b32 arm. The current lowering is a plain vector write under the
instruction's guard (select(is_lane_K, a, old)). On the console the write ignores EXEC: lane K
takes the scalar whenever some lane of the console wave runs the instruction, even with K outside
EXEC. The plain write loses that.

The patch re-issues the write where the guard does not cover lane K's own host lane:

  • lane_write(guard_raw, lane, a, plain): when the guard is not the whole wave (and the
    re-issue is safe: no exchange, and for local halves only when local_any holds), it finds
    the FIRST HOST LANE IN EXEC (waveActiveBallot + a first-bit-low on the two 32-bit halves,
    the same idiom first_lane already uses), reads the scalar from that lane
    (waveReadLaneAt), and returns select(is_lane_K, r, plain). The re-issued read runs
    whenever any lane runs the instruction, so lane K's host lane gets a there; everywhere
    else the plain result is kept.
  • guard_raw (the BDD guard from the structure) is threaded valu() -> valu_op(); the
    v_writelane_b32 arm uses it to decide whether the re-issue is needed.

The "do not write when no lane of the wave runs the instruction" half of the issue's
specification falls out for free: when EXEC is empty at the instruction, no host lane is in
EXEC, so the re-issue reads nothing and the plain write does not happen either. I checked
the s0 = 63 row by reading the emitted shape rather than running it (below).

The test file change appends the issue's own reproduction test
(a_lane_write_reaches_its_lane_outside_exec, from the branch in the issue) to
wave64_tests.rs without its #[ignore], so it runs on a machine with a card.

Verified

Mac (M1), main 44bff61b, Rust 1.98.1, no Windows:

  • cargo test -p victory-shader --lib --locked: 172 passed, 0 failed, 2 ignored
    (171 before; the +1 is a CPU-side lowering test, below).
  • cargo check -p victory-shader --lib --profile test --locked --target x86_64-pc-windows-msvc:
    clean, so the appended wave64_tests.rs test compiles where it runs.
  • CPU-side test cpu_side_lane_write_reissue_is_emitted (in lower.rs, no card needed):
    a v_writelane_b32 under a per-lane EXEC narrowing emits the re-issue
    (waveReadLaneAt count >= 1); the same write with EXEC not narrowed emits none (count == 0).
  • Non-vacuous: forcing lane_write to return None makes that test fail; restoring the
    patch makes it pass.
  • clippy clean on the changed lines (no new warnings vs main).

Not verified (no Windows here)

  • The reproduction test itself was not run on a card: it is in wave64_tests.rs, which is
    gated to a Windows host with shader model 6.6, and this machine has no Windows and no
    dxil.dll. The table in the issue (s0 = 10/62/63, the three forms, the control) is the thing
    to run: cargo test -p victory-shader --lib a_lane_write_reaches_its_lane_outside_exec -- --nocapture.
  • pr0vId3nce's comment notes one case the three open PRs share: a lane write reached with EXEC
    empty and no skip writes 7 where the hardware writes 5 (the s_nop variant). This patch
    has the same behaviour in that variant: with no lane in EXEC, the re-issue's ballot is
    empty and the plain write's EXEC is empty too, so nothing is written. I am stating that from
    the emitted shape, not from a run.

Diff:

--- a/crates/victory-shader/src/emit/lower.rs
+++ b/crates/victory-shader/src/emit/lower.rs
@@ -65,6 +65,10 @@ pub(crate) struct Lowered {
     /// Whether the program uses wave operations.
     #[cfg(test)]
     pub wave_ops: bool,
+    /// `waveReadLaneAt` calls emitted (a `v_writelane_b32` re-issue, a first-lane
+    /// read, or a lane read).
+    #[cfg(test)]
+    pub lane_reads: u32,
 }
 
 pub(crate) struct Parts<'a> {
@@ -295,6 +299,9 @@ struct Lower<'a> {
     counters: HashMap<usize, (V, Vec<(V, usize)>)>,
     /// The block a loop stopped by [`LOOP_LIMIT`] leaves the program from.
     abort: Option<usize>,
+    /// `waveReadLaneAt` calls emitted (tests only).
+    #[cfg(test)]
+    lane_reads: u32,
 }
 
 /// Iterations after which a loop is left (per entry into it), unless
@@ -1589,6 +1596,8 @@ impl<'a> Lower<'a> {
             code_table: None,
             counters: HashMap::new(),
             abort: None,
+            #[cfg(test)]
+            lane_reads: 0,
         }
     }
 
@@ -2295,6 +2304,8 @@ impl<'a> Lower<'a> {
             nonuniform_handles: self.s.nonuniform_handles,
             #[cfg(test)]
             wave_ops: self.s.flags & flags::WAVE_OPS != 0,
+            #[cfg(test)]
+            lane_reads: self.lane_reads,
             dxil: self.s.finish(),
             user_data,
             samplers: self.samplers,
@@ -4299,6 +4310,47 @@ impl<'a> Lower<'a> {
         r
     }
 
+    /// A `v_writelane_b32` of `a` to console lane `lane` that the plain write under the
+    /// guard would lose: the guard does not reach `lane`'s own host lane, so the console
+    /// lane would keep its old value although the console wave runs the instruction (the
+    /// write ignores EXEC). Re-issues the write to the first host lane in EXEC, which
+    /// reaches the instruction whenever any lane does, and returns the value the register
+    /// gets there: `a` on `lane`'s own host lane, else the plain result. `None` when the
+    /// guard is the whole wave (the plain write already covers `lane`) or the re-issue is
+    /// unsafe: with the halves exchanging, `lane`'s own host lane may stand in the other
+    /// half and not run the instruction, and `local` halves take their reads per half
+    /// (`local_any`), so a wave-wide re-issue would be wrong there.
+    fn lane_write(&mut self, guard: Option<Bool>, lane: V, a: V, plain: V) -> Option<V> {
+        let guard = guard?;
+        if guard == Bool::TRUE || self.exchange.is_some() {
+            return None;
+        }
+        if self.local && !self.local_any {
+            return None;
+        }
+        let c = self.cur;
+        let me = self.console_lane();
+        let k_here = self.s.m.cmp(c, pred::EQ, me, lane);
+        let g = self.boolean(guard, c).ok()?;
+        let four = self.s.m.named_struct("dx.types.fouri32", vec![self.s.t.i32; 4]);
+        let r = self.s.op(c, "waveActiveBallot", Attr::NoUnwind, four, 116, &[g]);
+        let (lo, hi) = (self.s.m.extract(c, r, 0), self.s.m.extract(c, r, 1));
+        let (z, k32) = (self.s.m.i32(0), self.s.m.i32(32));
+        // FirstbitLo (dx.op 32): the lowest set bit.
+        let flo = self.s.op(c, "unaryBits.i32", Attr::ReadNone, self.s.t.i32, 32, &[lo]);
+        let fhi = self.s.op(c, "unaryBits.i32", Attr::ReadNone, self.s.t.i32, 32, &[hi]);
+        let fhi = self.s.m.bin(c, Bin::Add, fhi, k32);
+        let in_lo = self.s.m.cmp(c, pred::NE, lo, z);
+        let in_hi = self.s.m.cmp(c, pred::NE, hi, z);
+        let any = self.s.m.bin(c, Bin::Or, in_lo, in_hi);
+        let at = self.s.m.select(c, in_lo, flo, fhi);
+        // No lane in EXEC here: the write does not happen; the read is not used.
+        let at = self.s.m.select(c, any, at, me);
+        self.s.flags |= flags::WAVE_OPS;
+        let r = self.read_lane(a, at);
+        Some(self.s.m.select(c, k_here, r, plain))
+    }
+
     /// `x` in the first lane of this host wave where `guard` holds, and whether it has such a
     /// lane: the console reads the first lane of EXEC, and a lane that got here with EXEC clear
     /// (a guard, not a branch) is not one. With none, `x` of the wave's first lane here.
@@ -4330,6 +4382,8 @@ impl<'a> Lower<'a> {
     }
 
     fn read_lane(&mut self, x: V, lane: V) -> V {
+        #[cfg(test)]
+        { self.lane_reads += 1; }
         self.s.op(
             self.cur,
             "waveReadLaneAt.i32",
@@ -6678,6 +6732,7 @@ impl<'a> Lower<'a> {
             }
             return r;
         }
+        let guard_raw = self.x.st.guards[b][i];
         let mut guard = self.guard(b, i)?;
         if let Some(d) = v.dpp {
             let (x, enable) = self.dpp(inst, d)?;
@@ -6687,7 +6742,7 @@ impl<'a> Lower<'a> {
             };
             self.src0 = Some(x);
         }
-        let r = self.valu_op(inst, guard);
+        let r = self.valu_op(inst, guard_raw, guard);
         self.src0 = None;
         r
     }
@@ -6819,7 +6874,12 @@ impl<'a> Lower<'a> {
         Ok((r, enable))
     }
 
-    fn valu_op(&mut self, inst: &Inst, guard: Option<V>) -> Result<(), Why> {
+    fn valu_op(
+        &mut self,
+        inst: &Inst,
+        guard_raw: Option<Bool>,
+        guard: Option<V>,
+    ) -> Result<(), Why> {
         let Fields::Valu(v) = &inst.fields else {
             unreachable!()
         };
@@ -7607,6 +7667,14 @@ impl<'a> Lower<'a> {
                 let me = self.console_lane();
                 let is = self.s.m.cmp(c, pred::EQ, me, lane);
                 let r = self.s.m.select(c, is, a, old);
+                // On the console the write ignores EXEC: lane K takes the scalar whenever
+                // some lane of the console wave runs the instruction, even with K outside
+                // EXEC. The select above does that only where the guard reaches K's own
+                // host lane, so re-issue it to a host lane in EXEC where it always does.
+                let r = match self.lane_write(guard_raw, lane, a, r) {
+                    Some(w) => w,
+                    None => r,
+                };
                 int(self, r)
             }
             "v_readfirstlane_b32"
@@ -11951,4 +12019,40 @@ mod tests {
         // A 16-bit float is a half already, sign included.
         assert_eq!(half(0xBC00 << half_shift(16)), -1.0);
     }
+
+    /// `v_writelane_b32` ignores EXEC on the console: lane K takes the scalar
+    /// whenever some lane of the wave runs the instruction, even with K outside
+    /// EXEC. The plain vector write under the narrowed EXEC loses that, so the
+    /// lowering re-issues the write to a host lane in EXEC (a `waveReadLaneAt`).
+    #[test]
+    fn cpu_side_lane_write_reissue_is_emitted() {
+        // EXEC narrowed per lane (`v_cmpx_gt_u32 exec, s0, v0`): the lanes with
+        // v0 <= s0 drop out of EXEC, so a `v_writelane_b32` to one of those lanes
+        // is outside EXEC while the wave still runs it. On the console the write
+        // ignores EXEC and still lands in that lane; the plain write under the
+        // narrowed EXEC would drop it. The lane-write words are the working
+        // encoding from `resource.rs` (v_writelane_b32 v0, s9, 3).
+        let words: &[u32] = &[
+            0xBE80_0380, // s_mov_b32 s0, 0 (root constant: the threshold)
+            0x7DA8_0000, // v_cmpx_gt_u32 exec, s0, v0 (lanes with v0 > s0 keep EXEC)
+            0xBE89_0385, // s_mov_b32 s9, 5 (the scalar to park in the lane)
+            0xD761_0000,
+            0x0001_0609, // v_writelane_b32 v0, s9, 3
+            0xBF81_0000, // s_endpgm
+        ];
+        let l = lower_wave(words, vec![], vec![], false).unwrap();
+        // The re-issue reads the scalar from a host lane in EXEC (waveReadLaneAt).
+        // The plain write alone emits no such read.
+        assert!(l.lane_reads >= 1, "the lane write must be re-issued to a host lane in EXEC");
+
+        // Control: the same write with EXEC not narrowed needs no re-issue.
+        let whole: &[u32] = &[
+            0xBE89_0385, // s_mov_b32 s9, 5
+            0xD761_0000,
+            0x0001_0609, // v_writelane_b32 v0, s9, 3
+            0xBF81_0000, // s_endpgm
+        ];
+        let w = lower_wave(whole, vec![], vec![], false).unwrap();
+        assert_eq!(w.lane_reads, 0, "a whole-wave lane write needs no re-issue");
+    }
 }
--- a/crates/victory-shader/src/emit/wave64_tests.rs
+++ b/crates/victory-shader/src/emit/wave64_tests.rs
@@ -530,3 +530,74 @@ fn scc_of_a_mask_operation_joined_with_a_scalar_test_needs_the_skip_wave_wide()
     }
     eprintln!("ran on the hardware device: the inner test's SCC for every lane once some lane is inside");
 }
+
+/// One console wave of 64. `v_writelane_b32` writes its lane whatever EXEC is: inside
+/// `if (t > s0) { ... }`, lane 0 (never inside) takes the scalar as soon as any thread is.
+/// The compiler parks scalars this way in a VGPR that has other uses too (`unspill` leaves
+/// those alone). Every thread stores what lane 0 holds after the join: 5 once the body
+/// ran, 7 when the wave skipped it.
+#[test]
+fn a_lane_write_reaches_its_lane_outside_exec() {
+    let words = [
+        0x7E12_0287, // v_mov_b32 v9, 7
+        0x7D82_0000, // v_cmp_lt_u32 vcc, s0, v0
+        0xBE8C_246A, // s_and_saveexec_b64 s[12:13], vcc
+        0xBF88_0003, // s_cbranch_execz to "join"
+        0xBE86_0385, // s_mov_b32 s6, 5
+        0xD761_0009,
+        0x0001_0006, // v_writelane_b32 v9, s6, 0
+        0xBEFE_040C, // join: s_mov_b64 exec, s[12:13]
+        0xD760_0007,
+        0x0001_0109, // v_readlane_b32 s7, v9, 0
+        0x7E02_0207, // v_mov_b32 v1, s7
+        0x38 << 26 | 0x1C << 18,
+        0x80 << 24 | 2 << 16 | 1 << 8, // buffer_store_dword v1, off, s[8:11], 0
+    ];
+    let native = native(&words);
+    let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build");
+    for i in p.blocks.iter().flat_map(|b| &b.insts) {
+        eprintln!("  {:#06x} {}", i.machine.offset, i.name());
+    }
+    let _one = super::valu_tests::ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner());
+    let forms = [
+        ("as is", Some(p.clone())),
+        ("without skips", ir::without_skips(&p, false)),
+        ("without skips, scalars followed", ir::without_skips(&p, true)),
+    ];
+    let mut wrong = Vec::new();
+    for (name, q) in &forms {
+        let Some(q) = q else {
+            eprintln!("{name}: the skip is kept");
+            continue;
+        };
+        lower::take_needs();
+        let shader = match lowered(&native, q, &HashSet::new()) {
+            Ok(s) => s,
+            Err(e) => {
+                eprintln!("{name}: {e}");
+                continue;
+            }
+        };
+        // (threads above s0 inside) -> lane 0 after the join
+        for (s0, expected) in [(10u32, 5u32), (62, 5), (63, 7)] {
+            let Some(got) = on_the_card(&shader, [s0, 0]) else { return };
+            eprintln!("{name}: threads above {s0} inside -> {got} (the console: {expected})");
+            if got != expected {
+                wrong.push(format!("{name}: s0 = {s0}: {got}, not {expected}"));
+            }
+        }
+    }
+    // The same with lane 0 inside (`t < s0`): the write lands in every form.
+    let mut inside = words;
+    inside[1] = 0x7D88_0000; // v_cmp_gt_u32 vcc, s0, v0
+    let native = native_of(&inside, true, 64);
+    let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build");
+    lower::take_needs();
+    let shader = lowered(&native, &p, &HashSet::new()).expect("lower");
+    for (s0, expected) in [(10u32, 5u32), (0, 7)] {
+        let Some(got) = on_the_card(&shader, [s0, 0]) else { return };
+        eprintln!("lane 0 inside, as is: threads below {s0} inside -> {got} (the console: {expected})");
+        assert_eq!(got, expected, "lane 0 inside, s0 = {s0}");
+    }
+    assert!(wrong.is_empty(), "{wrong:#?}");
+}

qwen3.8_27b running locally on an M1 Mac

shout out to Digital Debris Los Angeles

**@⁠studiostephe** on GitHub · 2026-11-26 01:48 UTC · [original](https://github.com/fxceless/victory-fork/issues/111#issuecomment-7180148895) A lowering that writes the lane whatever EXEC is, checked against the reproduction test. Against `main` at 44bff61b. AI-assisted (Claude Code). ## What the patch does `lower.rs`, the `v_writelane_b32` arm. The current lowering is a plain vector write under the instruction's guard (`select(is_lane_K, a, old)`). On the console the write ignores EXEC: lane K takes the scalar whenever some lane of the console wave runs the instruction, even with K outside EXEC. The plain write loses that. The patch re-issues the write where the guard does not cover lane K's own host lane: * `lane_write(guard_raw, lane, a, plain)`: when the guard is not the whole wave (and the re-issue is safe: no exchange, and for `local` halves only when `local_any` holds), it finds the FIRST HOST LANE IN EXEC (`waveActiveBallot` + a first-bit-low on the two 32-bit halves, the same idiom `first_lane` already uses), reads the scalar from that lane (`waveReadLaneAt`), and returns `select(is_lane_K, r, plain)`. The re-issued read runs whenever any lane runs the instruction, so lane K's host lane gets `a` there; everywhere else the plain result is kept. * `guard_raw` (the BDD guard from the structure) is threaded `valu()` -> `valu_op()`; the `v_writelane_b32` arm uses it to decide whether the re-issue is needed. The "do not write when no lane of the wave runs the instruction" half of the issue's specification falls out for free: when EXEC is empty at the instruction, no host lane is in EXEC, so the re-issue reads nothing and the plain write does not happen either. I checked the `s0 = 63` row by reading the emitted shape rather than running it (below). The test file change appends the issue's own reproduction test (`a_lane_write_reaches_its_lane_outside_exec`, from the branch in the issue) to `wave64_tests.rs` **without its `#[ignore]`**, so it runs on a machine with a card. ## Verified Mac (M1), `main` 44bff61b, Rust 1.98.1, no Windows: * `cargo test -p victory-shader --lib --locked`: **172 passed, 0 failed, 2 ignored** (171 before; the +1 is a CPU-side lowering test, below). * `cargo check -p victory-shader --lib --profile test --locked --target x86_64-pc-windows-msvc`: clean, so the appended `wave64_tests.rs` test compiles where it runs. * CPU-side test `cpu_side_lane_write_reissue_is_emitted` (in `lower.rs`, no card needed): a `v_writelane_b32` under a per-lane EXEC narrowing emits the re-issue (`waveReadLaneAt` count >= 1); the same write with EXEC not narrowed emits none (count == 0). * Non-vacuous: forcing `lane_write` to return `None` makes that test fail; restoring the patch makes it pass. * clippy clean on the changed lines (no new warnings vs main). ## Not verified (no Windows here) * The reproduction test itself was **not run on a card**: it is in `wave64_tests.rs`, which is gated to a Windows host with shader model 6.6, and this machine has no Windows and no dxil.dll. The table in the issue (s0 = 10/62/63, the three forms, the control) is the thing to run: `cargo test -p victory-shader --lib a_lane_write_reaches_its_lane_outside_exec -- --nocapture`. * pr0vId3nce's comment notes one case the three open PRs share: a lane write reached with EXEC *empty* and no skip writes 7 where the hardware writes 5 (the `s_nop` variant). This patch has the same behaviour in that variant: with no lane in EXEC, the re-issue's ballot is empty and the plain write's EXEC is empty too, so nothing is written. I am stating that from the emitted shape, not from a run. Diff: ```diff --- a/crates/victory-shader/src/emit/lower.rs +++ b/crates/victory-shader/src/emit/lower.rs @@ -65,6 +65,10 @@ pub(crate) struct Lowered { /// Whether the program uses wave operations. #[cfg(test)] pub wave_ops: bool, + /// `waveReadLaneAt` calls emitted (a `v_writelane_b32` re-issue, a first-lane + /// read, or a lane read). + #[cfg(test)] + pub lane_reads: u32, } pub(crate) struct Parts<'a> { @@ -295,6 +299,9 @@ struct Lower<'a> { counters: HashMap<usize, (V, Vec<(V, usize)>)>, /// The block a loop stopped by [`LOOP_LIMIT`] leaves the program from. abort: Option<usize>, + /// `waveReadLaneAt` calls emitted (tests only). + #[cfg(test)] + lane_reads: u32, } /// Iterations after which a loop is left (per entry into it), unless @@ -1589,6 +1596,8 @@ impl<'a> Lower<'a> { code_table: None, counters: HashMap::new(), abort: None, + #[cfg(test)] + lane_reads: 0, } } @@ -2295,6 +2304,8 @@ impl<'a> Lower<'a> { nonuniform_handles: self.s.nonuniform_handles, #[cfg(test)] wave_ops: self.s.flags & flags::WAVE_OPS != 0, + #[cfg(test)] + lane_reads: self.lane_reads, dxil: self.s.finish(), user_data, samplers: self.samplers, @@ -4299,6 +4310,47 @@ impl<'a> Lower<'a> { r } + /// A `v_writelane_b32` of `a` to console lane `lane` that the plain write under the + /// guard would lose: the guard does not reach `lane`'s own host lane, so the console + /// lane would keep its old value although the console wave runs the instruction (the + /// write ignores EXEC). Re-issues the write to the first host lane in EXEC, which + /// reaches the instruction whenever any lane does, and returns the value the register + /// gets there: `a` on `lane`'s own host lane, else the plain result. `None` when the + /// guard is the whole wave (the plain write already covers `lane`) or the re-issue is + /// unsafe: with the halves exchanging, `lane`'s own host lane may stand in the other + /// half and not run the instruction, and `local` halves take their reads per half + /// (`local_any`), so a wave-wide re-issue would be wrong there. + fn lane_write(&mut self, guard: Option<Bool>, lane: V, a: V, plain: V) -> Option<V> { + let guard = guard?; + if guard == Bool::TRUE || self.exchange.is_some() { + return None; + } + if self.local && !self.local_any { + return None; + } + let c = self.cur; + let me = self.console_lane(); + let k_here = self.s.m.cmp(c, pred::EQ, me, lane); + let g = self.boolean(guard, c).ok()?; + let four = self.s.m.named_struct("dx.types.fouri32", vec![self.s.t.i32; 4]); + let r = self.s.op(c, "waveActiveBallot", Attr::NoUnwind, four, 116, &[g]); + let (lo, hi) = (self.s.m.extract(c, r, 0), self.s.m.extract(c, r, 1)); + let (z, k32) = (self.s.m.i32(0), self.s.m.i32(32)); + // FirstbitLo (dx.op 32): the lowest set bit. + let flo = self.s.op(c, "unaryBits.i32", Attr::ReadNone, self.s.t.i32, 32, &[lo]); + let fhi = self.s.op(c, "unaryBits.i32", Attr::ReadNone, self.s.t.i32, 32, &[hi]); + let fhi = self.s.m.bin(c, Bin::Add, fhi, k32); + let in_lo = self.s.m.cmp(c, pred::NE, lo, z); + let in_hi = self.s.m.cmp(c, pred::NE, hi, z); + let any = self.s.m.bin(c, Bin::Or, in_lo, in_hi); + let at = self.s.m.select(c, in_lo, flo, fhi); + // No lane in EXEC here: the write does not happen; the read is not used. + let at = self.s.m.select(c, any, at, me); + self.s.flags |= flags::WAVE_OPS; + let r = self.read_lane(a, at); + Some(self.s.m.select(c, k_here, r, plain)) + } + /// `x` in the first lane of this host wave where `guard` holds, and whether it has such a /// lane: the console reads the first lane of EXEC, and a lane that got here with EXEC clear /// (a guard, not a branch) is not one. With none, `x` of the wave's first lane here. @@ -4330,6 +4382,8 @@ impl<'a> Lower<'a> { } fn read_lane(&mut self, x: V, lane: V) -> V { + #[cfg(test)] + { self.lane_reads += 1; } self.s.op( self.cur, "waveReadLaneAt.i32", @@ -6678,6 +6732,7 @@ impl<'a> Lower<'a> { } return r; } + let guard_raw = self.x.st.guards[b][i]; let mut guard = self.guard(b, i)?; if let Some(d) = v.dpp { let (x, enable) = self.dpp(inst, d)?; @@ -6687,7 +6742,7 @@ impl<'a> Lower<'a> { }; self.src0 = Some(x); } - let r = self.valu_op(inst, guard); + let r = self.valu_op(inst, guard_raw, guard); self.src0 = None; r } @@ -6819,7 +6874,12 @@ impl<'a> Lower<'a> { Ok((r, enable)) } - fn valu_op(&mut self, inst: &Inst, guard: Option<V>) -> Result<(), Why> { + fn valu_op( + &mut self, + inst: &Inst, + guard_raw: Option<Bool>, + guard: Option<V>, + ) -> Result<(), Why> { let Fields::Valu(v) = &inst.fields else { unreachable!() }; @@ -7607,6 +7667,14 @@ impl<'a> Lower<'a> { let me = self.console_lane(); let is = self.s.m.cmp(c, pred::EQ, me, lane); let r = self.s.m.select(c, is, a, old); + // On the console the write ignores EXEC: lane K takes the scalar whenever + // some lane of the console wave runs the instruction, even with K outside + // EXEC. The select above does that only where the guard reaches K's own + // host lane, so re-issue it to a host lane in EXEC where it always does. + let r = match self.lane_write(guard_raw, lane, a, r) { + Some(w) => w, + None => r, + }; int(self, r) } "v_readfirstlane_b32" @@ -11951,4 +12019,40 @@ mod tests { // A 16-bit float is a half already, sign included. assert_eq!(half(0xBC00 << half_shift(16)), -1.0); } + + /// `v_writelane_b32` ignores EXEC on the console: lane K takes the scalar + /// whenever some lane of the wave runs the instruction, even with K outside + /// EXEC. The plain vector write under the narrowed EXEC loses that, so the + /// lowering re-issues the write to a host lane in EXEC (a `waveReadLaneAt`). + #[test] + fn cpu_side_lane_write_reissue_is_emitted() { + // EXEC narrowed per lane (`v_cmpx_gt_u32 exec, s0, v0`): the lanes with + // v0 <= s0 drop out of EXEC, so a `v_writelane_b32` to one of those lanes + // is outside EXEC while the wave still runs it. On the console the write + // ignores EXEC and still lands in that lane; the plain write under the + // narrowed EXEC would drop it. The lane-write words are the working + // encoding from `resource.rs` (v_writelane_b32 v0, s9, 3). + let words: &[u32] = &[ + 0xBE80_0380, // s_mov_b32 s0, 0 (root constant: the threshold) + 0x7DA8_0000, // v_cmpx_gt_u32 exec, s0, v0 (lanes with v0 > s0 keep EXEC) + 0xBE89_0385, // s_mov_b32 s9, 5 (the scalar to park in the lane) + 0xD761_0000, + 0x0001_0609, // v_writelane_b32 v0, s9, 3 + 0xBF81_0000, // s_endpgm + ]; + let l = lower_wave(words, vec![], vec![], false).unwrap(); + // The re-issue reads the scalar from a host lane in EXEC (waveReadLaneAt). + // The plain write alone emits no such read. + assert!(l.lane_reads >= 1, "the lane write must be re-issued to a host lane in EXEC"); + + // Control: the same write with EXEC not narrowed needs no re-issue. + let whole: &[u32] = &[ + 0xBE89_0385, // s_mov_b32 s9, 5 + 0xD761_0000, + 0x0001_0609, // v_writelane_b32 v0, s9, 3 + 0xBF81_0000, // s_endpgm + ]; + let w = lower_wave(whole, vec![], vec![], false).unwrap(); + assert_eq!(w.lane_reads, 0, "a whole-wave lane write needs no re-issue"); + } } ``` ```diff --- a/crates/victory-shader/src/emit/wave64_tests.rs +++ b/crates/victory-shader/src/emit/wave64_tests.rs @@ -530,3 +530,74 @@ fn scc_of_a_mask_operation_joined_with_a_scalar_test_needs_the_skip_wave_wide() } eprintln!("ran on the hardware device: the inner test's SCC for every lane once some lane is inside"); } + +/// One console wave of 64. `v_writelane_b32` writes its lane whatever EXEC is: inside +/// `if (t > s0) { ... }`, lane 0 (never inside) takes the scalar as soon as any thread is. +/// The compiler parks scalars this way in a VGPR that has other uses too (`unspill` leaves +/// those alone). Every thread stores what lane 0 holds after the join: 5 once the body +/// ran, 7 when the wave skipped it. +#[test] +fn a_lane_write_reaches_its_lane_outside_exec() { + let words = [ + 0x7E12_0287, // v_mov_b32 v9, 7 + 0x7D82_0000, // v_cmp_lt_u32 vcc, s0, v0 + 0xBE8C_246A, // s_and_saveexec_b64 s[12:13], vcc + 0xBF88_0003, // s_cbranch_execz to "join" + 0xBE86_0385, // s_mov_b32 s6, 5 + 0xD761_0009, + 0x0001_0006, // v_writelane_b32 v9, s6, 0 + 0xBEFE_040C, // join: s_mov_b64 exec, s[12:13] + 0xD760_0007, + 0x0001_0109, // v_readlane_b32 s7, v9, 0 + 0x7E02_0207, // v_mov_b32 v1, s7 + 0x38 << 26 | 0x1C << 18, + 0x80 << 24 | 2 << 16 | 1 << 8, // buffer_store_dword v1, off, s[8:11], 0 + ]; + let native = native(&words); + let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build"); + for i in p.blocks.iter().flat_map(|b| &b.insts) { + eprintln!(" {:#06x} {}", i.machine.offset, i.name()); + } + let _one = super::valu_tests::ONE_AT_A_TIME.lock().unwrap_or_else(|e| e.into_inner()); + let forms = [ + ("as is", Some(p.clone())), + ("without skips", ir::without_skips(&p, false)), + ("without skips, scalars followed", ir::without_skips(&p, true)), + ]; + let mut wrong = Vec::new(); + for (name, q) in &forms { + let Some(q) = q else { + eprintln!("{name}: the skip is kept"); + continue; + }; + lower::take_needs(); + let shader = match lowered(&native, q, &HashSet::new()) { + Ok(s) => s, + Err(e) => { + eprintln!("{name}: {e}"); + continue; + } + }; + // (threads above s0 inside) -> lane 0 after the join + for (s0, expected) in [(10u32, 5u32), (62, 5), (63, 7)] { + let Some(got) = on_the_card(&shader, [s0, 0]) else { return }; + eprintln!("{name}: threads above {s0} inside -> {got} (the console: {expected})"); + if got != expected { + wrong.push(format!("{name}: s0 = {s0}: {got}, not {expected}")); + } + } + } + // The same with lane 0 inside (`t < s0`): the write lands in every form. + let mut inside = words; + inside[1] = 0x7D88_0000; // v_cmp_gt_u32 vcc, s0, v0 + let native = native_of(&inside, true, 64); + let p = ir::build(&native.code, native.wave64, native.vgprs).expect("ir::build"); + lower::take_needs(); + let shader = lowered(&native, &p, &HashSet::new()).expect("lower"); + for (s0, expected) in [(10u32, 5u32), (0, 7)] { + let Some(got) = on_the_card(&shader, [s0, 0]) else { return }; + eprintln!("lane 0 inside, as is: threads below {s0} inside -> {got} (the console: {expected})"); + assert_eq!(got, expected, "lane 0 inside, s0 = {s0}"); + } + assert!(wrong.is_empty(), "{wrong:#?}"); +} ``` qwen3.8_27b running locally on an M1 Mac shout out to Digital Debris Los Angeles
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/fxceless--victory-fork#111
No description provided.