isl_pw_*_gist: avoid intersection of domain with context
authorSven Verdoolaege <skimo@kotnet.org>
Fri, 24 Aug 2012 17:38:39 +0000 (19:38 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Thu, 6 Sep 2012 13:45:21 +0000 (15:45 +0200)
The intersection was introduced in cf42ba2 (isl_pw_qpolynomial_gist:
substitute equalities in polynomials, Mon Oct 25 13:49:22 2010 +0200)
in order to be able to detect and exploit equalities in the intersection.
However, there is no need to change the domain itself as we can just
as well use a temporary object.

Intersecting the domain with the context is not what the user would
expect as the purpose of the gist operation is to only keep the most
salient information, which is quite the opposite of introducing
extra constraints.

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

index b80e084..fa757c0 100644 (file)
@@ -802,16 +802,17 @@ static __isl_give PW *FN(PW,gist_aligned)(__isl_take PW *pw,
                goto error;
 
        for (i = pw->n - 1; i >= 0; --i) {
-               pw->p[i].set = isl_set_intersect(pw->p[i].set,
+               isl_set *set_i;
+               int empty;
+
+               set_i = isl_set_intersect(isl_set_copy(pw->p[i].set),
                                                 isl_set_copy(context));
-               if (!pw->p[i].set)
-                       goto error;
-               pw->p[i].FIELD = fn_el(pw->p[i].FIELD,
-                                            isl_set_copy(pw->p[i].set));
+               empty = isl_set_plain_is_empty(set_i);
+               pw->p[i].FIELD = fn_el(pw->p[i].FIELD, set_i);
                pw->p[i].set = fn_dom(pw->p[i].set, isl_basic_set_copy(hull));
-               if (!pw->p[i].set)
+               if (!pw->p[i].FIELD || !pw->p[i].set)
                        goto error;
-               if (isl_set_plain_is_empty(pw->p[i].set)) {
+               if (empty) {
                        isl_set_free(pw->p[i].set);
                        FN(EL,free)(pw->p[i].FIELD);
                        if (i != pw->n - 1)