-static int aff_chunk_absorb(co_mst_env_t *env, aff_chunk_t *c1, aff_chunk_t *c2) {
- DB((dbg, LEVEL_4, "Attempt to let c1 (id %d): ", c1->id));
- DBG_AFF_CHUNK(env, LEVEL_4, c1);
- DB((dbg, LEVEL_4, "\n\tabsorb c2 (id %d): ", c2->id));
- DBG_AFF_CHUNK(env, LEVEL_4, c2);
- DB((dbg, LEVEL_4, "\n"));
-
- if (c1 != c2 && ! aff_chunks_interfere(env, c1, c2)) {
+static int aff_chunk_absorb(co_mst_env_t *env, ir_node *src, ir_node *tgt) {
+ aff_chunk_t *c1 = get_aff_chunk(env, src);
+ aff_chunk_t *c2 = get_aff_chunk(env, tgt);
+
+ DEBUG_ONLY(
+ DB((dbg, LEVEL_4, "Attempt to let c1 (id %d): ", c1 ? c1->id : -1));
+ if (c1) {
+ DBG_AFF_CHUNK(env, LEVEL_4, c1);
+ } else {
+ DB((dbg, LEVEL_4, "{%+F}", src));
+ }
+ DB((dbg, LEVEL_4, "\n\tabsorb c2 (id %d): ", c2 ? c2->id : -1));
+ if (c2) {
+ DBG_AFF_CHUNK(env, LEVEL_4, c2);
+ } else {
+ DB((dbg, LEVEL_4, "{%+F}", tgt));
+ }
+ DB((dbg, LEVEL_4, "\n"));
+ )
+
+ if (c1 == NULL) {
+ if (c2 == NULL) {
+ /* no chunk exists */
+ co_mst_irn_t *mirn = get_co_mst_irn(env, src);
+ int i;
+
+ for (i = mirn->n_neighs - 1; i >= 0; --i) {
+ if (mirn->int_neighs[i] == tgt)
+ break;
+ }
+ if (i < 0) {
+ /* create one containing both nodes */
+ c1 = new_aff_chunk(env);
+ aff_chunk_add_node(c1, get_co_mst_irn(env, src));
+ aff_chunk_add_node(c1, get_co_mst_irn(env, tgt));
+ goto absorbed;
+ }
+ } else {
+ /* c2 already exists */
+ if (! aff_chunk_interferes(env, c2, src)) {
+ aff_chunk_add_node(c2, get_co_mst_irn(env, src));
+ goto absorbed;
+ }
+ }
+ } else if (c2 == NULL) {
+ /* c1 already exists */
+ if (! aff_chunk_interferes(env, c1, tgt)) {
+ aff_chunk_add_node(c1, get_co_mst_irn(env, tgt));
+ goto absorbed;
+ }
+ } else if (c1 != c2 && ! aff_chunks_interfere(env, c1, c2)) {