isl_printer_print_map: make printing order of disjuncts platform independent
authorSven Verdoolaege <skimo@kotnet.org>
Wed, 19 Jun 2013 07:04:39 +0000 (09:04 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 19 Jun 2013 07:04:39 +0000 (09:04 +0200)
In particular, the printing order is based on a sort of the affine hulls
of the disjuncts.  If some of these affine hulls are the same, then the
comparison routine will leave their order open.  Different implementations
of qsort may therefore produce different results.  By using isl_sort instead,
we can avoid this platform dependence.

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

index e9bc58f..deeb243 100644 (file)
@@ -25,6 +25,7 @@
 #include <isl_local_space_private.h>
 #include <isl_aff_private.h>
 #include <isl_ast_build_expr.h>
+#include <isl_sort.h>
 
 static const char *s_to[2] = { " -> ", " \\to " };
 static const char *s_and[2] = { " and ", " \\wedge " };
@@ -738,7 +739,7 @@ error:
        return NULL;
 }
 
-static int aff_split_cmp(const void *p1, const void *p2)
+static int aff_split_cmp(const void *p1, const void *p2, void *user)
 {
        const struct isl_aff_split *s1, *s2;
        s1 = (const struct isl_aff_split *) p1;
@@ -800,7 +801,9 @@ static __isl_give struct isl_aff_split *split_aff(__isl_keep isl_map *map)
                        goto error;
        }
 
-       qsort(split, map->n, sizeof(struct isl_aff_split), &aff_split_cmp);
+       if (isl_sort(split, map->n, sizeof(struct isl_aff_split),
+                       &aff_split_cmp, NULL) < 0)
+               goto error;
 
        n = map->n;
        for (i = n - 1; i >= 1; --i) {