AST generation: remove redundant constraints before determining loop bounds
commit1314871a1ff07b5baf01f8171a54f8f7ebe68aff
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 3 Jul 2015 17:05:08 +0000 (3 19:05 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sat, 4 Jul 2015 13:14:25 +0000 (4 15:14 +0200)
tree470fa2d6db285c93d4534bc5d8e9fc5e938c155e
parent22bb29ca56d32b86ef3c5f571d74e12ed3036089
AST generation: remove redundant constraints before determining loop bounds

The constraints that determine the part of the schedule space for
which a (possibly degenerate) loop is generated are first checked
to see if they assign a single value in isl_ast_build_set_loop_bounds.
This function also keeps track of the subset of constraints that do
not involve the loop iterator in the "pending" constraints such that
they can be added in the guard on the loop after it has been generated.
The other constraints are stored in the "generated" constraints.
During the actual construction of the for loop, i.e., its initial
value and its condition, the constraints not involving the loop iterator
are ignored because they are handled by the pending constraints.

However, the pending constraints are simplified with respect to
the generated constraints (including the current constraints
involving the loop iterator), while the redundant constraints
in the complete set of constraints are also eliminated as
a side effect of a gist operation.
This means in particular that if there are two mutually
redundant constraints, one involving the loop iterator and
one not involving the loop iterator, that then _both_ constraints
may end up getting eliminated.

For example, for the newly added test case, the set of constraints
at some loop level is

    [b0] -> { [[] -> [i0, i1, i2, i3]] : b0 <= 2 and i2 <= 2 and
i2 >= 1 and i2 >= -1 + 2i1 and i2 >= 1 - 2i1 and
i2 >= 8 - 8b0 and i1 >= 1 - 4i0 and i0 <= 2 and
b0 >= 1 and i1 <= 1 }

The constraint "b0 >= 1" gets eliminated with respect to
the generated constraints (which includes "i2 >= 8 - 8b0"),
while the "i2 >= 8 - 8b0" constraint gets eliminated from the above set
when redundant constraints are removed.

Perform the removal of redundant constraints before the constraints
are split up into pending and generated constraints to avoid
this situation.

Reported-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_codegen.c
test_inputs/codegen/omega/lefur04-0.c
test_inputs/codegen/redundant.c [new file with mode: 0644]
test_inputs/codegen/redundant.st [new file with mode: 0644]