diff --git a/src/nouveau/compiler/nak/from_nir.rs b/src/nouveau/compiler/nak/from_nir.rs index 60c9dcd4a6a..4ae8f2c8ce8 100644 --- a/src/nouveau/compiler/nak/from_nir.rs +++ b/src/nouveau/compiler/nak/from_nir.rs @@ -3106,17 +3106,28 @@ impl<'a> ShaderFromNir<'a> { let mut phi = OpPhiDsts::new(); for ni in nb.iter_instr_list() { - if ni.type_ == nir_instr_type_phi { - let np = ni.as_phi().unwrap(); - let dst = alloc_ssa_for_nir(&mut b, np.def.as_def()); - for (i, dst) in dst.iter().enumerate() { - let phi_id = phi_map.get_phi_id(np, i.try_into().unwrap()); - phi.dsts.push(phi_id, (*dst).into()); - } - self.set_ssa(np.def.as_def(), dst); - } else { + let Some(np) = ni.as_phi() else { break; + }; + + if DEBUG.annotate() { + let annotation = self + .nir_instr_printer + .instr_to_string(ni) + .split_whitespace() + .collect::>() + .join(" "); + b.push_op(OpAnnotate { + annotation: format!("generated by \"{}\"", annotation,), + }); } + + let dst = alloc_ssa_for_nir(&mut b, np.def.as_def()); + for (i, dst) in dst.iter().enumerate() { + let phi_id = phi_map.get_phi_id(np, i.try_into().unwrap()); + phi.dsts.push(phi_id, (*dst).into()); + } + self.set_ssa(np.def.as_def(), dst); } if !phi.dsts.is_empty() { @@ -3125,7 +3136,7 @@ impl<'a> ShaderFromNir<'a> { let mut goto = None; for ni in nb.iter_instr_list() { - if DEBUG.annotate() { + if DEBUG.annotate() && ni.type_ != nir_instr_type_phi { let annotation = self .nir_instr_printer .instr_to_string(ni) @@ -3175,12 +3186,23 @@ impl<'a> ShaderFromNir<'a> { let mut phi = OpPhiSrcs::new(); - for i in sb.iter_instr_list() { - let np = match i.as_phi() { - Some(phi) => phi, - None => break, + for ni in sb.iter_instr_list() { + let Some(np) = ni.as_phi() else { + break; }; + if DEBUG.annotate() { + let annotation = self + .nir_instr_printer + .instr_to_string(ni) + .split_whitespace() + .collect::>() + .join(" "); + b.push_op(OpAnnotate { + annotation: format!("generated by \"{}\"", annotation,), + }); + } + for ps in np.iter_srcs() { if ps.pred().index == nb.index { let src = *self.get_src(&ps.src).as_ssa().unwrap();