isl_space_insert_dims: fix handling of nested spaces
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 30 May 2012 09:03:12 +0000 (11:03 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 30 May 2012 10:46:30 +0000 (12:46 +0200)
In particular, if we are inserting parameters, then we should also
insert them in any nested spaces.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_space.c

index f4b1b2a..87fad1f 100644 (file)
@@ -795,6 +795,10 @@ static int valid_dim_type(enum isl_dim_type type)
        }
 }
 
+/* Insert "n" dimensions of type "type" at position "pos".
+ * If we are inserting parameters, then they are also inserted in
+ * any nested spaces.
+ */
 __isl_give isl_space *isl_space_insert_dims(__isl_take isl_space *dim,
        enum isl_dim_type type, unsigned pos, unsigned n)
 {
@@ -852,6 +856,17 @@ __isl_give isl_space *isl_space_insert_dims(__isl_take isl_space *dim,
        }
        dim = isl_space_reset(dim, type);
 
+       if (type == isl_dim_param) {
+               if (dim && dim->nested[0] &&
+                   !(dim->nested[0] = isl_space_insert_dims(dim->nested[0],
+                                                   isl_dim_param, pos, n)))
+                       goto error;
+               if (dim && dim->nested[1] &&
+                   !(dim->nested[1] = isl_space_insert_dims(dim->nested[1],
+                                                   isl_dim_param, pos, n)))
+                       goto error;
+       }
+
        return dim;
 error:
        isl_space_free(dim);