struct isl_dim *isl_dim_drop_outputs(struct isl_dim *dim,
unsigned first, unsigned n);
struct isl_dim *isl_dim_domain(struct isl_dim *dim);
+struct isl_dim *isl_dim_underlying(struct isl_dim *dim, unsigned n_div);
int isl_dim_equal(struct isl_dim *dim1, struct isl_dim *dim2);
int isl_dim_compatible(struct isl_dim *dim1, struct isl_dim *dim2);
return isl_dim_reverse(dim);
}
+struct isl_dim *isl_dim_underlying(struct isl_dim *dim, unsigned n_div)
+{
+ int i;
+
+ if (!dim)
+ return NULL;
+ if (n_div == 0 &&
+ dim->nparam == 0 && dim->n_in == 0 && dim->n_name == 0)
+ return dim;
+ dim = isl_dim_cow(dim);
+ if (!dim)
+ return NULL;
+ dim->n_out += dim->nparam + dim->n_in + n_div;
+ dim->nparam = 0;
+ dim->n_in = 0;
+
+ for (i = 0; i < dim->n_name; ++i)
+ isl_name_free(dim->ctx, get_name(dim, isl_dim_out, i));
+ dim->n_name = 0;
+
+ return dim;
+}
+
unsigned isl_dim_total(struct isl_dim *dim)
{
return dim->nparam + dim->n_in + dim->n_out;
bmap = isl_basic_map_cow(bmap);
if (!bmap)
goto error;
- bmap->dim = isl_dim_cow(bmap->dim);
+ bmap->dim = isl_dim_underlying(bmap->dim, bmap->n_div);
if (!bmap->dim)
goto error;
- bmap->dim->n_out += bmap->dim->nparam + bmap->dim->n_in + bmap->n_div;
- bmap->dim->nparam = 0;
- bmap->dim->n_in = 0;
bmap->extra -= bmap->n_div;
bmap->n_div = 0;
bmap = isl_basic_map_finalize(bmap);
goto error;
}
if (map->n == 0)
- map->dim->n_out += map->dim->nparam + map->dim->n_in;
- else
- map->dim->n_out = map->p[0]->dim->n_out;
- map->dim->nparam = 0;
- map->dim->n_in = 0;
+ map->dim = isl_dim_underlying(map->dim, 0);
+ else {
+ isl_dim_free(map->dim);
+ map->dim = isl_dim_copy(map->p[0]->dim);
+ }
+ if (!map->dim)
+ goto error;
return (struct isl_set *)map;
error:
isl_map_free(map);