Strip asserts right at the end of lowering#8094
Merged
Conversation
The simplifier exploits asserts to make simplification. When compiling with NoAsserts, certain assertions aren't ever introduced, which means that the simplifier can't exploit certain things that we know to be true. Mostly this has a negative effect on code size. E.g. tail cases get generated even though they are actually dead code. This PR keeps all the assertions right until the end of lowering, when it strips them in a dedicated pass. This reduces object file size for a large production blob of Halide code by ~10%, without measurably affecting runtime.
Member
|
I expect we'll need to make sure this doesn't introduce any failures in our large codebase before it lands. |
Contributor
|
To be clear, this shouldn't affect code that isn't compiled with NoAsserts (ie. the vast majority of code), right? |
Contributor
steven-johnson
left a comment
There was a problem hiding this comment.
LGTM but will test in google3 before we land
| s = hoist_prefetches(s); | ||
| log("Lowering after hoisting prefetches:", s); | ||
|
|
||
| if (t.has_feature(Target::NoAsserts)) { |
Contributor
There was a problem hiding this comment.
Might be worth adding comment from the PR about why we do this at the end
Member
Author
That's correct. This should have no effect on regular assert-using Halide code. |
Contributor
|
No related failures yet, going to run an all-of-google test just to be sure |
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The simplifier exploits asserts to make simplifications. When compiling with NoAsserts, certain assertions aren't ever introduced, which means that the simplifier can't exploit certain things that we know to be true. Mostly this has a negative effect on code size. E.g. tail cases get generated even though they are actually dead code.
This PR keeps all the assertions right until the end of lowering, when it strips them in a dedicated pass.
This reduces object file size for a large production blob of Halide code by ~10%, without measurably affecting runtime.