isl_{set,map}_{,unshifted_}simple_hull: finalize result

These are public function, so the result should be finalized.

The effect on the AST generation output is due to the fact that
during a gist, a simple hull would be computed of the context
that contains a redundant div because the other constraints
involving the div are not retained in the simple hull.
This redundant div would then get introduced in one of the basic
maps that are gisted, where it happens to have a fixed value.
After variable compression, one of the div constraints of the
redundant div would result in an _extra_ constraint in the result.
Now that redundant divs are removed from the simple hull of the context,
this extra constraint is no longer introduced.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_basic_map_remove_divs_involving_dims: avoid adding constraints to copy

Before calling isl_basic_map_remove_dims,
isl_basic_map_remove_divs_involving_dims calls insert_bounds_on_div
to insert extra constraints that can be used during Fourier-Motzkin.
These constraints should not be added to the input of
the isl_basic_map_remove_divs_involving_dims call, but only to the output
(or rather the intermediate result that will be used to construct the output).
That is, add a call to isl_basic_map_cow to ensure any other copies
of the input are left alone.

We also clear the ISL_BASIC_MAP_NORMALIZED flag, but this should
not have any effect since the flag is also cleared by
isl_basic_map_drop.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_aff_div: handle NaN input

We missed this in dd229ee (add preliminary support for affine NaN expressions,
Thu Feb 20 12:27:11 2014 +0100).

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_id_alloc: return NULL if ctx argument is NULL

We missed this in e9a49bb (isl_*alloc*: return NULL if ctx argument is NULL,
Tue May 29 15:44:46 2012 +0200) because the ctx argument is used
before the isl_id structure is allocation.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_set_coefficients: rename "dim" variable to "space"

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_set_solutions: rename "dim" variable to "space"

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_farkas.c: farkas: rename "dim" variable to "space"

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_farkas.c: extract out shared rational_universe

We will be able to reuse this function in the next commit.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_basic_set_{coefficients,solutions}: handle obviously empty input

We already specifically handle this case in isl_set_coefficients
and isl_set_solutions, but if isl_basic_set_coefficients or
isl_basic_set_solutions is called directly, we would return
a meaningless result.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_basic_map_preimage_multi_aff: check if parameters of inputs match

We currently assume that they do, but fail to check this condition.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_printer_print_pw_aff: keep track of whether we have printed any constraint

In the original code, it was the responsibility of print_basic_set_c to
keep track of whether it has printed any constraints with print_constraint_c
(or otherwise).
However, in d593762 (isl_printer_print_pw_aff: skip constraints implied
by div expression, Tue Feb 7 12:17:03 2012 +0100), we started skipping
some constraints in print_constraint_c.  If this happened to be the
first constraint that we tried to print, then print_basic_set_c's notion
of whether we have printed anything yet would be wrong, resulting in
output that starts with "&&".
Keep track of whether we have printed any constraint in print_constraint_c
itself.

It is difficult to construct a simple test case that reliably tickles
this bug.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
do not print colon if there are no constraints in omega format

Apparently, the Omega calculator does not accept a colon without
any following constraints, so we do not print the colon if there
are no constraints when printing in omega format.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_pw_*_gist: improve error handling

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c: extract_node: rename "dim" variable to "space"

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c: extract_node: improve error handling

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_schedule.c: copy_nodes: improve error handling

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_codegen.c: generate_domain: compute explicit representations of divs

The AST generator cannot build an expression from a set if it has
any unknown divs.  Call isl_set_compute_divs on the guard to
ensure that all divs are known.

This problem only rarely shows up because explicit representations
are usually computed implicitly by the call to isl_ast_build_compute_gist.
However, if the build domain is a universe set (which may happen
in the case of full unrolling), then this implicit divs computation
is not performed.

Reported-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_ast_node_user_get_expr: check that input is indeed a user node

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