[PATCH] D22377: [SCEV] trip count calculation for loops with unknown stride
Pankaj Chawla via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 14 13:17:29 PDT 2016
pankajchawla added a comment.
Hi
In https://reviews.llvm.org/D22377#484607, @eli.friedman wrote:
> You have to be a bit more careful here... consider:
>
> for (int i=0; i<16; i-=2) {
> if (i < -2000) break;
> }
>
>
> Here, the backedge is taken 1000 times. (There are actually two related cases here: one, the case where there's an explicit break, and the case where some call in the loop throws an exception.)
>
> It might be sufficient to show that the loop only has one exit and loopHasNoAbnormalExits() is true; not 100% sure about that.
Hi Eli,
The single exit condition is taken care of by checking the NoWrap flag as it is only set when ControlsExit is true, on line 8657.
We also need to check for loop entry guard because a single-trip do-while loop can have a negative stride. In this case, we will compute the wrong trip count. Consider this loop-
int i = 0;
do {
A[i] = i;
i += s;
} while (i<n);
This is a single trip loop if n = -10 and s = -1.
https://reviews.llvm.org/D22377
More information about the llvm-commits
mailing list