isl_local_space_substitute_seq: take argument for the number of divs to modify
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 29 Sep 2012 17:45:57 +0000 (29 19:45 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 13 Nov 2012 23:33:52 +0000 (14 00:33 +0100)
This will allow us to modify a single div in the next commit.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_aff.c
isl_local_space.c
isl_local_space_private.h

index 0ea1847..a77533f 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -758,7 +758,7 @@ static __isl_give isl_aff *plug_in_integral_divs(__isl_take isl_aff *aff)
                        continue;
                ls = isl_local_space_copy(aff->ls);
                ls = isl_local_space_substitute_seq(ls, isl_dim_div, i,
-                                           aff->ls->div->row[i], len, i + 1);
+                               aff->ls->div->row[i], len, i + 1, n - (i + 1));
                vec = isl_vec_copy(aff->v);
                vec = isl_vec_cow(vec);
                if (!ls || !vec)
index 33bf348..6c4fb84 100644 (file)
@@ -752,7 +752,7 @@ error:
 
 /* Plug in the affine expressions "subs" of length "subs_len" (including
  * the denominator and the constant term) into the variable at position "pos"
- * of all the div expressions starting at "first".
+ * of the "n" div expressions starting at "first".
  *
  * Let i be the dimension to replace and let "subs" be of the form
  *
@@ -769,11 +769,13 @@ error:
 __isl_give isl_local_space *isl_local_space_substitute_seq(
        __isl_take isl_local_space *ls,
        enum isl_dim_type type, unsigned pos, isl_int *subs, int subs_len,
-       int first)
+       int first, int n)
 {
        int i;
        isl_int v;
 
+       if (n == 0)
+               return ls;
        ls = isl_local_space_cow(ls);
        if (!ls)
                return NULL;
@@ -781,6 +783,10 @@ __isl_give isl_local_space *isl_local_space_substitute_seq(
        if (!ls->div)
                return isl_local_space_free(ls);
 
+       if (first + n > ls->div->n_row)
+               isl_die(isl_local_space_get_ctx(ls), isl_error_invalid,
+                       "index out of bounds", return isl_local_space_free(ls));
+
        pos += isl_local_space_offset(ls, type);
 
        isl_int_init(v);
@@ -828,7 +834,7 @@ __isl_give isl_local_space *isl_local_space_substitute(
                        return isl_local_space_free(ls));
 
        return isl_local_space_substitute_seq(ls, type, pos, subs->v->el,
-                                               subs->v->size, 0);
+                                           subs->v->size, 0, ls->div->n_row);
 }
 
 int isl_local_space_is_named_or_nested(__isl_keep isl_local_space *ls,
index f9c84dc..d54c3e3 100644 (file)
@@ -52,7 +52,7 @@ int *isl_local_space_get_active(__isl_keep isl_local_space *ls, isl_int *l);
 __isl_give isl_local_space *isl_local_space_substitute_seq(
        __isl_take isl_local_space *ls,
        enum isl_dim_type type, unsigned pos, isl_int *subs, int subs_len,
-       int first);
+       int first, int n);
 __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);