Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop moving Early FixedReg Use operands in certain conditions when Reuse operands are present. #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/ion/liveranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down Expand Up @@ -592,10 +591,20 @@ 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)
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),
};
Expand Down
Loading