make heur4 a bit more deterministic
authorMatthias Braun <matthias.braun@kit.edu>
Wed, 27 Jun 2012 10:45:04 +0000 (12:45 +0200)
committerMatthias Braun <matthias.braun@kit.edu>
Wed, 27 Jun 2012 11:01:24 +0000 (13:01 +0200)
ir/be/becopyheur4.c

index ad5ca80..6e228ff 100644 (file)
@@ -312,7 +312,13 @@ static __attribute__((unused)) int cmp_col_cost_lt(const void *a, const void *b)
        const col_cost_t *c1 = (const col_cost_t*)a;
        const col_cost_t *c2 = (const col_cost_t*)b;
        real_t diff = c1->cost - c2->cost;
-       return (diff > 0) - (diff < 0);
+
+       if (diff < 0)
+               return 1;
+       if (diff > 0)
+               return -1;
+
+       return QSORT_CMP(c1->col, c2->col);
 }
 
 static int cmp_col_cost_gt(const void *a, const void *b)
@@ -321,10 +327,12 @@ static int cmp_col_cost_gt(const void *a, const void *b)
        const col_cost_t *c2 = (const col_cost_t*)b;
        real_t diff = c2->cost - c1->cost;
 
-       if (diff == 0.0)
-               return QSORT_CMP(c1->col, c2->col);
+       if (diff > 0)
+               return 1;
+       if (diff < 0)
+               return -1;
 
-       return (diff > 0) - (diff < 0);
+       return QSORT_CMP(c1->col, c2->col);
 }
 
 /**