From: Sven Verdoolaege Date: Thu, 23 Jun 2011 06:59:26 +0000 (+0200) Subject: isl_qpolynomial_is_equal: also compare spaces and divs X-Git-Tag: isl-0.07~29^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=72b82fadc9c81c43d3e34f93fd7f84d7b8c1348b;p=platform%2Fupstream%2Fisl.git isl_qpolynomial_is_equal: also compare spaces and divs Before, isl_qpolynomial_is_equal would only consider the "shape" of the polynomial, meaning that two polynomial living in different spaces could be considered equal. Worse, expressions in terms of different integer divisions could also be considered equal. We now take into account both space and divs so that we no longer produce false positives. Signed-off-by: Sven Verdoolaege --- diff --git a/isl_polynomial.c b/isl_polynomial.c index d8beffc..efc6974 100644 --- a/isl_polynomial.c +++ b/isl_polynomial.c @@ -1718,9 +1718,19 @@ error: int isl_qpolynomial_is_equal(__isl_keep isl_qpolynomial *qp1, __isl_keep isl_qpolynomial *qp2) { + int equal; + if (!qp1 || !qp2) return -1; + equal = isl_dim_equal(qp1->dim, qp2->dim); + if (equal < 0 || !equal) + return equal; + + equal = isl_mat_is_equal(qp1->div, qp2->div); + if (equal < 0 || !equal) + return equal; + return isl_upoly_is_equal(qp1->upoly, qp2->upoly); } diff --git a/isl_test.c b/isl_test.c index 01839c3..7e22279 100644 --- a/isl_test.c +++ b/isl_test.c @@ -1635,6 +1635,14 @@ void test_pwqp(struct isl_ctx *ctx) assert(isl_pw_qpolynomial_is_zero(pwqp1)); isl_pw_qpolynomial_free(pwqp1); + + str = "{ [i] -> ([i/2]) : i >= 0; [i] -> ([i/3]) : i < 0 }"; + pwqp1 = isl_pw_qpolynomial_read_from_str(ctx, str); + pwqp2 = isl_pw_qpolynomial_read_from_str(ctx, str); + pwqp1 = isl_pw_qpolynomial_coalesce(pwqp1); + pwqp1 = isl_pw_qpolynomial_sub(pwqp1, pwqp2); + assert(isl_pw_qpolynomial_is_zero(pwqp1)); + isl_pw_qpolynomial_free(pwqp1); } void test_split_periods(isl_ctx *ctx)