isl_basic_map_gist: unique lower or upper bounds are never redundant
authorSven Verdoolaege <skimo@kotnet.org>
Sat, 4 Oct 2008 21:42:21 +0000 (23:42 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 14 Oct 2008 08:22:00 +0000 (10:22 +0200)
isl_convex_hull.c
isl_map.c
isl_map_private.h

index 40afb4d..8e6c5d7 100644 (file)
@@ -58,10 +58,20 @@ int isl_basic_map_constraint_is_redundant(struct isl_basic_map **bmap,
                *bmap = isl_basic_map_set_to_empty(*bmap);
                return 0;
        }
-       isl_int_addmul(*opt_n, *opt_d, c[0]);
+       if (opt_d)
+               isl_int_addmul(*opt_n, *opt_d, c[0]);
+       else
+               isl_int_add(*opt_n, *opt_n, c[0]);
        return !isl_int_is_neg(*opt_n);
 }
 
+int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
+       isl_int *c, isl_int *opt_n, isl_int *opt_d)
+{
+       return isl_basic_map_constraint_is_redundant(
+                       (struct isl_basic_map **)bset, c, opt_n, opt_d);
+}
+
 /* Compute the convex hull of a basic map, by removing the redundant
  * constraints.  If the minimal value along the normal of a constraint
  * is the same if the constraint is removed, then the constraint is redundant.
index d9d350a..9f5d657 100644 (file)
--- a/isl_map.c
+++ b/isl_map.c
@@ -4320,7 +4320,6 @@ static struct isl_basic_set *uset_gist(struct isl_basic_set *bset,
        isl_int opt;
        struct isl_basic_set *combined;
        struct isl_ctx *ctx;
-       enum isl_lp_result res = isl_lp_ok;
 
        if (!bset || !context)
                goto error;
@@ -4351,29 +4350,27 @@ static struct isl_basic_set *uset_gist(struct isl_basic_set *bset,
        ctx = context->ctx;
        isl_int_init(opt);
        for (i = bset->n_ineq-1; i >= 0; --i) {
+               int redundant;
                set_swap_inequality(context, i, context->n_ineq-1);
                context->n_ineq--;
-               res = isl_solve_lp((struct isl_basic_map *)context, 0,
-                       context->ineq[context->n_ineq]+1, ctx->one, &opt, NULL);
-               context->n_ineq++;
-               set_swap_inequality(context, i, context->n_ineq-1);
-               if (res == isl_lp_unbounded)
-                       continue;
-               if (res == isl_lp_error)
-                       break;
-               if (res == isl_lp_empty) {
+               redundant = isl_basic_set_constraint_is_redundant(&context,
+                               context->ineq[context->n_ineq], &opt, NULL);
+               if (redundant == -1) {
+                       isl_int_clear(opt);
+                       goto error;
+               }
+               if (F_ISSET(context, ISL_BASIC_MAP_EMPTY)) {
                        bset = isl_basic_set_set_to_empty(bset);
                        break;
                }
-               isl_int_add(opt, opt, context->ineq[i][0]);
-               if (!isl_int_is_neg(opt)) {
+               context->n_ineq++;
+               set_swap_inequality(context, i, context->n_ineq-1);
+               if (redundant) {
                        isl_basic_set_drop_inequality(context, i);
                        isl_basic_set_drop_inequality(bset, i);
                }
        }
        isl_int_clear(opt);
-       if (res == isl_lp_error)
-               goto error;
 done:
        isl_basic_set_free(context);
        return bset;
index 9782e8c..e90c83d 100644 (file)
@@ -54,3 +54,6 @@ struct isl_set *isl_set_drop_vars(
 
 struct isl_basic_set *isl_basic_set_eliminate_vars(
        struct isl_basic_set *bset, unsigned pos, unsigned n);
+
+int isl_basic_set_constraint_is_redundant(struct isl_basic_set **bset,
+       isl_int *c, isl_int *opt_n, isl_int *opt_d);