isl_map_coalesce: harmonize integer divisions that differ by a constant
commit8eb322ed4ee82cb9bdb8a18f9f689254c65c620d
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 13 Oct 2014 20:54:29 +0000 (13 22:54 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 16 Jan 2015 10:49:08 +0000 (16 11:49 +0100)
tree9c6b7837823ab00f6e6f1dd9abfbf30835129540
parent000474176ed7ceb78d386dd154f7d4db6b83b0d8
isl_map_coalesce: harmonize integer divisions that differ by a constant

If an integer division in one basic map is equal to an integer division
in another basic map plus a constant, then it will not satisfy the
conditions of that other integer division and coalescing is going to fail.
By pulling out this constant difference, however, we may in some cases
be able to coalesce the two basic maps.

For example, in the case of the cholesky2 AST generation example,
at some stage during the generation, we have two basic maps

    [M] -> { [i0, i1, i2, i3] : exists (e0 = floor((2 + i0)/3):
i1 = 1 and 3e0 = 2 + i0 and e0 >= 1 and e0 <= -2 + M) }

and

    [M] -> { [i0, i1, i2, i3] : exists (e0 = floor((-1 + i0)/3):
i1 = 1 and 3e0 = -1 + i0 and e0 >= 0 and e0 <= -2 + M) }

which can not be directly coalesced.
Replacing e0 in the first basic map by e0' = e0 - 1, we find

    [M] -> { [i0, i1, i2, i3] : exists (e0 = floor((-1 + i0)/3):
i1 = 1 and 3e0 = -1 + i0 and e0 >= 0 and e0 <= -3 + M) }

which can be coalesced with the second basic map.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_coalesce.c
test_inputs/codegen/cloog/cholesky2.c