summaryrefslogtreecommitdiffstats
path: root/polly/lib/External/isl/isl_morph.c
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-03-25 19:38:18 +0000
committerTobias Grosser <tobias@grosser.es>2016-03-25 19:38:18 +0000
commit37034db826ab706ffd9c74c8d5d7474f2700679c (patch)
tree1b87bb5fde12ac4cdb0276d4e86d57f8cbbde112 /polly/lib/External/isl/isl_morph.c
parente988af9073dc59d6b158b0b90570b97415ba52a2 (diff)
downloadbcm5719-llvm-37034db826ab706ffd9c74c8d5d7474f2700679c.tar.gz
bcm5719-llvm-37034db826ab706ffd9c74c8d5d7474f2700679c.zip
Update to isl-0.16.1-145-g243bf7c
Just an import to keep track with the latest version of isl. We are not looking for specific features. llvm-svn: 264452
Diffstat (limited to 'polly/lib/External/isl/isl_morph.c')
-rw-r--r--polly/lib/External/isl/isl_morph.c128
1 files changed, 15 insertions, 113 deletions
diff --git a/polly/lib/External/isl/isl_morph.c b/polly/lib/External/isl/isl_morph.c
index 92215af667f..1917148c50a 100644
--- a/polly/lib/External/isl/isl_morph.c
+++ b/polly/lib/External/isl/isl_morph.c
@@ -352,32 +352,6 @@ __isl_give isl_morph *isl_morph_empty(__isl_keep isl_basic_set *bset)
id, isl_mat_copy(id));
}
-/* Given a matrix that maps a (possibly) parametric domain to
- * a parametric domain, add in rows that map the "nparam" parameters onto
- * themselves.
- */
-static __isl_give isl_mat *insert_parameter_rows(__isl_take isl_mat *mat,
- unsigned nparam)
-{
- int i;
-
- if (nparam == 0)
- return mat;
- if (!mat)
- return NULL;
-
- mat = isl_mat_insert_rows(mat, 1, nparam);
- if (!mat)
- return NULL;
-
- for (i = 0; i < nparam; ++i) {
- isl_seq_clr(mat->row[1 + i], mat->n_col);
- isl_int_set(mat->row[1 + i][1 + i], mat->row[0][0]);
- }
-
- return mat;
-}
-
/* Construct a basic set described by the "n" equalities of "bset" starting
* at "first".
*/
@@ -411,10 +385,6 @@ error:
* a morphishm that maps the basic set to a lower-dimensional space.
* Specifically, the morphism reduces the number of dimensions of type "type".
*
- * This function is a slight generalization of isl_mat_variable_compression
- * in that it allows the input to be parametric and that it allows for the
- * compression of either parameters or set variables.
- *
* We first select the equalities of interest, that is those that involve
* variables of type "type" and no later variables.
* Denote those equalities as
@@ -424,35 +394,14 @@ error:
* where C(p) depends on the parameters if type == isl_dim_set and
* is a constant if type == isl_dim_param.
*
- * First compute the (left) Hermite normal form of M,
+ * Use isl_mat_final_variable_compression to construct a compression
*
- * M [U1 U2] = M U = H = [H1 0]
- * or
- * M = H Q = [H1 0] [Q1]
- * [Q2]
- *
- * with U, Q unimodular, Q = U^{-1} (and H lower triangular).
- * Define the transformed variables as
- *
- * x = [U1 U2] [ x1' ] = [U1 U2] [Q1] x
- * [ x2' ] [Q2]
- *
- * The equalities then become
+ * x = T x'
*
- * -C(p) + H1 x1' = 0 or x1' = H1^{-1} C(p) = C'(p)
+ * x' = Q x
*
- * If the denominator of the constant term does not divide the
- * the common denominator of the parametric terms, then every
- * integer point is mapped to a non-integer point and then the original set has no
- * integer solutions (since the x' are a unimodular transformation
- * of the x). In this case, an empty morphism is returned.
- * Otherwise, the transformation is given by
- *
- * x = U1 H1^{-1} C(p) + U2 x2'
- *
- * The inverse transformation is simply
- *
- * x2' = Q2 x
+ * If T is a zero-column matrix, then the set of equality constraints
+ * do not admit a solution. In this case, an empty morphism is returned.
*
* Both matrices are extended to map the full original space to the full
* compressed space.
@@ -466,7 +415,7 @@ __isl_give isl_morph *isl_basic_set_variable_compression(
unsigned nrest;
int f_eq, n_eq;
isl_space *dim;
- isl_mat *H, *U, *Q, *C = NULL, *H1, *U1, *U2;
+ isl_mat *E, *Q, *C;
isl_basic_set *dom, *ran;
if (!bset)
@@ -491,58 +440,17 @@ __isl_give isl_morph *isl_basic_set_variable_compression(
if (n_eq == 0)
return isl_morph_identity(bset);
- H = isl_mat_sub_alloc6(bset->ctx, bset->eq, f_eq, n_eq, otype, ntype);
- H = isl_mat_left_hermite(H, 0, &U, &Q);
- if (!H || !U || !Q)
- goto error;
- Q = isl_mat_drop_rows(Q, 0, n_eq);
- Q = isl_mat_diagonal(isl_mat_identity(bset->ctx, otype), Q);
- Q = isl_mat_diagonal(Q, isl_mat_identity(bset->ctx, nrest));
- C = isl_mat_alloc(bset->ctx, 1 + n_eq, otype);
- if (!C)
- goto error;
- isl_int_set_si(C->row[0][0], 1);
- isl_seq_clr(C->row[0] + 1, otype - 1);
- isl_mat_sub_neg(C->ctx, C->row + 1, bset->eq + f_eq, n_eq, 0, 0, otype);
- H1 = isl_mat_sub_alloc(H, 0, H->n_row, 0, H->n_row);
- H1 = isl_mat_lin_to_aff(H1);
- C = isl_mat_inverse_product(H1, C);
- if (!C)
- goto error;
- isl_mat_free(H);
-
- if (!isl_int_is_one(C->row[0][0])) {
- int i;
- isl_int g;
-
- isl_int_init(g);
- for (i = 0; i < n_eq; ++i) {
- isl_seq_gcd(C->row[1 + i] + 1, otype - 1, &g);
- isl_int_gcd(g, g, C->row[0][0]);
- if (!isl_int_is_divisible_by(C->row[1 + i][0], g))
- break;
- }
- isl_int_clear(g);
-
- if (i < n_eq) {
- isl_mat_free(C);
- isl_mat_free(U);
- isl_mat_free(Q);
- return isl_morph_empty(bset);
- }
-
- C = isl_mat_normalize(C);
+ E = isl_mat_sub_alloc6(bset->ctx, bset->eq, f_eq, n_eq, 0, orest);
+ C = isl_mat_final_variable_compression(E, otype - 1, &Q);
+ if (!Q)
+ C = isl_mat_free(C);
+ if (C && C->n_col == 0) {
+ isl_mat_free(C);
+ isl_mat_free(Q);
+ return isl_morph_empty(bset);
}
- U1 = isl_mat_sub_alloc(U, 0, U->n_row, 0, n_eq);
- U1 = isl_mat_lin_to_aff(U1);
- U2 = isl_mat_sub_alloc(U, 0, U->n_row, n_eq, U->n_row - n_eq);
- U2 = isl_mat_lin_to_aff(U2);
- isl_mat_free(U);
-
- C = isl_mat_product(U1, C);
- C = isl_mat_aff_direct_sum(C, U2);
- C = insert_parameter_rows(C, otype - 1);
+ Q = isl_mat_diagonal(Q, isl_mat_identity(bset->ctx, nrest));
C = isl_mat_diagonal(C, isl_mat_identity(bset->ctx, nrest));
dim = isl_space_copy(bset->dim);
@@ -552,12 +460,6 @@ __isl_give isl_morph *isl_basic_set_variable_compression(
dom = copy_equalities(bset, f_eq, n_eq);
return isl_morph_alloc(dom, ran, Q, C);
-error:
- isl_mat_free(C);
- isl_mat_free(H);
- isl_mat_free(U);
- isl_mat_free(Q);
- return NULL;
}
/* Construct a parameter compression for "bset".
OpenPOWER on IntegriCloud