From f6b9b7e17151786bb1bc049e306abb178dbdad99 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Sat, 23 Oct 2010 16:06:30 +0200 Subject: [PATCH] cloog_domain_project: drop divs involving level Commit 256fcba (clast.c: insert extra modulo guards involving loop iterator inside loop, Wed Mar 11 09:33:53 2009 +0100) added code to detect modulo constraints on the loop iterator to avoid bounds on loop depending on floors of expressions involving the loop iterator itself. However, this code was broken by 4171187 (source/clast.c: clean up insert_for, Thu Jul 15 11:02:02 2010 +0200) as the constraints involved in the modulo guards would no longer be removed from the set of constraints used to construct the bounds of a loop. Moreover, the original code only handled some special cases. Here, we take a different approach and remove all integer divisions that depend on the loop iterator inside cloog_domain_project. Signed-off-by: Sven Verdoolaege --- isl | 2 +- source/clast.c | 15 +++------------ source/isl/domain.c | 3 +++ test/Makefile.am | 6 +++++- test/isl/mod.c | 6 ++++++ test/isl/mod.cloog | 23 +++++++++++++++++++++++ 6 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 test/isl/mod.c create mode 100644 test/isl/mod.cloog diff --git a/isl b/isl index 27b6c99..720f32e 160000 --- a/isl +++ b/isl @@ -1 +1 @@ -Subproject commit 27b6c995aaab20bf3b51b4adbba4a465a48c231c +Subproject commit 720f32e22fd9ff996c01cf2b68cd0eb7a12fb03e diff --git a/source/clast.c b/source/clast.c index bd20c1e..7bbf5f4 100644 --- a/source/clast.c +++ b/source/clast.c @@ -887,9 +887,9 @@ static struct clast_expr *clast_minmax(CloogConstraintSet *constraints, * Insert modulo guards defined by existentially quantified dimensions, * not involving the given level. * - * This function is called from within insert_guard or insert_for. - * Any constraint used in constructing * a modulo guard is removed - * from the constraint set to avoid insert_guard or insert_for + * This function is called from within insert_guard. + * Any constraint used in constructing a modulo guard is removed + * from the constraint set to avoid insert_guard * adding a duplicate (pair of) constraint(s). */ static void insert_extra_modulo_guards(CloogConstraintSet *constraints, @@ -1585,13 +1585,6 @@ static void insert_guarded_otl_for(CloogConstraintSet *constraints, int level, * -j +5*M >= 0 * j -4*M >= 0 * this function should return 'for (j=max(-i+9*M,4*M),j<=5*M;j++) {'. - * If the given element is involved in modulo guards defined by - * existentially quantified variables, then these guards should be - * inserted inside the for loop. However, the constraints involved - * in this guard should not be used in determining the lower and upper - * bound of the loop. We therefore insert the guards first (which - * removes the corresponding constraints from the constraint set) - * and then reattach the guard inside the loop. * - constraints contains all constraints, * - level is the column number of the element in matrix we want to use, * - otl is set if the loop is executed at most once, @@ -1632,8 +1625,6 @@ static int insert_for(CloogConstraintSet *constraints, int level, int otl, *next = &f->body; } - insert_extra_modulo_guards(constraints, 0, next, infos); - return 1; } diff --git a/source/isl/domain.c b/source/isl/domain.c index 81e78dc..1484b15 100644 --- a/source/isl/domain.c +++ b/source/isl/domain.c @@ -598,6 +598,9 @@ CloogDomain *cloog_domain_project(CloogDomain *domain, int level) set = isl_set_remove_dims(isl_set_copy(set), isl_dim_set, level, isl_set_n_dim(set) - level); set = isl_set_compute_divs(set); + if (level > 0) + set = isl_set_remove_divs_involving_dims(set, + isl_dim_set, level - 1, 1); return cloog_domain_from_isl_set(set); } diff --git a/test/Makefile.am b/test/Makefile.am index 4f8d471..a8da158 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -161,12 +161,16 @@ FINITE_CLOOGTEST_C = \ ./reservoir/tang-xue1 \ ./reservoir/two +CLOOG_ISL_TEST_C = \ + isl/mod + CLOOGTEST_C = \ infinite \ infinite2 \ infinite3 \ infinite4 \ - $(FINITE_CLOOGTEST_C) + $(FINITE_CLOOGTEST_C) \ + $(CLOOG_ISL_TEST_C) # ./reservoir/long \ # faber diff --git a/test/isl/mod.c b/test/isl/mod.c new file mode 100644 index 0000000..4f6a15e --- /dev/null +++ b/test/isl/mod.c @@ -0,0 +1,6 @@ +/* Generated from ../../../git/cloog/test/isl/mod.cloog by CLooG 0.14.0-325-g71fa959 gmp bits in 0.00s. */ +for (i=0;i<=3;i++) { + if (i%3 <= 1) { + S1(i); + } +} diff --git a/test/isl/mod.cloog b/test/isl/mod.cloog new file mode 100644 index 0000000..e12de40 --- /dev/null +++ b/test/isl/mod.cloog @@ -0,0 +1,23 @@ +c + +# Context: +0 2 + +0 # Parameter name(s) +# Statement number: +1 + +# Iteration domain of statement 1 +4 4 1 0 1 0 +1 1 0 0 +1 -1 0 3 +1 1 -3 0 +1 -1 3 1 + +0 0 0 # For future options. + + +0 # Iterator name(s) + +# No scattering functions. +0 -- 2.11.4.GIT