-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Worse codegen for a get(a..a+N) slice range check on beta #112509
Comments
I think the change is that the MIR inliner now inlines The follow-up question is why LLVM can't still optimize the MIR. |
@rustbot label -regression-untriaged |
Just to be sure, would this missing fold also solve the same issue with range sizes bigger than 1? Like: https://godbolt.org/z/KxbE97faE |
No, that does not generalize. The previous issue was about the difference on 1.70. The regression on 1.71 would be llvm/llvm-project#63756. |
WG-prioritization assigning priority (Zulip discussion). @rustbot label -I-prioritize +P-medium |
Fixed by #114048, needs codegen test. |
Add codegen tests for E-needs-test close rust-lang#36010 close rust-lang#68667 close rust-lang#74938 close rust-lang#83585 close rust-lang#93036 close rust-lang#109328 close rust-lang#110797 close rust-lang#111508 close rust-lang#112509 close rust-lang#113757 close rust-lang#120440 close rust-lang#118392 close rust-lang#71096 r? nikic
Add codegen tests for E-needs-test close rust-lang#36010 close rust-lang#68667 close rust-lang#74938 close rust-lang#83585 close rust-lang#93036 close rust-lang#109328 close rust-lang#110797 close rust-lang#111508 close rust-lang#112509 close rust-lang#113757 close rust-lang#120440 close rust-lang#118392 close rust-lang#71096 r? nikic
Add codegen tests for E-needs-test close rust-lang#36010 close rust-lang#68667 close rust-lang#74938 close rust-lang#83585 close rust-lang#93036 close rust-lang#109328 close rust-lang#110797 close rust-lang#111508 close rust-lang#112509 close rust-lang#113757 close rust-lang#120440 close rust-lang#118392 close rust-lang#71096 r? nikic
Add codegen tests for E-needs-test close rust-lang#36010 close rust-lang#68667 close rust-lang#74938 close rust-lang#83585 close rust-lang#93036 close rust-lang#109328 close rust-lang#110797 close rust-lang#111508 close rust-lang#112509 close rust-lang#113757 close rust-lang#120440 close rust-lang#118392 close rust-lang#71096 r? nikic
Code
Godbolt repro: https://godbolt.org/z/Yv3qYqq4W
Variant A: check
a..
, then check..a+N
.Variant B: check
a..a+N
in one call.Note that N is a constant (1), as it's a size of an
u8
. Also note that that this example can be extended to other types ofbuf
:u16
,u32
,[u8; 17]
etc.Results
bytes.len() <= offset
check, then sets the byte and returnsOk
- perfect. (I wish the push/pop were only on the error path, but that's off topic).lea rdi, [rip + .L__unnamed_1]
looks like it moved address calculation of the error string to the happy path.This issue concerns the last one.
I did an ad-hoc microbenchmark that shows Variant B on Beta (and nightly) to become 2-3x slower, but I'm not sure if that benchmark needs attaching - to me it's clear from the disassembly that the happy path codegen is now worse.
The text was updated successfully, but these errors were encountered: