The following testcase
int A[100];
void foo(int n) {
for (int i = 0, j = 0; i < n; i+=2, j++)
A[j] += 1;
}
is not recognized as a valid scop: -debug-only=polly-detect prints:
Checking region: entry => <Function Return>
Top level region is invalid
Checking region: entry.split => for.end
Non affine loop bound '***COULDNOTCOMPUTE***' in loop: for.body
Checking region: for.body => for.cond.for.end_crit_edge
Non affine loop bound '***COULDNOTCOMPUTE***' in loop: for.body
And this corresponds to this code:
// Is the loop count affine?
const SCEV *LoopCount = SE->getBackedgeTakenCount(L);
if (!isAffineExpr(&Context.CurRegion, LoopCount, *SE))
INVALID(LoopBound,
"Non affine loop bound '"
<< *LoopCount << "' in loop: " << L->getHeader()->getName());
I think that unknown loop trip counts could be handled by adding a new
parameter.