isl_map_coalesce: take into account equality constraints while harmonizing divs
commitcd7d76013ff9b91d67c39b7e1bedbe15e91b6f9b
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 24 Jun 2016 08:33:29 +0000 (24 10:33 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 19 Dec 2016 09:05:20 +0000 (19 10:05 +0100)
tree884b3386ffbc074e923a2504697b585cab007e26
parent2ddacba48309a2f5c8a34caa1ba2c3a38669b532
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>
isl_coalesce.c
isl_test.c