diff --git a/src/nouveau/compiler/nak/to_cssa.rs b/src/nouveau/compiler/nak/to_cssa.rs index 2e01a9dae2a..5caffc1df68 100644 --- a/src/nouveau/compiler/nak/to_cssa.rs +++ b/src/nouveau/compiler/nak/to_cssa.rs @@ -355,31 +355,34 @@ impl Function { debug_assert!(src.src_mod.is_none()); if let SrcRef::SSA(vec) = &src.src_ref { debug_assert!(vec.comps() == 1); - let ss = cg.ssa_set(&vec[0]); - if cg.sets_interfere(ps, ss, &self.blocks) { - let tmp = self.ssa_alloc.alloc(file); - pcopy.push(tmp.into(), *src); - *src = tmp.into(); - } else { - cg.sets_merge(ps, ss); + if vec[0].file() == file { + let ss = cg.ssa_set(&vec[0]); + if cg.sets_interfere(ps, ss, &self.blocks) { + let tmp = self.ssa_alloc.alloc(file); + pcopy.push(tmp.into(), *src); + *src = tmp.into(); + } else { + cg.sets_merge(ps, ss); + } + continue; } - } else { - // Non-SSA sources get an actual Mov instruction - // and are not considered part of the parallel - // copy. - let tmp = self.ssa_alloc.alloc(file); - if DEBUG.annotate() { - instrs.push(Instr::new_boxed(OpAnnotate { - annotation: "generated by to_cssa" - .into(), - })); - } - instrs.push(Instr::new_boxed(OpCopy { - dst: tmp.into(), - src: *src, - })); - *src = tmp.into(); } + + // Non-SSA sources or sources with a different file + // from the destination get an actual copy + // instruction and are not considered part of the + // parallel copy. + let tmp = self.ssa_alloc.alloc(file); + if DEBUG.annotate() { + instrs.push(Instr::new_boxed(OpAnnotate { + annotation: "generated by to_cssa".into(), + })); + } + instrs.push(Instr::new_boxed(OpCopy { + dst: tmp.into(), + src: *src, + })); + *src = tmp.into(); } if !pcopy.is_empty() {