bound.c: remove unused variable
[platform/upstream/isl.git] / isl_map_subtract.c
index 2cbdb01..1cdd68e 100644 (file)
@@ -7,10 +7,10 @@
  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
  */
 
-#include "isl_seq.h"
-#include "isl_set.h"
-#include "isl_map.h"
-#include "isl_map_private.h"
+#include <isl_map_private.h>
+#include <isl/seq.h>
+#include <isl/set.h>
+#include <isl/map.h>
 #include "isl_tab.h"
 #include <isl_point_private.h>
 
@@ -49,6 +49,8 @@ static int tab_add_constraints(struct isl_tab *tab,
                return -1;
 
        v = isl_vec_alloc(bmap->ctx, 1 + tab_total);
+       if (!v)
+               return -1;
 
        for (i = 0; i < bmap->n_eq; ++i) {
                expand_constraint(v, dim, bmap->eq[i], div_map, bmap->n_div);
@@ -204,7 +206,8 @@ static int tab_freeze_constraints(struct isl_tab *tab)
  * Put the indices of the redundant constraints in index
  * and return the number of redundant constraints.
  */
-static int n_non_redundant(struct isl_tab *tab, int offset, int **index)
+static int n_non_redundant(isl_ctx *ctx, struct isl_tab *tab,
+       int offset, int **index)
 {
        int i, n;
        int n_test = tab->n_con - offset;
@@ -213,7 +216,7 @@ static int n_non_redundant(struct isl_tab *tab, int offset, int **index)
                return -1;
 
        if (!*index)
-               *index = isl_alloc_array(tab->mat->ctx, int, n_test);
+               *index = isl_alloc_array(ctx, int, n_test);
        if (!*index)
                return -1;
 
@@ -246,7 +249,7 @@ struct isl_diff_collector {
  * a negative value is treated as an error, but the calling
  * function can interpret the results based on the state of dc.
  *
- * Assumes that both bmap and map have known divs.
+ * Assumes that map has known divs.
  *
  * The difference is computed by a backtracking algorithm.
  * Each level corresponds to a basic map in "map".
@@ -276,6 +279,7 @@ static int basic_map_collect_diff(__isl_take isl_basic_map *bmap,
        int level;
        int init;
        int empty;
+       isl_ctx *ctx;
        struct isl_tab *tab = NULL;
        struct isl_tab_undo **snap = NULL;
        int *k = NULL;
@@ -296,6 +300,7 @@ static int basic_map_collect_diff(__isl_take isl_basic_map *bmap,
        if (!bmap || !map)
                goto error;
 
+       ctx = map->ctx;
        snap = isl_alloc_array(map->ctx, struct isl_tab_undo *, map->n);
        k = isl_alloc_array(map->ctx, int, map->n);
        n = isl_alloc_array(map->ctx, int, map->n);
@@ -363,7 +368,8 @@ static int basic_map_collect_diff(__isl_take isl_basic_map *bmap,
                                continue;
                        }
                        modified = 1;
-                       n[level] = n_non_redundant(tab, offset, &index[level]);
+                       n[level] = n_non_redundant(ctx, tab, offset,
+                                                   &index[level]);
                        if (n[level] < 0)
                                goto error;
                        if (n[level] == 0) {
@@ -554,7 +560,7 @@ static int basic_map_diff_is_empty(__isl_keep isl_basic_map *bmap,
        int r;
        struct isl_is_empty_diff_collector edc;
 
-       r = isl_basic_map_fast_is_empty(bmap);
+       r = isl_basic_map_plain_is_empty(bmap);
        if (r)
                return r;
 
@@ -590,7 +596,7 @@ static int map_diff_is_empty(__isl_keep isl_map *map1, __isl_keep isl_map *map2)
 
 /* Return 1 if "bmap" contains a single element.
  */
-int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap)
+int isl_basic_map_plain_is_singleton(__isl_keep isl_basic_map *bmap)
 {
        if (!bmap)
                return -1;
@@ -603,14 +609,14 @@ int isl_basic_map_is_singleton(__isl_keep isl_basic_map *bmap)
 
 /* Return 1 if "map" contains a single element.
  */
-int isl_map_is_singleton(__isl_keep isl_map *map)
+int isl_map_plain_is_singleton(__isl_keep isl_map *map)
 {
        if (!map)
                return -1;
        if (map->n != 1)
                return 0;
 
-       return isl_basic_map_is_singleton(map->p[0]);
+       return isl_basic_map_plain_is_singleton(map->p[0]);
 }
 
 /* Given a singleton basic map, extract the single element
@@ -669,6 +675,7 @@ error:
 
 /* Return 1 is the singleton map "map1" is a subset of "map2",
  * i.e., if the single element of "map1" is also an element of "map2".
+ * Assumes "map2" has known divs.
  */
 static int map_is_singleton_subset(__isl_keep isl_map *map1,
        __isl_keep isl_map *map2)
@@ -710,19 +717,16 @@ int isl_map_is_subset(struct isl_map *map1, struct isl_map *map2)
        if (isl_map_is_empty(map2))
                return 0;
 
-       if (isl_map_fast_is_universe(map2))
+       if (isl_map_plain_is_universe(map2))
                return 1;
 
-       map1 = isl_map_compute_divs(isl_map_copy(map1));
        map2 = isl_map_compute_divs(isl_map_copy(map2));
-       if (isl_map_is_singleton(map1)) {
+       if (isl_map_plain_is_singleton(map1)) {
                is_subset = map_is_singleton_subset(map1, map2);
-               isl_map_free(map1);
                isl_map_free(map2);
                return is_subset;
        }
        is_subset = map_diff_is_empty(map1, map2);
-       isl_map_free(map1);
        isl_map_free(map2);
 
        return is_subset;