From ab3c0a40c479f31658a97ac150d9fe668e07ae51 Mon Sep 17 00:00:00 2001 From: Iizerd <47404005+Iizerd@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:12:10 -0700 Subject: [PATCH 1/2] Added support for multiple OperandConstraint::Reuse operands. whoopsies. double whoopsies. --- src/ion/liveranges.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ion/liveranges.rs b/src/ion/liveranges.rs index b3ee32cb..a66f8269 100644 --- a/src/ion/liveranges.rs +++ b/src/ion/liveranges.rs @@ -460,15 +460,14 @@ impl<'a, F: Function> Env<'a, F> { // Does the instruction have any input-reusing // outputs? This is important below to establish // proper interference wrt other inputs. We note the - // *vreg* that is reused, not the index. - let mut reused_input = None; + // *vreg*s that are reused, not the index. + let mut reused_inputs: SmallVec<[VReg; 4]> = smallvec![]; for op in self.func.inst_operands(inst) { if let OperandConstraint::Reuse(i) = op.constraint() { debug_assert!(self.func.inst_operands(inst)[i] .as_fixed_nonallocatable() .is_none()); - reused_input = Some(self.func.inst_operands(inst)[i].vreg()); - break; + reused_inputs.push(self.func.inst_operands(inst)[i].vreg()) } } @@ -592,8 +591,8 @@ impl<'a, F: Function> Env<'a, F> { // the other inputs and the // input-that-is-reused/output. (OperandKind::Use, OperandPos::Early) - if reused_input.is_some() - && reused_input.unwrap() != operand.vreg() => + if !reused_inputs.is_empty() + && !reused_inputs.contains(&operand.vreg()) => { ProgPoint::after(inst) } From f9bdffc52a7aec2578b1b495007f655f206aae57 Mon Sep 17 00:00:00 2001 From: Iizerd <47404005+Iizerd@users.noreply.github.com> Date: Fri, 6 Sep 2024 12:01:20 -0700 Subject: [PATCH 2/2] Stop moving fixed reg operands to after if there is a clobber or late fixed def of the same PReg. --- src/ion/liveranges.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/ion/liveranges.rs b/src/ion/liveranges.rs index a66f8269..f4e1b119 100644 --- a/src/ion/liveranges.rs +++ b/src/ion/liveranges.rs @@ -594,7 +594,17 @@ impl<'a, F: Function> Env<'a, F> { if !reused_inputs.is_empty() && !reused_inputs.contains(&operand.vreg()) => { - ProgPoint::after(inst) + if let OperandConstraint::FixedReg(preg) = operand.constraint() { + if self.func.inst_clobbers(inst).contains(preg) + || late_def_fixed.contains(&preg) + { + ProgPoint::before(inst) + } else { + ProgPoint::after(inst) + } + } else { + ProgPoint::after(inst) + } } (OperandKind::Use, OperandPos::Early) => ProgPoint::before(inst), };