void open_hypercube(int dimension, ppl_Polyhedron_t ph) { int i; mpz_t z_one; mpz_t z_minus_one; ppl_Coefficient_t coeff_one; ppl_Coefficient_t coeff_minus_one; ppl_Linear_Expression_t le; ppl_Constraint_t c; ppl_Constraint_System_t cs; mpz_init_set_si(z_one, 1); mpz_init_set_si(z_minus_one, -1); ppl_new_Coefficient(&coeff_one); ppl_assign_Coefficient_from_mpz_t(coeff_one, z_one); ppl_new_Coefficient(&coeff_minus_one); ppl_assign_Coefficient_from_mpz_t(coeff_minus_one, z_minus_one); ppl_new_Linear_Expression_with_dimension(&le, dimension); ppl_new_Constraint_System(&cs); for (i = 0; i < dimension; ++i) { ppl_Linear_Expression_add_to_coefficient(le, i, coeff_one); /* Variable(i) > 0 */ ppl_new_Constraint(&c, le, PPL_CONSTRAINT_TYPE_GREATER_THAN); ppl_Constraint_System_insert_Constraint(cs, c); ppl_delete_Constraint(c); /* Variable(i) < 1 */ ppl_Linear_Expression_add_to_inhomogeneous(le, coeff_minus_one); ppl_new_Constraint(&c, le, PPL_CONSTRAINT_TYPE_LESS_THAN); ppl_Constraint_System_insert_Constraint(cs, c); ppl_delete_Constraint(c); /* Zero `le' */ ppl_Linear_Expression_add_to_coefficient(le, i, coeff_minus_one); ppl_Linear_Expression_add_to_inhomogeneous(le, coeff_one); } ppl_Polyhedron_add_constraints(ph, cs); ppl_delete_Constraint_System(cs); ppl_delete_Linear_Expression(le); ppl_delete_Coefficient(coeff_minus_one); ppl_delete_Coefficient(coeff_one); mpz_clear(z_minus_one); mpz_clear(z_one); }
ppl_Polyhedron_t ppl_strip_loop (ppl_Polyhedron_t ph, ppl_dimension_type loop, int stride) { ppl_const_Constraint_System_t pcs; ppl_Constraint_System_const_iterator_t cit, end; ppl_const_Constraint_t cstr; ppl_Linear_Expression_t expr; int v; ppl_dimension_type dim; ppl_Polyhedron_t res; ppl_Coefficient_t c; Value val; value_init (val); ppl_new_Coefficient (&c); ppl_Polyhedron_space_dimension (ph, &dim); ppl_Polyhedron_get_constraints (ph, &pcs); /* Start from a copy of the constraints. */ ppl_new_C_Polyhedron_from_space_dimension (&res, dim + 1, 0); ppl_Polyhedron_add_constraints (res, pcs); /* Add an empty dimension for the strip loop. */ ppl_insert_dimensions (res, loop, 1); /* Identify the constraints that define the lower and upper bounds of the strip-mined loop, and add them to the strip loop. */ { ppl_Polyhedron_t tmp; ppl_new_C_Polyhedron_from_space_dimension (&tmp, dim + 1, 0); ppl_new_Constraint_System_const_iterator (&cit); ppl_new_Constraint_System_const_iterator (&end); for (ppl_Constraint_System_begin (pcs, cit), ppl_Constraint_System_end (pcs, end); !ppl_Constraint_System_const_iterator_equal_test (cit, end); ppl_Constraint_System_const_iterator_increment (cit)) { ppl_Constraint_System_const_iterator_dereference (cit, &cstr); ppl_new_Linear_Expression_from_Constraint (&expr, cstr); ppl_Linear_Expression_coefficient (expr, loop, c); ppl_delete_Linear_Expression (expr); ppl_Coefficient_to_mpz_t (c, val); v = value_get_si (val); if (0 < v || v < 0) ppl_Polyhedron_add_constraint (tmp, cstr); } ppl_delete_Constraint_System_const_iterator (cit); ppl_delete_Constraint_System_const_iterator (end); ppl_insert_dimensions (tmp, loop + 1, 1); ppl_Polyhedron_get_constraints (tmp, &pcs); ppl_Polyhedron_add_constraints (res, pcs); ppl_delete_Polyhedron (tmp); } /* Lower bound of a tile starts at "stride * outer_iv". */ { ppl_Constraint_t new_cstr; ppl_new_Linear_Expression_with_dimension (&expr, dim + 1); ppl_set_coef (expr, loop + 1, 1); ppl_set_coef (expr, loop, -1 * stride); ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL); ppl_delete_Linear_Expression (expr); ppl_Polyhedron_add_constraint (res, new_cstr); ppl_delete_Constraint (new_cstr); } /* Upper bound of a tile stops at "stride * outer_iv + stride - 1", or at the old upper bound that is not modified. */ { ppl_Constraint_t new_cstr; ppl_new_Linear_Expression_with_dimension (&expr, dim + 1); ppl_set_coef (expr, loop + 1, -1); ppl_set_coef (expr, loop, stride); ppl_set_inhomogeneous (expr, stride - 1); ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL); ppl_delete_Linear_Expression (expr); ppl_Polyhedron_add_constraint (res, new_cstr); ppl_delete_Constraint (new_cstr); } value_clear (val); ppl_delete_Coefficient (c); return res; }