X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=heuristical.c;h=7605ffb580acf47e627893f143695cb7afb549c2;hb=b3b7cacd85e6ac3ff0c7c6e223ce95e46eadb569;hp=4fb18ce36b99294e374cf9efbc303b180253d09d;hpb=8e18a63a58127a126bc06fd42e9240f4d2bbb2a7;p=libfirm diff --git a/heuristical.c b/heuristical.c index 4fb18ce36..7605ffb58 100644 --- a/heuristical.c +++ b/heuristical.c @@ -17,6 +17,13 @@ static pbqp_node **node_buckets[4]; static pbqp_node **reduced_bucket = NULL; static int buckets_filled = 0; +static num add(num x, num y) +{ + if (x == INF_COSTS || y == INF_COSTS) return INF_COSTS; + + return x + y; +} + static void init_buckets(void) { int i; @@ -96,7 +103,8 @@ static void normalize_towards_source(pbqp *pbqp, pbqp_edge *edge) if (min != 0) { pbqp_matrix_sub_row_value(mat, src_index, tgt_vec, min); - src_vec->entries[src_index].data += min; + src_vec->entries[src_index].data = add( + src_vec->entries[src_index].data, min); // TODO add to edge_list if inf } @@ -140,7 +148,8 @@ static void normalize_towards_target(pbqp *pbqp, pbqp_edge *edge) if (min != 0) { pbqp_matrix_sub_col_value(mat, tgt_index, src_vec, min); - tgt_vec->entries[tgt_index].data += min; + tgt_vec->entries[tgt_index].data = add( + tgt_vec->entries[tgt_index].data, min); // TODO add to edge_list if inf } @@ -279,7 +288,7 @@ void solve_pbqp_heuristical(pbqp *pbqp) pbqp_edge *edge = edges[edge_index]; /* Simplify only once per edge. */ - if (node_index != edge->src->index) continue; + if (node != edge->src) continue; simplify_edge(pbqp, edge); } @@ -314,7 +323,8 @@ void solve_pbqp_heuristical(pbqp *pbqp) assert(node); node->solution = vector_get_min_index(node->costs); - pbqp->solution += node->costs->entries[node->solution].data; + pbqp->solution = add(pbqp->solution, + node->costs->entries[node->solution].data); if (pbqp->dump_file) { fprintf(pbqp->dump_file, "node n%d is set to %d
\n", node->index, node->solution); dump_node(pbqp, node);