LLVM cannot prove that index is in bounds #81432
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
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.
Current status: Waiting for llvm/llvm-project#90417
When trying to get rid of
unsafe
code in commit 57d25179e6751854c298313070adc4ac4454e230 in #81427.I found a case that GCC can prove that the slice index in bound but LLVM cannot.
I tried this code (see generated assembly at godbolt https://godbolt.org/z/dTraGe):
I expected to see this happen: Compiler optimizes
eat_digits
to onlytrue
.Instead, this happened: LLVM cannot prove that, which leads to bounds check with
s[..i]
.Note that for the C version (more or less), gcc can optimize the code to
ret true
:Meta
rustc --version --verbose
:@rustbot label A-LLVM I-slow T-compiler
The text was updated successfully, but these errors were encountered: