isl_aff_scale: special case scaling by a factor of the denominator
authorSven Verdoolaege <skimo@kotnet.org>
Mon, 18 Feb 2013 10:37:43 +0000 (18 11:37 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Tue, 19 Feb 2013 18:39:55 +0000 (19 19:39 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_aff.c

index ae57b81..3acb3f5 100644 (file)
--- a/isl_aff.c
+++ b/isl_aff.c
@@ -1214,6 +1214,11 @@ __isl_give isl_aff *isl_aff_scale(__isl_take isl_aff *aff, isl_int f)
        if (!aff->v)
                return isl_aff_free(aff);
 
+       if (isl_int_is_pos(f) && isl_int_is_divisible_by(aff->v->el[0], f)) {
+               isl_int_divexact(aff->v->el[0], aff->v->el[0], f);
+               return aff;
+       }
+
        isl_int_init(gcd);
        isl_int_gcd(gcd, aff->v->el[0], f);
        isl_int_divexact(aff->v->el[0], aff->v->el[0], gcd);