From b79e55bed79dd4c7d619c3370263600df14cd778 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 30 Jul 2025 14:57:23 +0200 Subject: [PATCH] nak: relayout opt_uniform_instrs I'm touching this code in the next commit, so this makes it easier to review. Reviewed-by: Faith Ekstrand Part-of: --- .../compiler/nak/opt_uniform_instrs.rs | 81 +++++++++---------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/src/nouveau/compiler/nak/opt_uniform_instrs.rs b/src/nouveau/compiler/nak/opt_uniform_instrs.rs index a7f55e680eb..750434fceb5 100644 --- a/src/nouveau/compiler/nak/opt_uniform_instrs.rs +++ b/src/nouveau/compiler/nak/opt_uniform_instrs.rs @@ -52,51 +52,50 @@ impl Shader<'_> { let mut r2ur = Default::default(); let mut propagated_r2ur = false; self.map_instrs(|mut instr, alloc| { - if matches!( - &instr.op, + match &instr.op { Op::Redux(_) - | Op::PhiDsts(_) - | Op::PhiSrcs(_) - | Op::Pin(_) - | Op::Unpin(_) - | Op::Vote(_) - ) { - MappedInstrs::One(instr) - } else if instr.is_uniform() { - let mut b = InstrBuilder::new(sm); - if should_lower_to_warp(sm, &instr, &r2ur) { - propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur); - instr.for_each_ssa_def_mut(|ssa| { - let w = alloc.alloc(ssa.file().to_warp()); - r2ur.insert(*ssa, w); - b.push_op(OpR2UR { - dst: (*ssa).into(), - src: w.into(), - }); - *ssa = w; - }); - let mut v = b.into_vec(); - v.insert(0, instr); - MappedInstrs::Many(v) - } else { - // We may have non-uniform sources - instr.for_each_ssa_use_mut(|ssa| { - let file = ssa.file(); - if !file.is_uniform() { - let u = alloc.alloc(file.to_uniform().unwrap()); + | Op::PhiDsts(_) + | Op::PhiSrcs(_) + | Op::Pin(_) + | Op::Unpin(_) + | Op::Vote(_) => MappedInstrs::One(instr), + _ if instr.is_uniform() => { + let mut b = InstrBuilder::new(sm); + if should_lower_to_warp(sm, &instr, &r2ur) { + propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur); + instr.for_each_ssa_def_mut(|ssa| { + let w = alloc.alloc(ssa.file().to_warp()); + r2ur.insert(*ssa, w); b.push_op(OpR2UR { - dst: u.into(), - src: (*ssa).into(), + dst: (*ssa).into(), + src: w.into(), }); - *ssa = u; - } - }); - b.push_instr(instr); - b.into_mapped_instrs() + *ssa = w; + }); + let mut v = b.into_vec(); + v.insert(0, instr); + MappedInstrs::Many(v) + } else { + // We may have non-uniform sources + instr.for_each_ssa_use_mut(|ssa| { + let file = ssa.file(); + if !file.is_uniform() { + let u = alloc.alloc(file.to_uniform().unwrap()); + b.push_op(OpR2UR { + dst: u.into(), + src: (*ssa).into(), + }); + *ssa = u; + } + }); + b.push_instr(instr); + b.into_mapped_instrs() + } + } + _ => { + propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur); + MappedInstrs::One(instr) } - } else { - propagated_r2ur |= propagate_r2ur(&mut instr, &r2ur); - MappedInstrs::One(instr) } });