Missed bound check removal #41789
Labels
A-codegen
Area: Code generation
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
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.
A little test program:
If I compile it with:
nightly-x86_64-pc-windows-gnu - rustc 1.19.0-nightly (f4209651e 2017-05-05)
Using:
rustc -C opt-level=3 --emit asm test1.rs
I get this asm for the loop:
The bound check isn't removed. To remove it I need to use get_unchecked_mut(), or code like this (with the same main function):
Now the loop gives a clean asm:
If I use:
unsafe { *result.get_unchecked_mut(i) = prod; }
The loop also gets unrolled four times:
The text was updated successfully, but these errors were encountered: