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

Cranelift: Break op cost ties with expression depth in egraphs #7456

Merged
merged 5 commits into from
Nov 7, 2023

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Nov 2, 2023

This means that, when the opcode cost is the same, we prefer shallow and wide
expressions to narrow and deep. For example, (a + b) + (c + d) is preferred to
((a + b) + c) + d. This is beneficial because it exposes more
instruction-level parallelism and shortens live ranges.

Follow up PRs will add rules that take advantage of this.

Depends on #7465

@fitzgen fitzgen requested a review from a team as a code owner November 2, 2023 16:44
@fitzgen fitzgen requested review from elliottt and removed request for a team November 2, 2023 16:44
@github-actions github-actions bot added the cranelift Issues related to the Cranelift code generator label Nov 2, 2023
Copy link
Member

@cfallin cfallin left a comment

Choose a reason for hiding this comment

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

LGTM to this as well, thanks! Will wait for #7465 to merge and this to rebase on main then we can merge.

Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

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

🎉

cranelift/codegen/src/egraph/cost.rs Outdated Show resolved Hide resolved
cranelift/codegen/src/egraph/cost.rs Show resolved Hide resolved
cranelift/codegen/src/egraph/cost.rs Outdated Show resolved Hide resolved
fitzgen and others added 5 commits November 7, 2023 13:27
This means that, when the opcode cost is the same, we prefer shallow and wide
expressions to narrow and deep. For example, `(a + b) + (c + d)` is preferred to
`((a + b) + c) + d`. This is beneficial because it exposes more
instruction-level parallelism and shortens live ranges.

Co-Authored-By: Trevor Elliott <telliott@fastly.com>
Co-Authored-By: Chris Fallin <chris@cfallin.org>
Co-Authored-By: Trevor Elliott <telliott@fastly.com>
@fitzgen fitzgen added this pull request to the merge queue Nov 7, 2023
Merged via the queue into bytecodealliance:main with commit b9f2a30 Nov 7, 2023
18 checks passed
@fitzgen fitzgen deleted the depth-cost branch November 7, 2023 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cranelift Issues related to the Cranelift code generator
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants