isl_tab_pip.c: add_div: use more reliable way to test whether div is nonneg
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 17 Sep 2009 13:40:46 +0000 (15:40 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Fri, 9 Oct 2009 17:56:02 +0000 (19:56 +0200)
Before, we used the fact that if all parameters are non-negative,
then the big parameter is not used.
However, it is perfectly valid to have negative parameters and
still not use any big parameter.

isl_tab_pip.c

index 5886fd7..7563a4e 100644 (file)
@@ -1335,14 +1335,24 @@ static int add_div(struct isl_tab *tab, struct isl_tab **context_tab,
        int i;
        int r;
        int k;
+       int nonneg;
        struct isl_mat *samples;
 
+       for (i = 0; i < (*context_tab)->n_var; ++i) {
+               if (isl_int_is_zero(div->el[2 + i]))
+                       continue;
+               if (!(*context_tab)->var[i].is_nonneg)
+                       break;
+       }
+       nonneg = i == (*context_tab)->n_var;
+
        if (isl_tab_extend_vars(*context_tab, 1) < 0)
                goto error;
        r = isl_tab_allocate_var(*context_tab);
        if (r < 0)
                goto error;
-       (*context_tab)->var[r].is_nonneg = 1;
+       if (nonneg)
+               (*context_tab)->var[r].is_nonneg = 1;
        (*context_tab)->var[r].frozen = 1;
 
        samples = isl_mat_extend((*context_tab)->samples,
@@ -1373,7 +1383,7 @@ static int add_div(struct isl_tab *tab, struct isl_tab **context_tab,
        r = isl_tab_allocate_var(tab);
        if (r < 0)
                goto error;
-       if (!(*context_tab)->M)
+       if (nonneg)
                tab->var[r].is_nonneg = 1;
        tab->var[r].frozen = 1;
        tab->n_div++;