Array bounds check not elided when indexing with ZST enum #82871
Labels
C-bug
Category: This is a bug.
E-easy
Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
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.
I tried this code:
I expected to see this happen: no bounds check
Instead, this happened (with
-C opt-level=3
)However adding more variants to the enum makes the bound check go away:
generates:
Here's a godbolt link to play around further: https://rust.godbolt.org/z/dK9e1z
The MIR of the two cases is identical, but the llvm IR in ZST case is lacking
@llvm.assume
, which I assume (heh!) leads to the bounds check being preserved. (However i don't actually understand LLVM, I'm just reading the diff...)Meta
rustc 1.50.0
This sounds very closely related to #13926, but I'm not actually sure if it is. Please reroute as appropriate.
The text was updated successfully, but these errors were encountered: