-
Notifications
You must be signed in to change notification settings - Fork 13.3k
RangeToInclusive
code-generation much worse than equivilent RangeTo
#63646
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
Comments
If you use |
I'm having the same issue, my code takes about twice as long with "..=", even with -C opt-level=3: https://rust.godbolt.org/z/yrPRd3 |
The problem is fixed on 1.42, but is back on the beta 1.43 and on nightly : |
This no longer reproduces on a recent rustc. Should this be closed, or is it preferable to add a codegen test? |
Should have a test |
Rollup merge of rust-lang#134871 - clubby789:test-63646, r=compiler-errors Add codegen test for issue 63646 Closes rust-lang#63646
I still see a slowdown with the inclusive range with the test I posted above, although not as bad as before:
|
Did you try |
I'm getting very strange (but reproducible) results:
That is, O3 is slower for the exclusive ranges. However, if I look at the disassembly, it seems the code is actually identical – looks like this is some strange effect triggered by alignment or something? I'm not really sure what to make of it. |
I have two copies of the exact same code, one using
for _ in 0..65
and the other usingfor _ in 0..=64
. The0..65
one optimizes down to very simple code, however the0..=64
version ends up emitting a large amount of unnecessary code.RangeTo example
Emits (https://rust.godbolt.org/z/pcscMB):
RangeToInclusive example
Emits (https://rust.godbolt.org/z/22JaO2):
The text was updated successfully, but these errors were encountered: