isl_map_simplify.c: better_div_constraint: use isl_basic_map_dim
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 13 Jul 2016 07:11:07 +0000 (13 09:11 +0200)
committerSven Verdoolaege <sven@cerebras.net>
Sat, 8 Jun 2024 16:29:56 +0000 (8 18:29 +0200)
This reduces the dependence on the internal representation.

Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_map_simplify.c

index 4549633..a0be9ea 100644 (file)
@@ -1323,19 +1323,21 @@ static isl_bool better_div_constraint(__isl_keep isl_basic_map *bmap,
        int div, int ineq)
 {
        unsigned total = isl_basic_map_offset(bmap, isl_dim_div);
+       isl_size n_div = isl_basic_map_dim(bmap, isl_dim_div);
        int last_div;
        int last_ineq;
 
+       if (n_div < 0)
+               return isl_bool_error;
        if (isl_int_is_zero(bmap->div[div][0]))
                return isl_bool_true;
 
        if (isl_seq_last_non_zero(bmap->ineq[ineq] + total + div + 1,
-                                 bmap->n_div - (div + 1)) >= 0)
+                                 n_div - (div + 1)) >= 0)
                return isl_bool_false;
 
        last_ineq = isl_seq_last_non_zero(bmap->ineq[ineq], total + div);
-       last_div = isl_seq_last_non_zero(bmap->div[div] + 1,
-                                        total + bmap->n_div);
+       last_div = isl_seq_last_non_zero(bmap->div[div] + 1, total + n_div);
 
        return last_ineq < last_div;
 }