[polly] r276094 - Update isl to isl-0.17.1-171-g233f589

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 20 00:52:43 PDT 2016


Author: grosser
Date: Wed Jul 20 02:52:42 2016
New Revision: 276094

URL: http://llvm.org/viewvc/llvm-project?rev=276094&view=rev
Log:
Update isl to isl-0.17.1-171-g233f589

This fixes an issue with equality detection that resulted in an assertion
being triggered during coalescing.

Modified:
    polly/trunk/lib/External/isl/GIT_HEAD_ID
    polly/trunk/lib/External/isl/doc/manual.pdf
    polly/trunk/lib/External/isl/isl_coalesce.c
    polly/trunk/lib/External/isl/isl_tab.c
    polly/trunk/lib/External/isl/isl_test.c

Modified: polly/trunk/lib/External/isl/GIT_HEAD_ID
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/GIT_HEAD_ID?rev=276094&r1=276093&r2=276094&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/GIT_HEAD_ID (original)
+++ polly/trunk/lib/External/isl/GIT_HEAD_ID Wed Jul 20 02:52:42 2016
@@ -1 +1 @@
-isl-0.17.1-164-gcbba1b6
+isl-0.17.1-171-g233f589

Modified: polly/trunk/lib/External/isl/doc/manual.pdf
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/doc/manual.pdf?rev=276094&r1=276093&r2=276094&view=diff
==============================================================================
Binary files polly/trunk/lib/External/isl/doc/manual.pdf (original) and polly/trunk/lib/External/isl/doc/manual.pdf Wed Jul 20 02:52:42 2016 differ

Modified: polly/trunk/lib/External/isl/isl_coalesce.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_coalesce.c?rev=276094&r1=276093&r2=276094&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_coalesce.c (original)
+++ polly/trunk/lib/External/isl/isl_coalesce.c Wed Jul 20 02:52:42 2016
@@ -2180,7 +2180,13 @@ static int same_divs(__isl_keep isl_basi
 /* Expand info->tab in the same way info->bmap was expanded in
  * isl_basic_map_expand_divs using the expansion "exp" and
  * update info->ineq with respect to the redundant constraints
- * in the resulting tableau.
+ * in the resulting tableau. "bmap" is the original version
+ * of info->bmap, i.e., the one that corresponds to the current
+ * state of info->tab.  The number of constraints in "bmap"
+ * is assumed to be the same as the number of constraints
+ * in info->tab.  This is required to be able to detect
+ * the extra constraints in info->bmap.
+ *
  * In particular, introduce extra variables corresponding
  * to the extra integer divisions and add the div constraints
  * that were added to info->bmap after info->tab was created
@@ -2189,13 +2195,21 @@ static int same_divs(__isl_keep isl_basi
  * does not take into account the redundant constraints
  * in the tableau.  Mark them here.
  */
-static isl_stat expand_tab(struct isl_coalesce_info *info, int *exp)
+static isl_stat expand_tab(struct isl_coalesce_info *info, int *exp,
+	__isl_keep isl_basic_map *bmap)
 {
 	unsigned total, pos, n_div;
 	int extra_var;
 	int i, n, j, n_ineq;
 	unsigned n_eq;
 
+	if (!bmap)
+		return isl_stat_error;
+	if (bmap->n_eq + bmap->n_ineq != info->tab->n_con)
+		isl_die(isl_basic_map_get_ctx(bmap), isl_error_internal,
+			"original tableau does not correspond "
+			"to original basic map", return isl_stat_error);
+
 	total = isl_basic_map_dim(info->bmap, isl_dim_all);
 	n_div = isl_basic_map_dim(info->bmap, isl_dim_div);
 	pos = total - n_div;
@@ -2280,7 +2294,7 @@ static enum isl_change coalesce_expand_t
 	bmap_i = info[i].bmap;
 	info[i].bmap = isl_basic_map_copy(bmap);
 	snap = isl_tab_snap(info[i].tab);
-	if (!info[i].bmap || expand_tab(&info[i], exp) < 0)
+	if (!info[i].bmap || expand_tab(&info[i], exp, bmap_i) < 0)
 		change = isl_change_error;
 
 	init_status(&info[j]);

Modified: polly/trunk/lib/External/isl/isl_tab.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_tab.c?rev=276094&r1=276093&r2=276094&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_tab.c (original)
+++ polly/trunk/lib/External/isl/isl_tab.c Wed Jul 20 02:52:42 2016
@@ -1603,36 +1603,52 @@ static int tab_is_manifestly_empty(struc
  * Each of the non-negative variables with a negative coefficient can
  * then also be written as the negative sum of non-negative variables
  * and must therefore also be zero.
- */
-static int close_row(struct isl_tab *tab, struct isl_tab_var *var) WARN_UNUSED;
-static int close_row(struct isl_tab *tab, struct isl_tab_var *var)
+ *
+ * If "temp_var" is set, then "var" is a temporary variable that
+ * will be removed after this function returns and for which
+ * no information is recorded on the undo stack.
+ * Do not add any undo records involving this variable in this case
+ * since the variable will have been removed before any future undo
+ * operations.  Also avoid marking the variable as redundant,
+ * since that either adds an undo record or needlessly removes the row
+ * (the caller will take care of removing the row).
+ */
+static isl_stat close_row(struct isl_tab *tab, struct isl_tab_var *var,
+	int temp_var) WARN_UNUSED;
+static isl_stat close_row(struct isl_tab *tab, struct isl_tab_var *var,
+	int temp_var)
 {
 	int j;
 	struct isl_mat *mat = tab->mat;
 	unsigned off = 2 + tab->M;
 
-	isl_assert(tab->mat->ctx, var->is_nonneg, return -1);
+	if (!var->is_nonneg)
+		isl_die(isl_tab_get_ctx(tab), isl_error_internal,
+			"expecting non-negative variable",
+			return isl_stat_error);
 	var->is_zero = 1;
-	if (tab->need_undo)
+	if (!temp_var && tab->need_undo)
 		if (isl_tab_push_var(tab, isl_tab_undo_zero, var) < 0)
-			return -1;
+			return isl_stat_error;
 	for (j = tab->n_dead; j < tab->n_col; ++j) {
 		int recheck;
 		if (isl_int_is_zero(mat->row[var->index][off + j]))
 			continue;
-		isl_assert(tab->mat->ctx,
-		    isl_int_is_neg(mat->row[var->index][off + j]), return -1);
+		if (isl_int_is_pos(mat->row[var->index][off + j]))
+			isl_die(isl_tab_get_ctx(tab), isl_error_internal,
+				"row cannot have positive coefficients",
+				return isl_stat_error);
 		recheck = isl_tab_kill_col(tab, j);
 		if (recheck < 0)
-			return -1;
+			return isl_stat_error;
 		if (recheck)
 			--j;
 	}
-	if (isl_tab_mark_redundant(tab, var->index) < 0)
-		return -1;
+	if (!temp_var && isl_tab_mark_redundant(tab, var->index) < 0)
+		return isl_stat_error;
 	if (tab_is_manifestly_empty(tab) && isl_tab_mark_empty(tab) < 0)
-		return -1;
-	return 0;
+		return isl_stat_error;
+	return isl_stat_ok;
 }
 
 /* Add a constraint to the tableau and allocate a row for it.
@@ -2451,7 +2467,7 @@ int isl_tab_cone_is_bounded(struct isl_t
 				return -1;
 			if (sgn != 0)
 				return 0;
-			if (close_row(tab, var) < 0)
+			if (close_row(tab, var, 0) < 0)
 				return -1;
 			break;
 		}
@@ -2583,16 +2599,35 @@ struct isl_basic_set *isl_basic_set_upda
 		(struct isl_basic_map *)bset, tab);
 }
 
-/* Given a non-negative variable "var", add a new non-negative variable
- * that is the opposite of "var", ensuring that var can only attain the
- * value zero.
+/* Drop the last constraint added to "tab" in position "r".
+ * The constraint is expected to have remained in a row.
+ */
+static isl_stat drop_last_con_in_row(struct isl_tab *tab, int r)
+{
+	if (!tab->con[r].is_row)
+		isl_die(isl_tab_get_ctx(tab), isl_error_internal,
+			"row unexpectedly moved to column",
+			return isl_stat_error);
+	if (r + 1 != tab->n_con)
+		isl_die(isl_tab_get_ctx(tab), isl_error_internal,
+			"additional constraints added", return isl_stat_error);
+	if (drop_row(tab, tab->con[r].index) < 0)
+		return isl_stat_error;
+
+	return isl_stat_ok;
+}
+
+/* Given a non-negative variable "var", temporarily add a new non-negative
+ * variable that is the opposite of "var", ensuring that "var" can only attain
+ * the value zero.  The new variable is removed again before this function
+ * returns.  However, the effect of forcing "var" to be zero remains.
  * If var = n/d is a row variable, then the new variable = -n/d.
  * If var is a column variables, then the new variable = -var.
  * If the new variable cannot attain non-negative values, then
  * the resulting tableau is empty.
  * Otherwise, we know the value will be zero and we close the row.
  */
-static int cut_to_hyperplane(struct isl_tab *tab, struct isl_tab_var *var)
+static isl_stat cut_to_hyperplane(struct isl_tab *tab, struct isl_tab_var *var)
 {
 	unsigned r;
 	isl_int *row;
@@ -2600,12 +2635,14 @@ static int cut_to_hyperplane(struct isl_
 	unsigned off = 2 + tab->M;
 
 	if (var->is_zero)
-		return 0;
-	isl_assert(tab->mat->ctx, !var->is_redundant, return -1);
-	isl_assert(tab->mat->ctx, var->is_nonneg, return -1);
+		return isl_stat_ok;
+	if (var->is_redundant || !var->is_nonneg)
+		isl_die(isl_tab_get_ctx(tab), isl_error_invalid,
+			"expecting non-redundant non-negative variable",
+			return isl_stat_error);
 
 	if (isl_tab_extend_cons(tab, 1) < 0)
-		return -1;
+		return isl_stat_error;
 
 	r = tab->n_con;
 	tab->con[r].index = tab->n_row;
@@ -2630,25 +2667,25 @@ static int cut_to_hyperplane(struct isl_
 
 	tab->n_row++;
 	tab->n_con++;
-	if (isl_tab_push_var(tab, isl_tab_undo_allocate, &tab->con[r]) < 0)
-		return -1;
 
 	sgn = sign_of_max(tab, &tab->con[r]);
 	if (sgn < -1)
-		return -1;
+		return isl_stat_error;
 	if (sgn < 0) {
+		if (drop_last_con_in_row(tab, r) < 0)
+			return isl_stat_error;
 		if (isl_tab_mark_empty(tab) < 0)
-			return -1;
-		return 0;
+			return isl_stat_error;
+		return isl_stat_ok;
 	}
 	tab->con[r].is_nonneg = 1;
-	if (isl_tab_push_var(tab, isl_tab_undo_nonneg, &tab->con[r]) < 0)
-		return -1;
 	/* sgn == 0 */
-	if (close_row(tab, &tab->con[r]) < 0)
-		return -1;
+	if (close_row(tab, &tab->con[r], 1) < 0)
+		return isl_stat_error;
+	if (drop_last_con_in_row(tab, r) < 0)
+		return isl_stat_error;
 
-	return 0;
+	return isl_stat_ok;
 }
 
 /* Given a tableau "tab" and an inequality constraint "con" of the tableau,
@@ -2876,7 +2913,7 @@ int isl_tab_detect_implicit_equalities(s
 		if (sgn < 0)
 			return -1;
 		if (sgn == 0) {
-			if (close_row(tab, var) < 0)
+			if (close_row(tab, var, 0) < 0)
 				return -1;
 		} else if (!tab->rational && !at_least_one(tab, var)) {
 			if (cut_to_hyperplane(tab, var) < 0)

Modified: polly/trunk/lib/External/isl/isl_test.c
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/External/isl/isl_test.c?rev=276094&r1=276093&r2=276094&view=diff
==============================================================================
--- polly/trunk/lib/External/isl/isl_test.c (original)
+++ polly/trunk/lib/External/isl/isl_test.c Wed Jul 20 02:52:42 2016
@@ -1905,6 +1905,32 @@ static int test_coalesce_special(struct
 	return 0;
 }
 
+/* A specialized coalescing test case that would result in an assertion
+ * in an earlier version of isl.
+ * The explicit call to isl_basic_set_union prevents the implicit
+ * equality constraints in the first basic map from being detected prior
+ * to the call to isl_set_coalesce, at least at the point
+ * where this test case was introduced.
+ */
+static int test_coalesce_special2(struct isl_ctx *ctx)
+{
+	const char *str;
+	isl_basic_set *bset1, *bset2;
+	isl_set *set;
+
+	str = "{ [x, y] : x, y >= 0 and x + 2y <= 1 and 2x + y <= 1 }";
+	bset1 = isl_basic_set_read_from_str(ctx, str);
+	str = "{ [x,0] : -1 <= x <= 1 and x mod 2 = 1 }" ;
+	bset2 = isl_basic_set_read_from_str(ctx, str);
+	set = isl_basic_set_union(bset1, bset2);
+	set = isl_set_coalesce(set);
+	isl_set_free(set);
+
+	if (!set)
+		return -1;
+	return 0;
+}
+
 /* Test the functionality of isl_set_coalesce.
  * That is, check that the output is always equal to the input
  * and in some cases that the result consists of a single disjunct.
@@ -1924,6 +1950,8 @@ static int test_coalesce(struct isl_ctx
 		return -1;
 	if (test_coalesce_special(ctx) < 0)
 		return -1;
+	if (test_coalesce_special2(ctx) < 0)
+		return -1;
 
 	return 0;
 }




More information about the llvm-commits mailing list