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

Keep all Uses in a single vector #172

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Amanieu
Copy link
Contributor

@Amanieu Amanieu commented Dec 6, 2023

Previously, each live range would carry a list of uses in a SmallVec<[Use; 4]>, which was an inefficient use of memory.

This PR instead keeps a single Vec<Use> for all uses in a function, sorted by vreg and position. Each live range now holds a Range<u32> of indices which refer to its uses inside this vector.

Benchmarks show that this consistently improves compilation times by ~2%.

Previously, each live range would carry a list of uses in a
`SmallVec<[Use; 4]>`, which was an inefficient use of memory.

This PR instead keeps a single `Vec<Use>` for all uses in a function,
sorted by vreg and position. Each live range now holds a `Range<u32>` of
indices which refer to its uses inside this vector.

Benchmarks show that this consistently improves compilation times by
~2%.
Comment on lines -828 to +836
if u.operand.constraint() == OperandConstraint::Any {
trace!(" -> migrating this any-constrained use to the spill range");
spill_uses.push(u);
// if u.operand.constraint() == OperandConstraint::Any {
// trace!(" -> migrating this any-constrained use to the spill range");
// spill_uses.push(u);

// Remember if we're moving the def of this vreg into the spill range, so that
// we can set the appropriate flags on it later.
spill_starts_def = spill_starts_def || is_def;
// // Remember if we're moving the def of this vreg into the spill range, so that
// // we can set the appropriate flags on it later.
// spill_starts_def = spill_starts_def || is_def;

continue;
}
// continue;
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only part that I couldn't make work out of the box: since each live range can only refer to a single continuous range of uses, disjoint sets of uses cannot be represented by a single live range.

One option would be to create multiple sub-ranges for the spill bundle here, so that Any uses can still be transferred to the spill bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant