-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Strip asserts right at the end of lowering #8094
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.
I expect we'll need to make sure this doesn't introduce any failures in our large codebase before it lands. |
To be clear, this shouldn't affect code that isn't compiled with NoAsserts (ie. the vast majority of code), right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but will test in google3 before we land
@@ -427,6 +428,12 @@ void lower_impl(const vector<Function> &output_funcs, | |||
s = hoist_prefetches(s); | |||
log("Lowering after hoisting prefetches:", s); | |||
|
|||
if (t.has_feature(Target::NoAsserts)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth adding comment from the PR about why we do this at the end
That's correct. This should have no effect on regular assert-using Halide code. |
No related failures yet, going to run an all-of-google test just to be sure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to land.
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.