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>
Tue, 16 Apr 2013 09:49:05 +0000 (11:49 +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 34d6094..618d7df 100644 (file)
@@ -1333,9 +1333,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;
 }