isl_map_coalesce: do not leave input basic maps in inconsistent state
commit2c183b79d8de1fa4e648ecfd7e1eea9076825429
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Mon, 1 Oct 2018 09:18:02 +0000 (1 11:18 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Tue, 2 Oct 2018 19:43:24 +0000 (2 21:43 +0200)
tree7d64d7bc412842c4d773f4d2b6e5f2016a0b8116
parent9c4481099d5b9e5fddc6aaf21ee517d5e0c357b8
isl_map_coalesce: do not leave input basic maps in inconsistent state

Commit isl-0.11.1-19-g9ce5772769 (isl_map_coalesce: avoid dropping
constraints redundant wrt implicit equalities,
Sat Mar 16 14:40:56 2013 +0100) introduced code to ensure
that equality constraints discovered in the tableau are
explicitly available in the basic map, without performing
Gaussian elimination on those equality constraints during
the isl_map_coalesce call, postponing this step to right before
the result is returned.  However, it would only end up performing
this elimination on the basic maps that remain in the result and
not on those that may be shared with other maps and
that either get dropped or get further modified during coalescing.

Commits isl-0.20-8-g7726e51e2f (isl_map_coalesce: do not leave input
basic maps in inconsistent state, Fri Aug 10 22:07:06 2018 +0200) and
isl-0.20-19-g8dced6146e (isl_map_coalesce: do not leave input
basic maps in inconsistent state, Thu Sep 13 20:03:38 2018 +0200)
attempt to fix this issue, but they only considered the case
where a shared basic map gets dropped during coalescing,
not where it gets further modified.
The solution that worked for the dropped basic maps
does not work in this case because isl_basic_map_gauss
cannot be called on the basic map that gets modified
because that may conflict with the modifications.

There are several possible solutions:
- stop detecting equality constraints
- recreate the tableau after equality constraints get detected
- call isl_basic_map_gauss as soon as the equality constraints get
  detected, but keep the tableau in sync

The first will break some test cases, while the second
results in redundant computations.
The third is a bit more fragile, but arguably less so
than the attempts at keeping tableau and basic map in sync
that are already performed by isl_tab_make_equalities_explicit.
This commit therefore implements the third option.

Note that there is a further complication in that
isl_map_coalesce may also have called isl_basic_map_reduce_coefficients,
which may also leave the basic map in an inconsistent state,
but isl_map_coalesce depends on this state.
However, isl_basic_map_reduce_coefficients makes sure to only
perform its modifications on a private copy, in which
case the problem of leaving a shared basic map in an inconsistent state
does not arise.  isl_basic_map_gauss therefore does not get called
when the basic map only has a single reference.

Since this commit solves the problem at the point where it gets
introduced, there is no longer any need to try and recover from it later.
The previous (partial) fixes are therefore removed.

Reported-by: Andrei Lascu <alas.20073@gmail.com>
Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_coalesce.c
isl_map_private.h
isl_map_simplify.c
isl_tab.c
isl_test.c