From: Matthias Braun Date: Wed, 4 Jul 2007 11:54:48 +0000 (+0000) Subject: be sure to not add a node twice to the bipartite matching X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=e1bb0cf4e9c560fdb9855543734f0dd854c630fc;p=libfirm be sure to not add a node twice to the bipartite matching [r14920] --- diff --git a/ir/be/bechordal.c b/ir/be/bechordal.c index 8aec639b5..d58e6d313 100644 --- a/ir/be/bechordal.c +++ b/ir/be/bechordal.c @@ -578,13 +578,25 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env, set of admissible registers via a bipartite graph. */ if(!op->partner || !pmap_contains(partners, op->partner->carrier)) { - pmap_insert(partners, op->carrier, - op->partner ? op->partner->carrier : NULL); + ir_node *partner = op->partner ? op->partner->carrier : NULL; + pmap_insert(partners, op->carrier, partner); + if(partner != NULL) + pmap_insert(partners, partner, op->carrier); + + /* don't insert a node twice */ + int i; + for(i = 0; i < n_alloc; ++i) { + if(alloc_nodes[i] == op->carrier) { + break; + } + } + if(i < n_alloc) + continue; alloc_nodes[n_alloc] = op->carrier; DBG((dbg, LEVEL_2, "\tassociating %+F and %+F\n", op->carrier, - op->partner ? op->partner->carrier : NULL)); + partner)); bitset_clear_all(bs); get_decisive_partner_regs(bs, op, op->partner); @@ -607,6 +619,7 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env, */ if(perm != NULL) { foreach_out_edge(perm, edge) { + int i; ir_node *proj = get_edge_src_irn(edge); assert(is_Proj(proj)); @@ -614,6 +627,16 @@ static ir_node *handle_constraints(be_chordal_alloc_env_t *alloc_env, if(!values_interfere(birg, proj, irn) || pmap_contains(partners, proj)) continue; + /* don't insert a node twice */ + for(i = 0; i < n_alloc; ++i) { + if(alloc_nodes[i] == proj) { + break; + } + } + if(i < n_alloc) + continue; + + assert(n_alloc < n_regs); alloc_nodes[n_alloc] = proj;