isl_pw_*_fix_val: also plug in value in associated functions
authorSven Verdoolaege <skimo@kotnet.org>
Sun, 2 Jun 2013 08:57:15 +0000 (10:57 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 2 Jun 2013 08:58:35 +0000 (10:58 +0200)
The original code would only plug in the value in the domains.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_pw_templ.c
isl_test.c

index bb8d70e..3921c81 100644 (file)
@@ -1130,14 +1130,11 @@ __isl_give PW *FN(PW,fix_dim)(__isl_take PW *pw,
                return NULL;
        for (i = 0; i < pw->n; ++i) {
                pw->p[i].set = isl_set_fix(pw->p[i].set, type, pos, v);
-               if (!pw->p[i].set)
-                       goto error;
+               if (FN(PW,exploit_equalities_and_remove_if_empty)(pw, i) < 0)
+                       return FN(PW,free)(pw);
        }
 
        return pw;
-error:
-       FN(PW,free)(pw);
-       return NULL;
 }
 
 /* Fix the value of the variable at position "pos" of type "type" of "pw"
index 1e90cbd..eeb2fc3 100644 (file)
@@ -2112,6 +2112,20 @@ static int test_pwqp(struct isl_ctx *ctx)
        if (!equal)
                isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
 
+       str = "{ [a,b,c] -> (([(2*[a/3]+1)/5]) * ([(2*[c/3]+1)/5])) : b = 1 }";
+       pwqp2 = isl_pw_qpolynomial_read_from_str(ctx, str);
+       str = "{ [a,b,c] -> (([(2*[a/3]+b)/5]) * ([(2*[c/3]+b)/5])) }";
+       pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str);
+       pwqp1 = isl_pw_qpolynomial_fix_val(pwqp1, isl_dim_set, 1,
+                                               isl_val_one(ctx));
+       equal = isl_pw_qpolynomial_plain_is_equal(pwqp1, pwqp2);
+       isl_pw_qpolynomial_free(pwqp1);
+       isl_pw_qpolynomial_free(pwqp2);
+       if (equal < 0)
+               return -1;
+       if (!equal)
+               isl_die(ctx, isl_error_unknown, "unexpected result", return -1);
+
        return 0;
 }