isl_pw_*_union_add: don't subtract non-overlapping cells
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 7 Feb 2012 11:19:20 +0000 (12:19 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 7 Feb 2012 12:00:21 +0000 (13:00 +0100)
There is no point in subtracting a cell from another if their intersection
is empty.  It can only lead to a further subdivision of the other cell.

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

index 10bc4b8..448b082 100644 (file)
@@ -371,14 +371,14 @@ static __isl_give PW *FN(PW,union_add_aligned)(__isl_take PW *pw1,
                for (j = 0; j < pw2->n; ++j) {
                        struct isl_set *common;
                        EL *sum;
-                       set = isl_set_subtract(set,
-                                       isl_set_copy(pw2->p[j].set));
                        common = isl_set_intersect(isl_set_copy(pw1->p[i].set),
                                                isl_set_copy(pw2->p[j].set));
                        if (isl_set_plain_is_empty(common)) {
                                isl_set_free(common);
                                continue;
                        }
+                       set = isl_set_subtract(set,
+                                       isl_set_copy(pw2->p[j].set));
 
                        sum = FN(EL,add_on_domain)(common,
                                                   FN(EL,copy)(pw1->p[i].FIELD),