-
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
Inconsistent iterator optimization #75980
Comments
Please come up with minimal example to show what you mean about missed-optimization. |
All right, highlighted 2 from that mess: https://rust.godbolt.org/z/EjW13c In this case, by optimized I mean evaluated. One sums the array, other sums every second element. I'm trying to figure out why this happens, but as of yet I have no idea why/where the first function gets interpreted... It's obvious it's not during mir optimization, since the emitted mir is rather verbose. |
This seems like a duplicate of #73825 . |
maybe const prop in LLVM after inlining. |
Although, to be fair, it's still not clear why an extra |
This is the thing I don't know. After comparing the MIR with and without "&", |
I'm not sure if this is the fault of const propagation (probably not?), but these examples (more examples, but a lot more messy) result in unexpected code.
In some instances, the function bodies are evaluated and are replaced by a constant value as expected. However, given some usage patterns, (the most simple is an extra
iterator.next
call where the return value is ignored) this simplification does not happen. It's not clear why some patterns can be simplified and others can't.The text was updated successfully, but these errors were encountered: