-static int guarded_poly_bound(__isl_take isl_basic_set *bset,
- __isl_take isl_qpolynomial *poly, void *user)
-{
- struct range_data *data = (struct range_data *)user;
- isl_pw_qpolynomial_fold *top_pwf;
- isl_pw_qpolynomial_fold *top_pwf_exact;
- isl_dim *dim;
- isl_morph *morph;
- unsigned orig_nvar, final_nvar;
- int r;
-
- bset = isl_basic_set_detect_equalities(bset);
-
- if (!bset)
- goto error;
-
- if (bset->n_eq == 0)
- return compressed_guarded_poly_bound(bset, poly, user);
-
- orig_nvar = isl_basic_set_dim(bset, isl_dim_set);
-
- morph = isl_basic_set_full_compression(bset);
-
- bset = isl_morph_basic_set(isl_morph_copy(morph), bset);
- poly = isl_qpolynomial_morph(poly, isl_morph_copy(morph));
-
- final_nvar = isl_basic_set_dim(bset, isl_dim_set);
-
- dim = isl_morph_get_ran_dim(morph);
- dim = isl_dim_drop(dim, isl_dim_set, 0, isl_dim_size(dim, isl_dim_set));
-
- top_pwf = data->pwf;
- top_pwf_exact = data->pwf_exact;
-
- data->pwf = isl_pw_qpolynomial_fold_zero(isl_dim_copy(dim));
- data->pwf_exact = isl_pw_qpolynomial_fold_zero(dim);
-
- r = compressed_guarded_poly_bound(bset, poly, user);
-
- morph = isl_morph_remove_dom_dims(morph, isl_dim_set, 0, orig_nvar);
- morph = isl_morph_remove_ran_dims(morph, isl_dim_set, 0, final_nvar);
- morph = isl_morph_inverse(morph);
-
- data->pwf = isl_pw_qpolynomial_fold_morph(data->pwf,
- isl_morph_copy(morph));
- data->pwf_exact = isl_pw_qpolynomial_fold_morph(data->pwf_exact, morph);
-
- data->pwf = isl_pw_qpolynomial_fold_add(top_pwf, data->pwf);
- data->pwf_exact = isl_pw_qpolynomial_fold_add(top_pwf_exact,
- data->pwf_exact);
-
- return r;
-error:
- isl_basic_set_free(bset);
- isl_qpolynomial_free(poly);
- return -1;
-}
-
-static int basic_guarded_bound(__isl_take isl_basic_set *bset, void *user)
-{
- struct range_data *data = (struct range_data *)user;
- int r;
-
- r = isl_qpolynomial_as_polynomial_on_domain(data->qp, bset,
- &guarded_poly_bound, user);
- isl_basic_set_free(bset);
- return r;
-}
-
-static int guarded_bound(__isl_take isl_set *set,
- __isl_take isl_qpolynomial *qp, void *user)
-{
- struct range_data *data = (struct range_data *)user;
-
- if (!set || !qp)
- goto error;
-
- set = isl_set_make_disjoint(set);
-
- data->qp = qp;
-
- if (isl_set_foreach_basic_set(set, &basic_guarded_bound, data) < 0)
- goto error;
-
- isl_set_free(set);
- isl_qpolynomial_free(qp);
-
- return 0;
-error:
- isl_set_free(set);
- isl_qpolynomial_free(qp);
- return -1;
-}
-
-/* Compute a lower or upper bound (depending on "type") on the given
- * piecewise step-polynomial using range propagation.
- */
-__isl_give isl_pw_qpolynomial_fold *isl_pw_qpolynomial_bound_range(
- __isl_take isl_pw_qpolynomial *pwqp, enum isl_fold type, int *exact)