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

improve asm copy propagation for MOVE instruction #6641

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented Oct 15, 2024

Description

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

Copy link

codspeed-hq bot commented Oct 15, 2024

CodSpeed Performance Report

Merging #6641 will not alter performance

Comparing xunilrj/cpy-propagation-move (ff484be) with master (1dfca80)

Summary

✅ 22 untouched benchmarks

VirtualOp::ADD(dest, opd1, opd2) => {
// We don't look for the first operand being a constant and the second
// one a base register. Such patterns must be canonicalised prior.
if let Some(&RegContents::Constant(c2)) = reg_contents.get(opd2) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I correct in understanding that this is a bug fix? (unrelated to MOVs). We're missing an optimization opportunity here

Copy link
Contributor Author

@xunilrj xunilrj Nov 16, 2024

Choose a reason for hiding this comment

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

This should be the same code, but with a if let to accommodate the fact that this runs inside a retain_mut now.

},
VirtualOp::MOVE(dest, src) => {
let ver = get_def_version(&latest_version, src);
if let Some(RegContents::BaseOffset(src, 0)) = reg_contents.get(src) {
Copy link
Contributor

Choose a reason for hiding this comment

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

are you trying to catch something like

a = b
b = a

?? Not sure I understand what is it that you're trying to optimize, and why the existing copy propagation in the assembly generator doesn't apply.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For example, from the configurable_const test:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a = b, this match arm does two things:
1 - first, it indeed checks if a and b are already the same, and it removes the instruction;
2 - but it also propagates that b and a are the same for future optimizations.

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.

2 participants