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

Remove extra blocks for return statements #645

Merged
merged 4 commits into from
Oct 31, 2024
Merged

Conversation

oflatt
Copy link
Member

@oflatt oflatt commented Oct 30, 2024

This PR adds a small optimization that moves return statements up into parent blocks

@oflatt oflatt changed the base branch from main to oflatt-investigate-translation October 30, 2024 22:58
Base automatically changed from oflatt-investigate-translation to main October 30, 2024 23:38
Copy link
Member

@chandrakananandi chandrakananandi left a comment

Choose a reason for hiding this comment

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

Seems fine to me!

.fuze_up()
.return_early()
.return_early()
.collapse_empty_blocks()
Copy link
Member

Choose a reason for hiding this comment

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

collapse_empty also needs to be run to fixpoint? We cant do it in a single pass?

Copy link
Member Author

Choose a reason for hiding this comment

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

If there are two empty blocks, you need to skip both of them. This pass only does it once per time it runs

}

/// Find cases where a block jumps directly to another block A -> B where B
/// Converts footers into bril expressions to simplify this pass
fn remove_footers(mut self) -> SimpleCfgFunction {
Copy link
Member

Choose a reason for hiding this comment

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

what is a footer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Footers are used by the RVSDG translation to track new stuff added to the block
We don't really care about footers vs instructions so we convert them here

@oflatt oflatt merged commit 7c6ee48 into main Oct 31, 2024
4 checks passed
@oflatt oflatt deleted the oflatt-remove-extra-block branch October 31, 2024 19:43
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