From a08f8c8804713194285ffba25f5b5bce08777433 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 5 Jun 2024 16:54:37 -0500 Subject: [PATCH] nak: Only copy-prop neg into iadd2/3 if no carry is written Fixes: 1b3382b86172 ("nak: Add modifier propagation") Part-of: --- src/nouveau/compiler/nak/opt_copy_prop.rs | 38 +++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/nouveau/compiler/nak/opt_copy_prop.rs b/src/nouveau/compiler/nak/opt_copy_prop.rs index 781b851c404..1c6f23cc63f 100644 --- a/src/nouveau/compiler/nak/opt_copy_prop.rs +++ b/src/nouveau/compiler/nak/opt_copy_prop.rs @@ -551,9 +551,41 @@ impl CopyPropPass { self.prop_to_pred(&mut instr.pred); - let src_types = instr.src_types(); - for (i, src) in instr.srcs_mut().iter_mut().enumerate() { - self.prop_to_src(src_types[i], src); + match &mut instr.op { + Op::IAdd2(add) => { + // Carry-out interacts funny with SrcMod::INeg so we can + // only propagate with modifiers if no carry is written. + if add.carry_out.is_none() { + self.prop_to_src(SrcType::I32, &mut add.srcs[0]); + self.prop_to_src(SrcType::I32, &mut add.srcs[1]); + } else { + self.prop_to_src(SrcType::ALU, &mut add.srcs[0]); + self.prop_to_src(SrcType::ALU, &mut add.srcs[1]); + } + } + Op::IAdd3(add) => { + // Overflow interacts funny with SrcMod::INeg so we can + // only propagate with modifiers if no overflow values + // are written. + if add.overflow[0].is_none() + && add.overflow[0].is_none() + { + self.prop_to_src(SrcType::I32, &mut add.srcs[0]); + self.prop_to_src(SrcType::I32, &mut add.srcs[1]); + self.prop_to_src(SrcType::I32, &mut add.srcs[2]); + } else { + self.prop_to_src(SrcType::ALU, &mut add.srcs[0]); + self.prop_to_src(SrcType::ALU, &mut add.srcs[1]); + self.prop_to_src(SrcType::ALU, &mut add.srcs[2]); + } + } + _ => { + let src_types = instr.src_types(); + for (i, src) in instr.srcs_mut().iter_mut().enumerate() + { + self.prop_to_src(src_types[i], src); + } + } } } }