/* Check if the constraints in "set" imply any stride on set dimension "pos" and * store the results in data->stride and data->offset. * * In particular, compute the affine hull and then check if * any of the constraints in the hull impose any stride on the dimension. * If no such constraint can be found, then the offset is taken * to be the zero expression and the stride is taken to be one. */ static void set_detect_stride(__isl_keep isl_set *set, int pos, struct isl_detect_stride_data *data) { isl_basic_set *hull; hull = isl_set_affine_hull(isl_set_copy(set)); data->pos = pos; data->found = 0; data->stride = NULL; data->offset = NULL; if (isl_basic_set_foreach_constraint(hull, &detect_stride, data) < 0) goto error; if (!data->found) { data->stride = isl_val_one(isl_set_get_ctx(set)); if (data->want_offset) { isl_space *space; isl_local_space *ls; space = isl_set_get_space(set); ls = isl_local_space_from_space(space); data->offset = isl_aff_zero_on_domain(ls); } } isl_basic_set_free(hull); return; error: isl_basic_set_free(hull); data->stride = isl_val_free(data->stride); data->offset = isl_aff_free(data->offset); }
/* Check if dimension "dim" belongs to a residue class * i_dim \equiv r mod m * with m != 1 and if so return m in *modulo and r in *residue. * As a special case, when i_dim has a fixed value v, then * *modulo is set to 0 and *residue to v. * * If i_dim does not belong to such a residue class, then *modulo * is set to 1 and *residue is set to 0. */ isl_stat isl_set_dim_residue_class_val(__isl_keep isl_set *set, int pos, __isl_give isl_val **modulo, __isl_give isl_val **residue) { *modulo = NULL; *residue = NULL; if (!set) return isl_stat_error; *modulo = isl_val_alloc(isl_set_get_ctx(set)); *residue = isl_val_alloc(isl_set_get_ctx(set)); if (!*modulo || !*residue) goto error; if (isl_set_dim_residue_class(set, pos, &(*modulo)->n, &(*residue)->n) < 0) goto error; isl_int_set_si((*modulo)->d, 1); isl_int_set_si((*residue)->d, 1); return isl_stat_ok; error: isl_val_free(*modulo); isl_val_free(*residue); return isl_stat_error; }