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

Iterate inlining and simplification until we can do no more #133

Merged
merged 1 commit into from
May 5, 2022

Conversation

jwatzman
Copy link
Contributor

@jwatzman jwatzman commented May 5, 2022

Inlining can open up new opportunities for simplification. The rewriter
tries to take advantage of this by doing two passes, but there can be
chains of inlinable variables which can require an arbitrary number of
passes. Instead, we can track whether or not we've inlined a variable
this pass, and continue with further passes until we haven't found such
a variable.

Copy link
Owner

@laurentlb laurentlb left a comment

Choose a reason for hiding this comment

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

Very nice, thanks a lot!

src/rewriter.fs Outdated Show resolved Hide resolved
Inlining can open up new opportunities for simplification. The rewriter
tries to take advantage of this by doing two passes, but there can be
chains of inlinable variables which can require an arbitrary number of
passes. Instead, we can track whether or not we've inlined a variable
this pass, and continue with further passes until we haven't found such
a variable.
@laurentlb laurentlb merged commit 50b12fe into laurentlb:master May 5, 2022
jwatzman added a commit to jwatzman/Shader_Minifier that referenced this pull request May 11, 2022
The logic used in laurentlb#133 for when to iterate isn't quite right: it runs
another pass when it detects an inlinable variable, not when it actually
inlines. This means we sometimes run an extra pass (i.e., after removing
an unused variable, we don't need to run another pass) and sometimes run
too few passes (i.e., when inlining a variable we didn't "find"
ourselves, such as an `i_blah` variable).

Instead, we can use a very similiar technique but detecting when we
actually do the inlining, not the finding.
laurentlb pushed a commit that referenced this pull request May 11, 2022
The logic used in #133 for when to iterate isn't quite right: it runs
another pass when it detects an inlinable variable, not when it actually
inlines. This means we sometimes run an extra pass (i.e., after removing
an unused variable, we don't need to run another pass) and sometimes run
too few passes (i.e., when inlining a variable we didn't "find"
ourselves, such as an `i_blah` variable).

Instead, we can use a very similiar technique but detecting when we
actually do the inlining, not the finding.
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.

None yet

2 participants