AST generator: drop redundant lower bounds on strided loops
commit314ac67d3c65fd5ab05b65f8b70304e4913f5fe9
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 17 Sep 2014 09:36:53 +0000 (17 11:36 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 22 Sep 2014 12:09:37 +0000 (22 14:09 +0200)
tree683f17f594b34772a8ccf961dc96f97d602cabbc
parent14be194ea5c72c18538d2b769a829e475b7a9bd9
AST generator: drop redundant lower bounds on strided loops

The basic set from which the lower bounds of a for loop are constructed
should not have any redundant constraints in itself.  However, this set
does not take into account any possible stride on the loop.
During the construction of the set of lower bounds, this information
is taken into account, which may result in lower bounds that are
redundant with respect to the other lower bounds.

For example, for the shift2 test case we have the following effect:

   for (int c1 = 32; c1 < length - 1; c1 += 32)
     for (int c2 = c1; c2 < length; c2 += 32)
-      for (int c3 = max(c1, c2); c3 <= min(length - 1, c2 + 31); c3 += 16)
+      for (int c3 = c2; c3 <= min(length - 1, c2 + 31); c3 += 16)

The original lower bounds on c3 are c3 >= c1 - 14 and c3 >= c2 - 15.
The c3 >= c1 - 14 bound is not redundant, since c1 - 14 may be greater
than c2 - 15.  However, after taking into account that the lower bound
needs to be a multiple of 16, we obtain bounds c3 >= c1 and c3 >= c2.
Since c1 is smaller than or equal to c2, the first bound can be removed.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_codegen.c
test_inputs/codegen/hoist2.c
test_inputs/codegen/shift2.c