-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Optimization regression in 1.32+ #59352
Comments
have bisected this regression and the PR where the regression started is #55932 seems like the inliner are not able to inline the function any more after that PR |
Worth noting with example::num_to_digit_fast:
add edi, -48
xor eax, eax
cmp edi, 8
cmovb eax, edi
ret
example::num_to_digit_fast2:
add edi, -48
xor eax, eax
cmp edi, 7
cmovbe eax, edi
ret |
As far as I can see, this can be solved if mir inlining gets out of mir-opt-level 2. |
Add test for rust-lang#59352 Issue rust-lang#59352 reported an optimization regression with rustc 1.32.0+. That regression could be tracked to a change that caused a function to miss the size limit of llvm's inlining, which results in an unreachable panicing branch being generated. Enabling mir inline solves the issue, but is currently only done for `mir-opt-level>=2`. This PR adds a test that can serve as a regression test for rust-lang#59352, if/when mir inlining gets mature enough for opt-level 1, or some other optimization can remove the panic.
…laumeGomez Rollup of 6 pull requests Successful merges: - rust-lang#77693 (Add test for rust-lang#59352) - rust-lang#80515 (Improve JS performance by storing length before comparing to it in loops) - rust-lang#81030 (Update mdbook) - rust-lang#81033 (Remove useless `clean::Variant` struct) - rust-lang#81049 (inline: Round word-size cost estimates up) - rust-lang#81054 (Drop a few unneeded borrows) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
FYI, looks like this got partially fixed somewhere in 1.64 (no clue by which commit though):
And 1.65 optimized it more, it looks mostly the same as before the regression now (only difference being
|
The following function:
With 1.31 produced the following:
Which looks reasonable, as
unwrap()
should never fail.But in 1.32 and above it produces an unnecessary panic branch:
Interestingly, when I manually inline
is_digit
:rust/src/libcore/char/methods.rs
Lines 58 to 61 in 89573b3
Or just use
unwrap_or
:It produces good code on all compiler versions.
Godbolt instance I tested this on: https://godbolt.org/z/8yg7x0
The text was updated successfully, but these errors were encountered: