* Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
*/
+#include <isl_ctx_private.h>
+#include <isl_map_private.h>
#include "isl_equalities.h"
-#include "isl_map.h"
-#include "isl_map_private.h"
-#include "isl_seq.h"
+#include <isl/map.h>
+#include <isl/seq.h>
#include "isl_tab.h"
#include <isl_dim_private.h>
#include <isl_mat_private.h>
}
}
-static void set_swap_inequality(struct isl_basic_set *bset, int a, int b)
-{
- swap_inequality((struct isl_basic_map *)bset, a, b);
-}
-
static void constraint_drop_vars(isl_int *c, unsigned n, unsigned rem)
{
isl_seq_cpy(c, c + n, rem);
if (progress)
*progress = 1;
isl_seq_elim(bmap->eq[k], eq, 1+pos, 1+total, NULL);
+ isl_seq_normalize(bmap->ctx, bmap->eq[k], 1 + total);
}
for (k = 0; k < bmap->n_ineq; ++k) {
if (progress)
*progress = 1;
isl_seq_elim(bmap->ineq[k], eq, 1+pos, 1+total, NULL);
+ isl_seq_normalize(bmap->ctx, bmap->ineq[k], 1 + total);
ISL_F_CLR(bmap, ISL_BASIC_MAP_NORMALIZED);
}
return bmap;
if (div_eq < bmap->n_eq) {
- B = isl_mat_sub_alloc(bmap->ctx, bmap->eq, div_eq,
+ B = isl_mat_sub_alloc6(bmap->ctx, bmap->eq, div_eq,
bmap->n_eq - div_eq, 0, 1 + total);
C = isl_mat_variable_compression(B, &C2);
if (!C || !C2)
--j;
isl_int_set(d->block.data[i], bmap->eq[i][1 + total + j]);
}
- B = isl_mat_sub_alloc(bmap->ctx, bmap->eq, 0, div_eq, 0, 1 + total);
+ B = isl_mat_sub_alloc6(bmap->ctx, bmap->eq, 0, div_eq, 0, 1 + total);
if (C) {
B = isl_mat_product(B, C);
}
static struct isl_basic_map *remove_duplicate_constraints(
- struct isl_basic_map *bmap, int *progress)
+ struct isl_basic_map *bmap, int *progress, int detect_divs)
{
unsigned int size;
isl_int ***index;
l = index[h] - &bmap->ineq[0];
isl_int_add(sum, bmap->ineq[k][0], bmap->ineq[l][0]);
if (isl_int_is_pos(sum)) {
- bmap = check_for_div_constraints(bmap, k, l, sum,
- progress);
+ if (detect_divs)
+ bmap = check_for_div_constraints(bmap, k, l,
+ sum, progress);
continue;
}
if (isl_int_is_zero(sum)) {
bmap = isl_basic_map_gauss(bmap, &progress);
/* requires equalities in normal form */
bmap = normalize_divs(bmap, &progress);
- bmap = remove_duplicate_constraints(bmap, &progress);
+ bmap = remove_duplicate_constraints(bmap, &progress, 1);
}
return bmap;
}
}
if (n_lower > 0 && n_upper > 0) {
bmap = isl_basic_map_normalize_constraints(bmap);
- bmap = remove_duplicate_constraints(bmap, NULL);
+ bmap = remove_duplicate_constraints(bmap, NULL, 0);
bmap = isl_basic_map_gauss(bmap, NULL);
bmap = isl_basic_map_remove_redundancies(bmap);
if (!bmap)
return NULL;
total = isl_basic_set_total_dim(bset);
- B = isl_mat_sub_alloc(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + total);
+ B = isl_mat_sub_alloc6(bset->ctx, bset->eq, 0, bset->n_eq, 0, 1 + total);
C = isl_mat_variable_compression(B, NULL);
if (!C)
return bset;
isl_mat_free(C);
return isl_basic_set_set_to_empty(bset);
}
- B = isl_mat_sub_alloc(bset->ctx, bset->ineq,
+ B = isl_mat_sub_alloc6(bset->ctx, bset->ineq,
0, bset->n_ineq, 0, 1 + total);
C = isl_mat_product(B, C);
if (!C)
* We first compute the integer affine hull of the intersection,
* compute the gist inside this affine hull and then add back
* those equalities that are not implied by the context.
+ *
+ * If two constraints are mutually redundant, then uset_gist_full
+ * will remove the second of those constraints. We therefore first
+ * sort the constraints so that constraints not involving existentially
+ * quantified variables are given precedence over those that do.
+ * We have to perform this sorting before the variable compression,
+ * because that may effect the order of the variables.
*/
static __isl_give isl_basic_set *uset_gist(__isl_take isl_basic_set *bset,
__isl_take isl_basic_set *context)
goto error;
bset = isl_basic_set_intersect(bset, isl_basic_set_copy(context));
- if (isl_basic_set_fast_is_empty(bset)) {
+ if (isl_basic_set_plain_is_empty(bset)) {
isl_basic_set_free(context);
return bset;
}
+ bset = isl_basic_set_sort_constraints(bset);
aff = isl_basic_set_affine_hull(isl_basic_set_copy(bset));
if (!aff)
goto error;
- if (isl_basic_set_fast_is_empty(aff)) {
+ if (isl_basic_set_plain_is_empty(aff)) {
isl_basic_set_free(aff);
isl_basic_set_free(context);
return bset;
return uset_gist_full(bset, context);
}
total = isl_basic_set_total_dim(bset);
- eq = isl_mat_sub_alloc(bset->ctx, aff->eq, 0, aff->n_eq, 0, 1 + total);
+ eq = isl_mat_sub_alloc6(bset->ctx, aff->eq, 0, aff->n_eq, 0, 1 + total);
eq = isl_mat_cow(eq);
T = isl_mat_variable_compression(eq, &T2);
if (T && T->n_col == 0) {
isl_basic_map_free(context);
return bmap;
}
- if (isl_basic_map_fast_is_empty(context)) {
+ if (isl_basic_map_plain_is_empty(context)) {
struct isl_dim *dim = isl_dim_copy(bmap->dim);
isl_basic_map_free(context);
isl_basic_map_free(bmap);
return isl_basic_map_universe(dim);
}
- if (isl_basic_map_fast_is_empty(bmap)) {
+ if (isl_basic_map_plain_is_empty(bmap)) {
isl_basic_map_free(context);
return bmap;
}
if (!map || !context)
goto error;;
- if (isl_basic_map_fast_is_empty(context)) {
+ if (isl_basic_map_plain_is_empty(context)) {
struct isl_dim *dim = isl_dim_copy(map->dim);
isl_basic_map_free(context);
isl_map_free(map);
map = isl_map_compute_divs(map);
for (i = 0; i < map->n; ++i)
context = isl_basic_map_align_divs(context, map->p[i]);
- for (i = 0; i < map->n; ++i) {
+ for (i = map->n - 1; i >= 0; --i) {
map->p[i] = isl_basic_map_gist(map->p[i],
isl_basic_map_copy(context));
if (!map->p[i])
goto error;
+ if (isl_basic_map_plain_is_empty(map->p[i])) {
+ isl_basic_map_free(map->p[i]);
+ if (i != map->n - 1)
+ map->p[i] = map->p[map->n - 1];
+ map->n--;
+ }
}
isl_basic_map_free(context);
ISL_F_CLR(map, ISL_MAP_NORMALIZED);
__isl_give isl_map *isl_map_gist(__isl_take isl_map *map,
__isl_take isl_map *context)
{
+ context = isl_map_compute_divs(context);
return isl_map_gist_basic_map(map, isl_map_simple_hull(context));
}
* one basic map in the context of the equalities of the other
* basic map and check if we get a contradiction.
*/
-int isl_basic_map_fast_is_disjoint(struct isl_basic_map *bmap1,
- struct isl_basic_map *bmap2)
+int isl_basic_map_plain_is_disjoint(__isl_keep isl_basic_map *bmap1,
+ __isl_keep isl_basic_map *bmap2)
{
struct isl_vec *v = NULL;
int *elim = NULL;
return -1;
}
-int isl_basic_set_fast_is_disjoint(struct isl_basic_set *bset1,
- struct isl_basic_set *bset2)
+int isl_basic_set_plain_is_disjoint(__isl_keep isl_basic_set *bset1,
+ __isl_keep isl_basic_set *bset2)
{
- return isl_basic_map_fast_is_disjoint((struct isl_basic_map *)bset1,
+ return isl_basic_map_plain_is_disjoint((struct isl_basic_map *)bset1,
(struct isl_basic_map *)bset2);
}
-int isl_map_fast_is_disjoint(struct isl_map *map1, struct isl_map *map2)
+int isl_map_plain_is_disjoint(__isl_keep isl_map *map1,
+ __isl_keep isl_map *map2)
{
int i, j;
if (!map1 || !map2)
return -1;
- if (isl_map_fast_is_equal(map1, map2))
+ if (isl_map_plain_is_equal(map1, map2))
return 0;
for (i = 0; i < map1->n; ++i) {
for (j = 0; j < map2->n; ++j) {
- int d = isl_basic_map_fast_is_disjoint(map1->p[i],
+ int d = isl_basic_map_plain_is_disjoint(map1->p[i],
map2->p[j]);
if (d != 1)
return d;
return 1;
}
-int isl_set_fast_is_disjoint(struct isl_set *set1, struct isl_set *set2)
+int isl_set_plain_is_disjoint(__isl_keep isl_set *set1,
+ __isl_keep isl_set *set2)
{
- return isl_map_fast_is_disjoint((struct isl_map *)set1,
+ return isl_map_plain_is_disjoint((struct isl_map *)set1,
(struct isl_map *)set2);
}
+int isl_set_fast_is_disjoint(__isl_keep isl_set *set1, __isl_keep isl_set *set2)
+{
+ return isl_set_plain_is_disjoint(set1, set2);
+}
+
/* Check if we can combine a given div with lower bound l and upper
* bound u with some other div and if so return that other div.
* Otherwise return -1.
if (remove < 0)
return bmap;
- bmap = isl_basic_map_remove(bmap, isl_dim_div, remove, 1);
+ bmap = isl_basic_map_remove_dims(bmap, isl_dim_div, remove, 1);
return isl_basic_map_drop_redundant_divs(bmap);
error:
free(pairs);