return NULL;
}
+/* Plug in "subs" for dimension "type", "pos" in the integer divisions
+ * of "ls".
+ *
+ * Let i be the dimension to replace and let "subs" be of the form
+ *
+ * f/d
+ *
+ * Any integer division with a non-zero coefficient for i,
+ *
+ * floor((a i + g)/m)
+ *
+ * is replaced by
+ *
+ * floor((a f + d g)/(m d))
+ */
+__isl_give isl_local_space *isl_local_space_substitute(
+ __isl_take isl_local_space *ls,
+ enum isl_dim_type type, unsigned pos, __isl_keep isl_aff *subs)
+{
+ int i;
+ isl_int v;
+
+ ls = isl_local_space_cow(ls);
+ if (!ls || !subs)
+ return isl_local_space_free(ls);
+
+ if (!isl_space_is_equal(ls->dim, subs->ls->dim))
+ isl_die(isl_local_space_get_ctx(ls), isl_error_invalid,
+ "spaces don't match", return isl_local_space_free(ls));
+ if (isl_local_space_dim(subs->ls, isl_dim_div) != 0)
+ isl_die(isl_local_space_get_ctx(ls), isl_error_unsupported,
+ "cannot handle divs yet",
+ return isl_local_space_free(ls));
+
+ pos += isl_local_space_offset(ls, type);
+
+ isl_int_init(v);
+ for (i = 0; i < ls->div->n_row; ++i) {
+ if (isl_int_is_zero(ls->div->row[i][1 + pos]))
+ continue;
+ isl_int_set(v, ls->div->row[i][1 + pos]);
+ isl_int_set_si(ls->div->row[i][1 + pos], 0);
+ isl_seq_combine(ls->div->row[i] + 1,
+ subs->v->el[0], ls->div->row[i] + 1,
+ v, subs->v->el + 1, subs->v->size - 1);
+ isl_int_mul(ls->div->row[i][0],
+ ls->div->row[i][0], subs->v->el[0]);
+ normalize_div(ls, i);
+ }
+ isl_int_clear(v);
+
+ return ls;
+}
+
int isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
enum isl_dim_type type)
{