isl_basic_map_simplify: reduce coefficients of integer divisions
commit5334f05998c761d7ffbf9a2bc50f99c80698886d
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 23 Jun 2016 15:31:31 +0000 (23 17:31 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 19 Dec 2016 09:05:20 +0000 (19 10:05 +0100)
treecb4e80b86fac02db1a342e82d030a082a42d7a92
parentf356dba29aa12e03295a3d98c8647efe3d67ba1d
isl_basic_map_simplify: reduce coefficients of integer divisions

Commit 3fbc27f (isl_aff_floor: reduce coefficients of newly created div,
Sun Jul 31 12:57:01 2011 +0200) introduced a reduction on the coefficients
of integer divisions created through isl_aff_floor.
Since this function is used during the parsing of set descriptions,
this means that an input of the form

{ [a, b] : 0 <= a <= 1 and ((b >= 0 and 2*floor((a + b)/2) >= -5 + a + 2b) or
(2*floor((-a + b)/2) >= -5 + a + 2b and 2*floor((-a + b)/2) < -a + 2b)) }

is transformed to

{ [a, b] : 0 <= a <= 1 and ((b >= 0 and 2*floor((a + b)/2) >= -5 + a + 2b) or
(2*floor((a + b)/2) >= -5 + 3a + 2b and 2*floor((a + b)/2) < a + 2b)) }

resulting in identical integer divisions in the two disjuncts.

However, if the input is specified as

{ [a, b] : exists (e0: 0 <= a <= 1 and b >= 0 and
2e0 >= -5 + a + 2b and 2e0 >= -1 + a + b and 2e0 <= a + b);
  [a, b] : exists (e0: 0 <= a <= 1 and 2e0 >= -5 + a + 2b and
2e0 >= -1 - a + b and 2e0 <= -a + b and 2e0 < -a + 2b) }

then the integer divisions are detected internally resulting in

{ [a, b] : 0 <= a <= 1 and ((b >= 0 and 2*floor((a + b)/2) >= -5 + a + 2b) or
(2*floor((-a + b)/2) >= -5 + a + 2b and 2*floor((-a + b)/2) < -a + 2b)) }

i.e., with different integer divisions in the two disjuncts.

Apply the same reduction applied by isl_aff_floor in isl_basic_map_simplify.
Do this by extending the removal of integer coefficients introduced in
commit c9fb3b7 (isl_basic_map_simplify: remove integer coefficients from
integer divisions, Wed Apr 29 16:35:19 2015 +0200).  As in that commit,
it would be nice if the reduction could be applied only during
the introduction of the integer division, but there are several
places where an integer division may be introduced or modified.

This change has an effect on the AST generation output because
the representation of the integer divisions involved is changed.
This effect is not always positive, but at least the results
should be more consistent and less dependent on internal changes.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
18 files changed:
isl_aff.c
isl_map_simplify.c
isl_test.c
test_inputs/codegen/cloog/faber.c
test_inputs/codegen/cloog/jacobi-shared.c
test_inputs/codegen/cloog/levenshtein-1-2-3.c
test_inputs/codegen/cloog/reservoir-cholesky2.c
test_inputs/codegen/cloog/reservoir-pingali1.c
test_inputs/codegen/cloog/walters.c
test_inputs/codegen/isolate5.c
test_inputs/codegen/omega/guard1-0.c
test_inputs/codegen/omega/guard1-1.c
test_inputs/codegen/omega/m7-1.c
test_inputs/codegen/omega/m8-1.c
test_inputs/codegen/omega/p.delft2-0.c
test_inputs/codegen/redundant.c
test_inputs/codegen/sor1d-part.c
test_inputs/codegen/stride5.c