return NULL;
dup_constraints(dup, bmap);
dup->flags = bmap->flags;
- dup->sample = isl_vec_copy(bmap->ctx, bmap->sample);
+ dup->sample = isl_vec_copy(bmap->sample);
return dup;
}
isl_blk_free(bmap->ctx, bmap->block2);
free(bmap->ineq);
isl_blk_free(bmap->ctx, bmap->block);
- isl_vec_free(bmap->ctx, bmap->sample);
+ isl_vec_free(bmap->sample);
isl_dim_free(bmap->dim);
free(bmap);
}
isl_int_init(s);
for (i = 0; i < bmap->n_eq; ++i) {
- isl_seq_inner_product(vec->block.data, bmap->eq[i], total, &s);
+ isl_seq_inner_product(vec->el, bmap->eq[i], total, &s);
if (!isl_int_is_zero(s)) {
isl_int_clear(s);
return 0;
}
for (i = 0; i < bmap->n_ineq; ++i) {
- isl_seq_inner_product(vec->block.data, bmap->ineq[i], total, &s);
+ isl_seq_inner_product(vec->el, bmap->ineq[i], total, &s);
if (isl_int_is_neg(s)) {
isl_int_clear(s);
return 0;
if (bmap1->sample &&
basic_map_contains(bmap1, bmap1->sample) > 0 &&
basic_map_contains(bmap2, bmap1->sample) > 0)
- sample = isl_vec_copy(bmap1->ctx, bmap1->sample);
+ sample = isl_vec_copy(bmap1->sample);
else if (bmap2->sample &&
basic_map_contains(bmap1, bmap2->sample) > 0 &&
basic_map_contains(bmap2, bmap2->sample) > 0)
- sample = isl_vec_copy(bmap2->ctx, bmap2->sample);
+ sample = isl_vec_copy(bmap2->sample);
bmap1 = isl_basic_map_cow(bmap1);
bmap1 = isl_basic_map_extend_dim(bmap1, isl_dim_copy(bmap1->dim),
bmap1 = add_constraints(bmap1, bmap2, 0, 0);
if (sample) {
- isl_vec_free(bmap1->ctx, bmap1->sample);
+ isl_vec_free(bmap1->sample);
bmap1->sample = sample;
}
return isl_basic_map_finalize(bmap1);
error:
if (sample)
- isl_vec_free(bmap1->ctx, sample);
+ isl_vec_free(sample);
isl_basic_map_free(bmap1);
isl_basic_map_free(bmap2);
return NULL;
return NULL;
}
-struct isl_basic_map *add_divs(struct isl_basic_map *bmap, unsigned n)
+static struct isl_basic_map *add_divs(struct isl_basic_map *bmap, unsigned n)
{
int i, j;
return NULL;
}
+/* If bmap contains any unknown divs, then compute explicit
+ * expressions for them. However, this computation may be
+ * quite expensive, so first try to remove divs that aren't
+ * strictly needed.
+ */
struct isl_map *isl_basic_map_compute_divs(struct isl_basic_map *bmap)
{
int i;
off = isl_dim_total(bmap->dim);
for (i = 0; i < bmap->n_div; ++i) {
if (isl_int_is_zero(bmap->div[i][0]))
- return isl_pip_basic_map_compute_divs(bmap);
+ break;
isl_assert(bmap->ctx, isl_int_is_zero(bmap->div[i][1+1+off+i]),
goto error);
}
- return isl_map_from_basic_map(bmap);
+ if (i == bmap->n_div)
+ return isl_map_from_basic_map(bmap);
+ bmap = isl_basic_map_drop_redundant_divs(bmap);
+ if (!bmap)
+ goto error;
+ for (i = 0; i < bmap->n_div; ++i)
+ if (isl_int_is_zero(bmap->div[i][0]))
+ break;
+ if (i == bmap->n_div)
+ return isl_map_from_basic_map(bmap);
+ struct isl_map *map = isl_pip_basic_map_compute_divs(bmap);
+ return map;
error:
isl_basic_map_free(bmap);
return NULL;
return bmap->n_eq == 0 && bmap->n_ineq == 0;
}
+int isl_basic_set_is_universe(struct isl_basic_set *bset)
+{
+ if (!bset)
+ return -1;
+ return bset->n_eq == 0 && bset->n_ineq == 0;
+}
+
int isl_basic_map_is_empty(struct isl_basic_map *bmap)
{
struct isl_basic_set *bset = NULL;
if (contains)
return 0;
}
+ isl_vec_free(bmap->sample);
+ bmap->sample = NULL;
bset = isl_basic_map_underlying_set(isl_basic_map_copy(bmap));
if (!bset)
return -1;
if (!sample)
return -1;
empty = sample->size == 0;
- if (bmap->sample)
- isl_vec_free(bmap->ctx, bmap->sample);
+ isl_vec_free(bmap->sample);
bmap->sample = sample;
+ if (empty)
+ ISL_F_SET(bmap, ISL_BASIC_MAP_EMPTY);
return empty;
}
bmap->n_div-i);
if (pos == -1)
continue;
- swap_div(bmap, i, pos);
+ swap_div(bmap, i, i + pos);
--i;
}
return bmap;
isl_int_clear(num);
isl_int_clear(den);
isl_basic_map_free(bmap1);
- isl_vec_free(ctx, obj);
+ isl_vec_free(obj);
return cmp;
error:
isl_basic_map_free(bmap1);
return NULL;
}
+/* Given two set A and B, construct its Cartesian product A x B.
+ */
+struct isl_set *isl_set_product(struct isl_set *set1, struct isl_set *set2)
+{
+ return (struct isl_set *)isl_map_product((struct isl_map *)set1,
+ (struct isl_map *)set2);
+}
+
uint32_t isl_basic_set_get_hash(struct isl_basic_set *bset)
{
int i;