From feb33f20a275459b16a7e08f606c14dc7d42e151 Mon Sep 17 00:00:00 2001 From: gefydev Date: Wed, 25 Nov 2026 14:23:05 -0300 Subject: [PATCH] Tests: the bridged mask write checks for no barrier past the first branch a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier (#2074) counted the group barriers of the whole program and wanted exactly one. Since #2074 other changes reached main (a whole-wave EXEC branch now meets an exchange of its condition in the entry block), so the program has three, all in the entry block, before the first conditional branch, where every lane of both halves is. The test failed on every machine with DXC although the property it protects still holds: the guarded float compare ballots its own half and its block has none. The test now wants at least one barrier in the entry block and none past the first conditional branch, where only one half may be. With the #2074 fix switched off, the new check fails on the barriers of the guarded block, so it still catches the deadlock it was written for. A count of the whole program would have let a barrier move into the guarded block and still pass. Found by DarkPanda69 and Gevroska on #2074. --- crates/xcl/src/gpu/recomp/lower_dxil.rs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/crates/xcl/src/gpu/recomp/lower_dxil.rs b/crates/xcl/src/gpu/recomp/lower_dxil.rs index a3b942da6c..58d52fa4b8 100644 --- a/crates/xcl/src/gpu/recomp/lower_dxil.rs +++ b/crates/xcl/src/gpu/recomp/lower_dxil.rs @@ -1120,7 +1120,8 @@ mod tests { /// wave64 group reaches (Pipodi's point 5 on #1745): a nested `if` whose condition goes to /// `s_and_saveexec`. #1426 would ballot the compare's mask through an exchange, a group /// barrier the upper half never reaches. The bridge reads back only each lane's bit, so this - /// half's ballot is enough, and the only barrier left is the one at the start. + /// half's ballot is enough, and no barrier is left past the first conditional branch, where + /// only one half may be: the barriers are in the entry block, which every lane reaches. #[test] fn a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier() { let lines: &[I] = &[ @@ -1150,9 +1151,16 @@ mod tests { return runner::skip_test("no DXC"); } let text = crate::gpu::dxil::validate::disassemble(&dxil).unwrap(); - let barriers = text.lines().filter(|l| l.contains("call void @dx.op.barrier")).count(); - // the one where the halves take their console lanes, at the start (every lane is there) - assert_eq!(barriers, 1, "group barriers in the program:\n{text}"); + let barriers = |s: &str| s.lines().filter(|l| l.contains("call void @dx.op.barrier")).count(); + // The entry block holds the barriers: the one where the halves take their console lanes + // and the pair around the exchange of the whole-wave EXEC condition of `s_cbranch_execz` + // (how many there are is the lowering's business, every lane of both halves is there). + // Past the first conditional branch only one half may be, so no barrier can be there. + let body = text.split_once("define void @main()").map_or(text.as_str(), |(_, b)| b); + let (entry, past) = body.split_once(" br i1 ").unwrap_or((body, "")); + assert!(!past.is_empty(), "no conditional branch in the program:\n{text}"); + assert!(barriers(entry) >= 1, "no group barrier in the entry block:\n{text}"); + assert_eq!(barriers(past), 0, "a group barrier past the first conditional branch, where one half may be elsewhere:\n{text}"); if !gpu() { return; }