diff --git a/src/nouveau/compiler/nak/legalize.rs b/src/nouveau/compiler/nak/legalize.rs index fe995e7c27a..8e145d09649 100644 --- a/src/nouveau/compiler/nak/legalize.rs +++ b/src/nouveau/compiler/nak/legalize.rs @@ -970,6 +970,7 @@ fn legalize_instr( b: &mut impl SSABuilder, bl: &impl BlockLiveness, block_uniform: bool, + pinned: &HashSet, ip: usize, instr: &mut Instr, ) { @@ -989,7 +990,10 @@ fn legalize_instr( // we need to insert copies to warp regs which we can collect. match &mut src.src_ref { SrcRef::SSA(vec) => { - if vec.is_uniform() && vec.comps() > 1 { + if vec.is_uniform() + && vec.comps() > 1 + && !pinned.contains(vec) + { copy_ssa_ref(b, vec, vec.file().unwrap().to_warp()); } } @@ -1049,6 +1053,7 @@ impl Shader { let sm = self.info.sm; for f in &mut self.functions { let live = SimpleLiveness::for_function(f); + let mut pinned = HashSet::new(); for (bi, b) in f.blocks.iter_mut().enumerate() { let bl = live.block_live(bi); @@ -1056,8 +1061,14 @@ impl Shader { let mut instrs = Vec::new(); for (ip, mut instr) in b.instrs.drain(..).enumerate() { + if let Op::Pin(pin) = &instr.op { + if let Dst::SSA(ssa) = &pin.dst { + pinned.insert(*ssa); + } + } + let mut b = SSAInstrBuilder::new(sm, &mut f.ssa_alloc); - legalize_instr(&mut b, bl, bu, ip, &mut instr); + legalize_instr(&mut b, bl, bu, &pinned, ip, &mut instr); b.push_instr(instr); instrs.append(&mut b.as_vec()); }