Bounds check not elided for index that should be known to be in-bounds #139759
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
I-slow
Issue: Problems and improvements with respect to performance of generated code.
llvm-fixed-upstream
Issue expected to be fixed by the next major LLVM upgrade, or backported fixes
When calculating a new index with
valid_index.saturating_sub(1)
, I expected the bounds check to be elided. Instead,get_unchecked
must be used to eliminate the check.https://rust.godbolt.org/z/3d8o81T5h
Assembly
I came across this while starting to constify
floor_char_boundary
by rewriting it into a while loop.https://rust.godbolt.org/z/zEYvEPG8v
Meta
The text was updated successfully, but these errors were encountered: