- scan_tree_for_params (SCOP_REGION (scop), nb_iters, ub_expr, one);
- value_clear (one);
-
- if (estimated_loop_iterations (loop, true, &nit))
- add_upper_bounds_from_estimated_nit (scop, nit, dim, ub_expr);
-
- /* loop_i <= expr_nb_iters */
- ppl_set_coef (ub_expr, nb, -1);
- ppl_new_Constraint (&ub, ub_expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
- ppl_Polyhedron_add_constraint (ph, ub);
- ppl_delete_Linear_Expression (ub_expr);
- ppl_delete_Constraint (ub);
+
+ aff = extract_affine (scop, nb_iters, isl_set_get_space (inner));
+ valid = isl_pw_aff_nonneg_set (isl_pw_aff_copy (aff));
+ valid = isl_set_project_out (valid, isl_dim_set, 0,
+ isl_set_dim (valid, isl_dim_set));
+ scop->context = isl_set_intersect (scop->context, valid);
+
+ ls = isl_local_space_from_space (isl_space_copy (space));
+ al = isl_aff_set_coefficient_si (isl_aff_zero_on_domain (ls),
+ isl_dim_in, pos, 1);
+ le = isl_pw_aff_le_set (isl_pw_aff_from_aff (al),
+ isl_pw_aff_copy (aff));
+ inner = isl_set_intersect (inner, le);
+
+ if (max_stmt_executions (loop, &nit))
+ {
+ /* Insert in the context the constraints from the
+ estimation of the number of iterations NIT and the
+ symbolic number of iterations (involving parameter
+ names) NB_ITERS. First, build the affine expression
+ "NIT - NB_ITERS" and then say that it is positive,
+ i.e., NIT approximates NB_ITERS: "NIT >= NB_ITERS". */
+ isl_pw_aff *approx;
+ mpz_t g;
+ isl_set *x;
+ isl_constraint *c;
+
+ mpz_init (g);
+ mpz_set_double_int (g, nit, false);
+ mpz_sub_ui (g, g, 1);
+ approx = extract_affine_gmp (g, isl_set_get_space (inner));
+ x = isl_pw_aff_ge_set (approx, aff);
+ x = isl_set_project_out (x, isl_dim_set, 0,
+ isl_set_dim (x, isl_dim_set));
+ scop->context = isl_set_intersect (scop->context, x);
+
+ c = isl_inequality_alloc
+ (isl_local_space_from_space (isl_space_copy (space)));
+ c = isl_constraint_set_coefficient_si (c, isl_dim_set, pos, -1);
+ isl_int_set_gmp (v, g);
+ mpz_clear (g);
+ c = isl_constraint_set_constant (c, v);
+ inner = isl_set_add_constraint (inner, c);
+ }
+ else
+ isl_pw_aff_free (aff);