isl_map_simplify.c: div_is_redundant: ignore coefficients of unknown divs
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 16 Apr 2013 09:49:05 +0000 (11:49 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Mon, 22 Apr 2013 07:38:19 +0000 (09:38 +0200)
If a div is unknown, then its coefficients are undefined so we should
not take them into account while checking if some other div is redundant.
In rare cases, looking at those undefined coefficients could result
in system dependent behavior.

Reported-by: Tobias Grosser <tobias@grosser.es>
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_map_simplify.c

index a25daf1..00533cf 100644 (file)
@@ -1363,9 +1363,12 @@ static int div_is_redundant(struct isl_basic_map *bmap, int div)
                        return 0;
        }
 
-       for (i = 0; i < bmap->n_div; ++i)
+       for (i = 0; i < bmap->n_div; ++i) {
+               if (isl_int_is_zero(bmap->div[i][0]))
+                       continue;
                if (!isl_int_is_zero(bmap->div[i][1+pos]))
                        return 0;
+       }
 
        return 1;
 }