isl_map_transitive_closure: break early if input map doesn't compose with itself
[platform/upstream/isl.git] / isl_map_simplify.c
index c9f997e..d4b7af9 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * Copyright 2008-2009 Katholieke Universiteit Leuven
+ *
+ * Use of this software is governed by the GNU LGPLv2.1 license
+ *
+ * Written by Sven Verdoolaege, K.U.Leuven, Departement
+ * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
+ */
+
 #include "isl_equalities.h"
 #include "isl_map.h"
 #include "isl_map_private.h"
@@ -233,6 +242,12 @@ error:
        return NULL;
 }
 
+struct isl_set *isl_set_drop(struct isl_set *set,
+       enum isl_dim_type type, unsigned first, unsigned n)
+{
+       return (isl_set *)isl_map_drop((isl_map *)set, type, first, n);
+}
+
 struct isl_map *isl_map_drop_inputs(
                struct isl_map *map, unsigned first, unsigned n)
 {
@@ -1007,6 +1022,8 @@ static struct isl_basic_map *remove_duplicate_constraints(
                         * will no longer be valid.
                         * Plus, we probably we want to regauss first.
                         */
+                       if (progress)
+                               *progress = 1;
                        isl_basic_map_drop_inequality(bmap, l);
                        isl_basic_map_inequality_to_equality(bmap, k);
                } else
@@ -1565,26 +1582,30 @@ static struct isl_basic_set *uset_gist(struct isl_basic_set *bset,
        bset = remove_shifted_constraints(bset, context);
        if (!bset->n_ineq)
                goto done;
-       isl_basic_set_free_equality(context, context->n_eq);
        context_ineq = context->n_ineq;
        combined = isl_basic_set_cow(isl_basic_set_copy(context));
+       if (isl_basic_set_free_equality(combined, context->n_eq) < 0)
+               goto error;
        combined = isl_basic_set_extend_constraints(combined,
                                                    bset->n_eq, bset->n_ineq);
        tab = isl_tab_from_basic_set(combined);
        if (!tab)
                goto error;
        for (i = 0; i < context_ineq; ++i)
-               tab->con[i].frozen = 1;
+               if (isl_tab_freeze_constraint(tab, i) < 0)
+                       goto error;
        tab = isl_tab_extend(tab, bset->n_ineq);
        if (!tab)
                goto error;
        for (i = 0; i < bset->n_ineq; ++i)
-               tab = isl_tab_add_ineq(tab, bset->ineq[i]);
+               if (isl_tab_add_ineq(tab, bset->ineq[i]) < 0)
+                       goto error;
        bset = isl_basic_set_add_constraints(combined, bset, 0);
        tab = isl_tab_detect_implicit_equalities(tab);
-       tab = isl_tab_detect_redundant(tab);
-       if (!tab)
+       if (isl_tab_detect_redundant(tab) < 0) {
+               isl_tab_free(tab);
                goto error2;
+       }
        for (i = 0; i < context_ineq; ++i) {
                tab->con[i].is_zero = 0;
                tab->con[i].is_redundant = 1;