[PATCH] D22377: [SCEV] trip count calculation for loops with unknown stride
Pankaj Chawla via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 26 14:52:06 PDT 2016
pankajchawla added inline comments.
================
Comment at: llvm/lib/Analysis/ScalarEvolution.cpp:8751
@@ +8750,3 @@
+ // do-while loop. Stride cannot be assumed to be positive for such loops so
+ // we bail out.
+ if (!PositiveStride)
----------------
sanjoy wrote:
> Here and in the comment in the test case, we're not assuming the stride is positive, but that the trip count math is correct even if stride is negative given that the conditions we checked above are correct; so I think the comment and the variable name needs to change.
>
>
I think this check is unnecessary as the computed backedge taken count is correct for single trip do-while loops as well.
For a do-while loop like this-
int i = init;
do {
A[i] = i;
i += s;
} while (i<n);
The computed backedge taken count is: ((-1 + (-1 * %init) + ((%init + %s) smax %n)) /u %s)
This seems correct because if %n is less than (%init + %s), it reduces to ((-1 + %s) /u %s) ==> 0.
I will remove this check.
https://reviews.llvm.org/D22377
More information about the llvm-commits
mailing list