[PATCH] D49602: Use SCEV to avoid inserting some bounds checks.
Evgenii Stepanov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 20 10:55:09 PDT 2018
eugenis added a comment.
In https://reviews.llvm.org/D49602#1170033, @jgalenson wrote:
> In https://reviews.llvm.org/D49602#1169952, @eugenis wrote:
>
> > Do the tests cover cases where only one or two of the checks can be omitted, but not all of them? Does not look that way.
>
>
> I'm not quite sure what you mean. The test cases are essentially:
>
> int foo[1000];
> for (int i = 0; i < {1000,2000,n}; i++)
>
> foo[i];
>
>
> and
>
> foo[2][2];
> for (int i = 0; i < {2,3,n}; i++)
>
> for (int j = 0; j < {2,3,n}; j++)
> foo[i][j[]
>
>
> So they do cover the same where you iterate over the whole array and beyond it. I also just added a testcase that counts down to 0 or below 0.
Consider a loop where offset is always inbounds, but offset + access size may be not. Bounds checks is still needed, but it should be cheaper, because Size <= Offset will be constant false.
https://reviews.llvm.org/D49602
More information about the llvm-commits
mailing list