Useless while loop with a step of 2 doesn't optimize away #60616
Labels
A-codegen
Area: Code generation
I-slow
Issue: Problems and improvements with respect to performance of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
While investigating a variant of #59281 and #57517 reported on Reddit, I found that even a
while
loop version still had an extra loop that wasn't optimized away. A minimal example that demonstrates the issue:While the same loop with a step increment of 1 does optimize away the loop:
It looks like this optimization happens in
rustc
before LLVM. Increment by 2:Increment by 1:
The text was updated successfully, but these errors were encountered: