-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Remove trivial branches in with_cond #13055
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
Conversation
Removes branches on constant values when using with_cond, improving the performance of non-optimized code and (hopefully) improving compile times. This is a fairly simple front-end optimization.
My setup right now doesn't usually provide reliable measures of time, but I can try (in a few hours) |
Do you have any statistics for before/after codegen for this? Front-end optimizations are tricky and can easily go wrong, so it's good to make sure that they're worth it before committing. |
@alexcrichton for what it's worth, we do a similar optimization in |
Indeed, and it has caused bugs before (see #9484). That was also a proven win because all of our |
FWIW, in
And the |
@dotdash, is that saying that out of all of |
@alexcrichton The above is the output from |
Correction, they don't directly originate from |
It would be possible (although annoying) to make the implementation of |
@huonw, I don't think it's worth the trouble. Better have the shortcut in |
While a plausible optimization, it sounds like we don't generate code that benefits much from this, so I'm going to close this for now. We may want to implement this in the future, but it's likely more reliable to wait for a visible benefit in order to exercise the optimization. |
Only check for `automatically_derived` on impl blocks This brings us in line with how rustc checks for the attribute. Also note that `unused_attributes` will trigger if it's placed anywhere else. See: https://github.com/rust-lang/rust/blob/9a21ac8e7efe9ea26a8065d0959a976ca32039bb/compiler/rustc_passes/src/dead.rs#L400-L403 https://github.com/rust-lang/rust/blob/9a21ac8e7efe9ea26a8065d0959a976ca32039bb/compiler/rustc_passes/src/liveness.rs#L143-L148 changelog: none
Removes branches on constant values when using with_cond, improving the
performance of non-optimized code and (hopefully) improving compile times.
This is a fairly simple front-end optimization.
@cmr if you could see if there is a measurable difference in compile times, that would be awesome