isl_scheduler.c: extract out shared extract_var_coef
[isl.git] / isl_multi_cmp.c
bloba99d3707a579b41adc64d9bc80ad5c6f53a60852
1 /*
2 * Copyright 2016 Sven Verdoolaege
4 * Use of this software is governed by the MIT license
6 * Written by Sven Verdoolaege
7 */
9 #include <isl_multi_macro.h>
11 /* Compare two multi expressions.
13 * Return -1 if "multi1" is "smaller" than "multi2", 1 if "multi1" is "greater"
14 * than "multi2" and 0 if they are equal.
16 int FN(MULTI(BASE),plain_cmp)(__isl_keep MULTI(BASE) *multi1,
17 __isl_keep MULTI(BASE) *multi2)
19 int i;
20 int cmp;
22 if (multi1 == multi2)
23 return 0;
24 if (!multi1)
25 return -1;
26 if (!multi2)
27 return 1;
29 cmp = isl_space_cmp(multi1->space, multi2->space);
30 if (cmp != 0)
31 return cmp;
33 for (i = 0; i < multi1->n; ++i) {
34 cmp = FN(EL,plain_cmp)(multi1->p[i], multi2->p[i]);
35 if (cmp != 0)
36 return cmp;
39 return 0;