Displaying 2 results from an estimated 2 matches for "may_exit".
Did you mean:
ma_exit
2016 Jun 29
3
Regarding ScalarEvolution's loop backedge computation
Hi,
It looks like ScalarEvolution bails out of loop backedge computation if it cannot prove the IV stride as either positive or negative (based on loop control condition). I think this logic can be refined for signed IVs.
Consider this simple loop-
void foo(int *A, int n, int s) {
int i;
for(i=0; i<n; i += s) {
A[i]++;
}
}
The IV of this loop has this SCEV form-
2016 Jun 30
1
Regarding ScalarEvolution's loop backedge computation
...do things like this for
for (i = A; i != B; i += 5)
...
and compute the backedge taken count as "(B - A) / 5" (roughly :) )
since if (B - A) is not divisible by 5 then we have UB due to
overflow. We just have to be careful around cases like:
for(i = 0; i < 60; i += s) {
may_exit();
}
"s" can be (say) -3 and the loop can take 160 backedges and then
"exit(0)", avoiding the undefined behavior due to underflow. "s" can
also be zero, in which case the loop can potentially take an infinite
number of backedges.
However, in the example you gave...