isl_map_coalesce: take into account equality constraints while harmonizing divs
Commit
8eb322e (isl_map_coalesce: harmonize integer divisions that differ by
a constant, Mon Oct 13 22:54:29 2014 +0200) introduced support for
harmonizing integer divisions that only differ by a constant.
However, if one of the basic maps satisfies some equality constraints,
then its integer divisions will have been simplified with respect
to these equality constraints. The integer divisions may then
not resemble those of the other basic map, even though shifting
could still be useful.
Take, for example, the test case
{ [a, b, c] : (b = -1 + a and 0 < a <= 3 and
9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or
(exists (e0 = floor((-16 + 2c)/9): a = 4 and
b = 3 and 9e0 <= -19 + 2c)) }
added in
a130b58 (isl_map_coalesce: allow general coalescing
with expanded divs, Fri May 27 13:12:48 2016 +0200). It was already
being handled because the two integer divisions can be treated
as the same variable. However, if the same example is specified as
{ [a, b, c] : (b = -1 + a and 0 < a <= 3 and
9*floor((-4a + 2c)/9) <= -3 - 4a + 2c) or
(a = 4 and b = 3 and 9*floor((-16 + 2c)/9) <= -19 + 2c) }
then floor((-16 + 2c)/9) gets simplified to floor((2 + 2c)/9) - 2
but treating floor((-4a + 2c)/9) and floor((2 + 2c)/9) as the same
variable does not result in a successful coalescing.
However, if the equality constraint a = 4 is plugged into the integer
division floor((-4a + 2c)/9) of the other basic map, then it simplifies
to floor((-16 + 2c)/9). The mechanism added in this commit then
identifies that one is a shift of the other.
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>