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

A couple of small refactorings to the egraph elaboration pass #7304

Merged
merged 1 commit into from
Oct 20, 2023

Conversation

elliottt
Copy link
Member

@elliottt elliottt commented Oct 19, 2023

@jameysharp and I noticed a couple of refactoring opportunities while reading through the elaboration pass:

  • The elaboration loop doesn't need to match on the top of the stack as a reference, because each case pops it immediately. Instead we can pop and match on the popped value.
  • Computing the cost of a pure ValueDef::Result was using the block that contains the instruction to determine the level, but since pure values will not be in the DFG yet, this would default to LoopLevel::root() unconditionally. This also meant that the Cost::at_level function turned into an identity function on the cost given, making it unnecessary.

Co-authored-by: Jamey Sharp jsharp@fastly.com

@jameysharp and I noticed a couple of refactoring opportunities while
reading through the elaboration pass:

* The elaboration loop doesn't need to match on the top of the stack as
  a reference, because each case pops it immediately. Instead we can pop
  and match on the popped value.
* Computing the cost of a `Result` value that's not in the DFG was using
  the block that contains the instruction to determine the level, but
  since the instruction is already known to not be in the DFG, this
  would default to `LoopLevel::root()` unconditionally. This also meant
  that the `Cost::at_level` function turned into an identity function on
  the cost given, making it unnecessary.

Co-authored-by: Jamey Sharp <jsharp@fastly.com>
@elliottt elliottt requested a review from a team as a code owner October 19, 2023 22:52
@elliottt elliottt requested review from abrown and cfallin and removed request for a team October 19, 2023 22:52
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! Good find w.r.t. the loop-level cost factor being a no-op; I suspect this was left over from an earlier version of extraction. I'd be interested to hear any thoughts you or others have about using the loop level somehow, but I'm happy to see this merged for now!

@cfallin cfallin added this pull request to the merge queue Oct 19, 2023
Merged via the queue into bytecodealliance:main with commit 04fcb6a Oct 20, 2023
18 checks passed
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