Open
Description
On Rust 1.79.0.
pub const fn missing_bce(v: &[u32]) -> u32 {
if v.is_empty() {
return 0;
}
let mut sum = 0;
let mut i = v.len() - 1;
while i > 0 {
sum += v[i];
i -= 1;
}
sum
}
https://godbolt.org/z/xxjKd5anW
The compiler should be able to elide the bounds check for v[i]
since i
is always in [0, v.len()-1].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generationCategory: This is a bug.Category: An issue highlighting optimization opportunities or PRs implementing suchIssue: Problems and improvements with respect to performance of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.