Closed
Description
https://godbolt.org/z/3TGbK9
It looks like bounds checks are not eliminated when more than one restriction is applied to the index variable (i.e. when it's range checked from two sides). Late edit: It's also interesting that the issue disappears for certain lower limits. For example if idx > 2 && idx < 8
is optimized, while if idx > 5 && idx < 8
is not.
Using assumptions, the bounds checks are removed as expected: https://godbolt.org/z/Ksn8dW
However, if any of the assumptions is a GE or LE instead of a GT or LT, the bounds checks are back: https://godbolt.org/z/YhK1rT
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: MIR optimizationsCategory: An issue proposing an enhancement or a PR with one.Issue: Problems and improvements with respect to performance of generated code.Relevant to the compiler team, which will review and decide on the PR/issue.