Fixed liveness in loops an phi functions.
[libfirm] / ir / be / bephicoal.c
1 /**
2  * @author Daniel Grund
3  * @date 04.01.2005
4  */
5 #ifdef HAVE_CONFIG_H
6 #include "config.h"
7 #endif
8
9 #include <stdlib.h>
10
11 #include "obst.h"
12 #include "set.h"
13 #include "pset.h"
14 #include "bitset.h"
15 #include "debug.h"
16 #include "irouts.h"
17 #include "irdom.h"
18
19 #include "bechordal.h"
20 #include "belive_t.h"
21 #include "bera_t.h"
22 #include "phiclass_t.h"
23 #include "bephicoal_t.h"
24
25 #define DEBUG_LVL SET_LEVEL_3
26 #define MAX_COLORS 16
27
28 #define INITIAL_SLOTS_PINNED_GLOBAL 256
29 #define INITIAL_SLOTS_FREE_NODES    128
30 #define INITIAL_SLOTS_CHANGED_NODES 32
31
32 /* some things for readable code */
33 #define CHANGE_SAVE NULL
34 #define CHANGE_IMPOSSIBLE (ir_node *)1
35 #define CHANGE_NYI (ir_node *)2
36 #define is_conflicting_node(n) (((int)n) > 2)
37
38 /**
39  * Models conflicts between nodes. These may be life range conflicts or
40  * pinning conflicts which may occur while changing colors
41  */
42 typedef struct _conflict_t {
43         ir_node *n1, *n2;
44 } conflict_t;
45
46 /**
47  * If an irn is changed, the changes first get stored in a node_stat_t,
48  * to allow undo of changes in case of conflicts.
49  */
50 typedef struct _node_stat_t {
51         ir_node *irn;
52         int color;
53         int undo_color;
54         char status;            /**< Bit 0: pinned, Bit 1: removed */
55 } node_stat_t;
56
57 #define _set_pinned(nodestat)    nodestat->status |= 1
58 #define _set_removed(nodestat)   nodestat->status |= 2
59 #define _clear_pinned(nodestat)  nodestat->status &= 255 ^ 1
60 #define _clear_removed(nodestat) nodestat->status &= 255 ^ 2
61 #define _is_pinned(nodestat)     (nodestat->status & 1)
62 #define _is_removed(nodestat)    (nodestat->status & 2)
63
64 /**
65  * Central data structure. Contains infos needed during coalescing of the
66  * corresponding phi class.
67  */
68 typedef struct _phi_unit_t {
69         unsigned char phi_count;                        /**< the number of phi nodes in this unit */
70         /* 1 phi */
71         unsigned char node_count;                       /**< size of the nodes-array */
72         unsigned char conflict_count;           /**< size of the conflicts-array */
73         unsigned char conflict_count_org;       /**< initial size of the conflicts-array */
74         ir_node **nodes;                                        /**< [0] is the phi node. [1..node_count-1] the arguments of the phi not interfering with it */
75         conflict_t *conflicts;                          /**< pairs of conflicting ir_nodes. */
76         set *changed_nodes;                                     /**< contains node_stat_t's. */
77 } phi_unit_t;
78
79 static firm_dbg_module_t *dbgphi = NULL;
80
81 /**
82  * Contains ir_nodes of phi-classes whose colors may change unlimited times.
83  * These nodes are not optimizable, so there is no need to pin their color.
84  */
85 static pset *free_nodes = NULL;
86
87 /**
88  * Contains already optimized ir_nodes of phi-classes fully processed.
89  * So one can perform a check not to switch them twice or more.
90  */
91 static pset *pinned_global = NULL;
92
93 static int set_cmp_node_stat_t(const void *x, const void *y, size_t size) {
94         return ((node_stat_t *)x)->irn != ((node_stat_t *)y)->irn;
95 }
96
97 /**
98  * Finds a node status entry of a node if existent.
99  */
100 static INLINE node_stat_t *pu_find_node(phi_unit_t *pu, ir_node *irn) {
101         node_stat_t find;
102         find.irn = irn;
103         return set_find(pu->changed_nodes, &find, sizeof(find), HASH_PTR(irn));
104 }
105
106 /**
107  * Finds a node status entry of a node if existent. Otherwise it will return
108  * an initialized new entry for this node.
109  */
110 static INLINE node_stat_t *pu_find_or_insert_node(phi_unit_t *pu, ir_node *irn) {
111         node_stat_t find;
112         find.irn = irn;
113         find.color = NO_COLOR;
114         find.undo_color = NO_COLOR;
115         find.status = 0;
116         return set_insert(pu->changed_nodes, &find, sizeof(find), HASH_PTR(irn));
117 }
118
119 /**
120  * @return The virtual color of a node, if set before, else just the real color.
121  */
122 static INLINE int pu_get_new_color(phi_unit_t *pu, ir_node *irn) {
123         node_stat_t *found = pu_find_node(pu, irn);
124         if (found)
125                 return found->color;
126         else
127                 return get_irn_color(irn);
128 }
129
130 /**
131  * Sets the virtual color of a node.
132  */
133 static INLINE void pu_set_new_color(phi_unit_t *pu, ir_node *irn, int color) {
134         node_stat_t *found = pu_find_or_insert_node(pu, irn);
135         found->undo_color = found->color;
136         found->color = color;
137         DBG((dbgphi, LEVEL_4, "%n %d\n", irn, color));
138 }
139
140 /**
141  * Sets the virtual color of a node to the color it had,
142  * before the last call to pu_set_new_color
143  */
144 static INLINE void pu_undo_color(phi_unit_t *pu, ir_node *irn) {
145         node_stat_t *ns = pu_find_node(pu, irn);
146         assert(ns && "Nodes whose colors are undone must be in pu->changed_nodes");
147         ns->color = ns->undo_color;
148         DBG((dbgphi, LEVEL_3, "\t\tUndo: col(%n) := %d\n", irn, ns->undo_color));
149 }
150
151 /**
152  * Checks if a node is removed from consideration respectively building
153  * a maximum independent set.
154  */
155 static INLINE int pu_is_node_removed(phi_unit_t *pu, ir_node *irn) {
156         node_stat_t *found = pu_find_node(pu, irn);
157         if (found)
158                 return _is_removed(found);
159         else
160                 return 0;
161 }
162
163 /**
164  * Removes a node from the base set, out of which a maximum independet
165  * set gets build from.
166  */
167 static INLINE void pu_remove_node(phi_unit_t *pu, ir_node *irn) {
168         node_stat_t *found = pu_find_or_insert_node(pu, irn);
169         _set_removed(found);
170         DBG((dbgphi, LEVEL_4, "%n\n", irn));
171 }
172
173 /**
174  * Checks if a node is local pinned; i.e. it belongs to the same phi unit and
175  * has been optimized before the current processed one.
176  */
177 static INLINE int pu_is_node_pinned(phi_unit_t *pu, ir_node *irn) {
178         node_stat_t *found = pu_find_node(pu, irn);
179         if (found)
180                 return _is_pinned(found);
181         else
182                 return 0;
183 }
184
185 /**
186  * Local-pins a node, so optimizations of further nodes of the same phi unit
187  * can handle situations in which a color change would undo prior optimizations.
188  */
189 static INLINE void pu_pin_node(phi_unit_t *pu, ir_node *irn) {
190         node_stat_t *found = pu_find_or_insert_node(pu, irn);
191         _set_pinned(found);
192         DBG((dbgphi, LEVEL_4, "%n\n", irn));
193 }
194
195 /**
196  * If a local pinned conflict occurs, a new edge in the conflict graph is added.
197  * The next maximum independent set build, will regard it.
198  */
199 static INLINE void pu_add_conflict(phi_unit_t *pu, ir_node *n1, ir_node *n2) {
200         int count = pu->conflict_count;
201
202         DBG((dbgphi, LEVEL_3, "\t    %n -- %n\n", n1, n2));
203         assert(count != 255 && "Too much conflicts. Can hold max 255 entries");
204         if ((count & 15) == 0)
205                 pu->conflicts = realloc(pu->conflicts, (count + 16)*sizeof(*pu->conflicts));
206
207         if ((int)n1 < (int)n2) {
208                 pu->conflicts[count].n1 = n1;
209                 pu->conflicts[count].n2 = n2;
210         } else {
211                 pu->conflicts[count].n1 = n2;
212                 pu->conflicts[count].n2 = n1;
213         }
214
215         pu->conflict_count++;
216 }
217
218 /**
219  * Checks if two nodes are in a conflict.
220  */
221 static INLINE int pu_are_conflicting(phi_unit_t *pu, ir_node *n1, ir_node *n2) {
222         const ir_node *o1, *o2;
223         int i;
224
225         if ((int)n1 < (int)n2) {
226                 o1 = n1;
227                 o2 = n2;
228         } else {
229                 o1 = n2;
230                 o2 = n1;
231         }
232
233         for (i = 0; i < pu->conflict_count; ++i)
234                 if (pu->conflicts[i].n1 == o1 && pu->conflicts[i].n2 == o2)
235                         return 1;
236         return 0;
237 }
238
239 /**
240  * Determines a maximum independent set with respect to the conflict edges
241  * in pu->conflicts and the nodes beeing all non-removed nodes of pu->nodes.
242  * TODO: make this 'un-greedy'
243  * TODO: be aware that phi nodes should find their way in the set.
244  *       for 1 phi in greedy version this is no prob, cause is comes first at [0].
245  */
246 static int pu_get_max_ind_set(phi_unit_t *pu, struct obstack *res) {
247         int i, o, size = 0;
248         ir_node **mis;
249
250         DBG((dbgphi, LEVEL_2, "\t    Max indep set:\n"));
251         for (i = 0; i < pu->node_count; ++i) {
252                 int intf_det = 0;
253                 if (pu_is_node_removed(pu, pu->nodes[i]))
254                         continue;
255                 mis = (ir_node**) obstack_base(res);
256                 for (o = 0; o < size; ++o)
257                         if (phi_ops_interfere(pu->nodes[i], mis[o])) {
258                                 intf_det = 1;
259                                 break;
260                         }
261
262                 if (!intf_det) {
263                         DBG((dbgphi, LEVEL_2, "\t\t%n\n", pu->nodes[i]));
264                         obstack_ptr_grow(res, pu->nodes[i]);
265                         size++;
266                 }
267         }
268         return size;
269 }
270
271 /**
272  * Performs virtual re-coloring of node @p n to color @p col. Virtual colors of
273  * other nodes are changed too, as required to preserve correctness. Function is
274  * aware of local and global pinning. Recursive.
275  * @param  irn The node to set the color for
276  * @param  col The color to set.
277  * @param  trigger The irn that caused the wish to change the color of the irn
278  * @param  changed_nodes An obstack on which all ir_nodes get growed on, which are changed
279  * @return CHANGE_SAVE iff setting the color is possible, with all transiteve effects.
280  *         CHANGE_IMPOSSIBLE iff conflicts with reg-constraintsis occured.
281  *         CHANGE_NYI iff an unhandled situation occurs.
282  *         Else the first conflicting ir_node encountered is returned.
283  *
284  * ASSUMPTION: Assumes that a life range of a single value can't be spilt into
285  *                         several smaller intervals where other values can live in between.
286  */
287 static ir_node *_pu_color_irn(phi_unit_t *pu, ir_node *irn, int col, const ir_node *trigger, struct obstack *changed_nodes) {
288         ir_node *res;
289         struct obstack confl_ob;
290         ir_node **confl, *cn;
291         int i, irn_col;
292
293         DBG((dbgphi, LEVEL_3, "\t\t%n \tcaused col(%n) \t%2d --> %2d\n", trigger, irn, pu_get_new_color(pu, irn), col));
294         obstack_init(&confl_ob);
295         irn_col = pu_get_new_color(pu, irn);
296
297         if (irn_col == col)
298                 goto ret_save;
299         if (pset_find_ptr(pinned_global, irn) || pu_is_node_pinned(pu, irn)) {
300                 res = irn;
301                 goto ret_confl;
302         }
303
304         /* get all nodes which would conflict with this change */
305         {
306                 struct obstack q;
307                 int in, out;
308                 ir_node *irn_bl;
309
310                 irn_bl = get_nodes_block(irn);
311
312                 /* first check for a conflicting node which is 'living in' the irns block */
313                 {
314                         ir_node *n;
315                         pset *live_ins = get_live_in(irn_bl);
316                         for (n = pset_first(live_ins); n; n = pset_next(live_ins))
317                                 if (is_allocatable_irn(n) && n != trigger && pu_get_new_color(pu, n) == col && phi_ops_interfere(irn, n)) {
318                                         DBG((dbgphi, LEVEL_4, "\t\t    %n\ttroubles\n", n));
319                                         obstack_ptr_grow(&confl_ob, n);
320                                         pset_break(live_ins);
321                                         break;
322                                 }
323                 }
324
325                 /* setup the queue of blocks. */
326                 obstack_init(&q);
327                 obstack_ptr_grow(&q, irn_bl);
328                 in = 1;
329                 out = 0;
330
331                 /* process the queue. The code below looks for every block dominated
332                  * by the irns one, and in which the irn is live, if there are
333                  * conflicting nodes */
334                 while (out < in) {
335                         ir_node *curr_bl, *sub_bl;
336                         int i, max;
337
338                         curr_bl = ((ir_node **)obstack_base(&q))[out++];
339
340                         /* Add to the result all nodes in the block, which have
341                          * the target color and interfere with the irn */
342                         for (i = 0, max = get_irn_n_outs(curr_bl); i < max; ++i) {
343                                 ir_node *n = get_irn_out(curr_bl, i);
344                                 if (is_allocatable_irn(n) && n != trigger && pu_get_new_color(pu, n) == col && phi_ops_interfere(irn, n)) {
345                                         DBG((dbgphi, LEVEL_4, "\t\t    %n\ttroubles\n", n));
346                                         obstack_ptr_grow(&confl_ob, n);
347                                 }
348                         }
349
350                         /* If irn lives out check i-dominated blocks where the irn lives in */
351                         /* Fill the queue */
352                         if (is_live_out(curr_bl, irn)) {
353                                 dominates_for_each(curr_bl, sub_bl)
354                                         if (is_live_in(sub_bl, irn)) {
355                                                 obstack_ptr_grow(&q, sub_bl);
356                                                 in++;
357                                         }
358                         }
359                 }
360                 obstack_free(&q, NULL);
361                 obstack_ptr_grow(&confl_ob, NULL);
362                 confl = (ir_node **) obstack_finish(&confl_ob);
363         }
364
365         /* process all nodes which would conflict with this change */
366         for (i = 0, cn = confl[0]; cn; cn = confl[++i]) {
367                 ir_node *sub_res;
368
369                 /* try to color the conflicting node cn with the color of the irn itself */
370                 sub_res = _pu_color_irn(pu, cn, irn_col, irn, changed_nodes);
371                 if (sub_res != CHANGE_SAVE) {
372                         res = sub_res;
373                         goto ret_confl;
374                 }
375         }
376         /* if we arrive here all sub changes can be applied, so it's save to change this irn */
377
378 ret_save:
379         DBG((dbgphi, LEVEL_3, "\t\t%n save\n", irn));
380         obstack_free(&confl_ob, NULL);
381         pu_set_new_color(pu, irn, col);
382         obstack_ptr_grow(changed_nodes, irn);
383         return CHANGE_SAVE;
384
385 ret_confl:
386         DBG((dbgphi, LEVEL_3, "\t\t%n conflicting\n", irn));
387         obstack_free(&confl_ob, NULL);
388         return res;
389 }
390
391 static ir_node *pu_color_irn(phi_unit_t *pu, ir_node *irn, int col) {
392         ir_node *res;
393         struct obstack ob_undo;
394
395         obstack_init(&ob_undo);
396         res = _pu_color_irn(pu, irn, col, irn, &ob_undo);
397
398         if (res != CHANGE_SAVE) { /* undo virtual changes caused by the last call */
399                 int i;
400                 ir_node *undo_node, **undo_nodes;
401
402                 obstack_ptr_grow(&ob_undo, NULL);
403                 undo_nodes = obstack_finish(&ob_undo);
404                 for (i = 0, undo_node = undo_nodes[0]; undo_node; undo_node = undo_nodes[++i])
405                         pu_undo_color(pu, undo_node);
406         }
407
408         obstack_free(&ob_undo, NULL);
409         return res;
410 }
411
412 /**
413  * Tries to set as much members of a phi unit as possible to color @p col.
414  * All changes taken together are guaranteed to be conflict free.
415  */
416 static int pu_try_color(phi_unit_t *pu, int col, int b_size) {
417         struct obstack ob_mis;
418         int i, redo, mis_size;
419         ir_node **mis;
420
421         /* first init pessimistically. Just return if we can't get a better result */
422         mis_size = 0;
423
424         obstack_init(&ob_mis);
425         redo = 1;
426         while (redo) {
427                 int impossibles = 0;
428                 redo = 0;
429                 /* get a max independent set regarding current conflicts */
430                 mis_size = pu_get_max_ind_set(pu, &ob_mis);
431                 mis = obstack_finish(&ob_mis);
432
433                 /* shortcut: if mis size is worse than best, then mis won't be better. */
434                 if (mis_size < b_size)
435                         goto ret;
436
437                 /* check if its possible to set the color for all members of the maximum set*/
438                 for (i = 0; i < mis_size; ++i) {
439                         ir_node *test_node, *confl_node;
440
441                         test_node = mis[i];
442                         DBG((dbgphi, LEVEL_2, "\t    Testing %n\n", test_node));
443                         confl_node = pu_color_irn(pu, test_node, col);
444
445                         if (confl_node == CHANGE_SAVE) {
446                                 DBG((dbgphi, LEVEL_2, "\t    Save\n"));
447                                 if (!pset_find_ptr(free_nodes, test_node))
448                                         pu_pin_node(pu, test_node);
449                                 continue;
450                         } else {
451                                 DBG((dbgphi, LEVEL_2, "\t    Conflicting\n"));
452                                 /* adjust conflict graph */
453                                 if (is_conflicting_node(confl_node)) {
454                                         impossibles++;
455                                         if (pu_is_node_pinned(pu, confl_node)) {
456                                                 pu_add_conflict(pu, confl_node, test_node);
457                                                 redo = 1;
458                                         }
459                                         if (pset_find_ptr(pinned_global, confl_node)) {
460                                                 pu_remove_node(pu, test_node);
461                                                 redo = 1;
462                                         }
463                                 }
464                                 /* TODO: CHANGE_IMPOSSIBLE due to reg constraints --> remove from set ?? */
465                         }
466
467                         /* shortcut: color not possible for phi node (phi comes first) ==> exit */
468                         if (i == 0)
469                                 goto ret;
470
471                         /* shortcut: if the best size achievable with this mis is worse than best, then get another mis. */
472                         if (mis_size - impossibles < b_size) {
473                                 redo = 1;
474                                 break;
475                         }
476                 }
477                 obstack_free(&ob_mis, mis);
478         }
479
480 ret:
481         obstack_free(&ob_mis, NULL);
482         return mis_size;
483 }
484
485 /**
486  * Tries to re-allocate colors of nodes in this phi unit, to achieve a lower
487  * number of copy instructions placed during phi destruction. Optimized version.
488  * Works only for phi-classes/phi-units with exactly 1 phi node, which is the
489  * case for approximately 80% of all phi units.
490  */
491 static void pu_coalesce_1_phi(phi_unit_t *pu) {
492         int size, col, b_size, b_color;
493         set *b_changes;
494
495         /* init best search result */
496         b_changes = NULL;
497         b_size = 0;
498         b_color = NO_COLOR;
499
500         /* find optimum of all colors */
501         for (col = MAX_COLORS-1; col >= 0; --col) {
502                 DBG((dbgphi, 1, "\tTrying color %d\n", col));
503                 size = pu_try_color(pu, col, b_size);
504
505                 /* did we find a better max ind. set? */
506                 if (size > b_size) {
507                         DBG((dbgphi, 1, "\tBetter size: %d\n", size));
508                         if (b_changes)
509                                 del_set(b_changes);
510                         b_changes = pu->changed_nodes;
511                         b_size = size;
512                         b_color = col;
513                 } else {
514                         del_set(pu->changed_nodes);
515                 }
516
517                 /* reset the phi unit to original state for next color */
518                 pu->changed_nodes = new_set(set_cmp_node_stat_t, INITIAL_SLOTS_CHANGED_NODES);
519                 pu->conflict_count = pu->conflict_count_org;
520
521                 /* shortcut: if all members can be colored we are (very) happy */
522                 if (b_size == pu->node_count)
523                         break;
524         }
525
526         /* now apply the found optimum */
527         if (b_changes) {
528                 node_stat_t *ns;
529                 DBG((dbgphi, 1, "\tBest color: %d  Copies: %d/%d\n", b_color, pu->node_count-b_size, pu->node_count-1));
530                 for (ns = set_first(b_changes); ns; ns = set_next(b_changes)) {
531                         /* NO_COLOR is possible, if we had an undo; so the irn stays in the
532                          * pu->changed_nodes with new color set to NO_COLOR. */
533                         if (ns->color != NO_COLOR) {
534                                 DBG((dbgphi, 1, "\t    color(%n) := %d\n", ns->irn, ns->color));
535                                 set_irn_color(ns->irn, ns->color);
536                         }
537                 }
538                 free(b_changes);
539         } else {
540                 DBG((dbgphi, 1, "\tBest color: none\n"));
541         }
542 }
543
544 /**
545  * Tries to re-allocate colors of nodes in this phi unit, to achieve a lower
546  * number of copy instructions placed during phi destruction.
547  * General purpose version.
548  */
549 static void pu_coalesce_n_phi(phi_unit_t *pu) {
550         /* TODO */
551 }
552
553 /**
554  * Prepares a phi class for further processing as a phi unit.
555  * @param pc The phi class to prepare.
556  * @return A so called phi unit containing some prepared informations
557  *         needed by the following coalescing phase.
558  */
559 static phi_unit_t *new_pu(pset *pc) {
560         phi_unit_t *pu;
561         ir_node *n, *phi = NULL;
562
563         /* get the phi count of this class */
564         pu = calloc(1, sizeof(*pu));
565         for (n = pset_first(pc); n; n = pset_next(pc))
566                 if (is_Phi(n)) {
567                         phi = n;
568                         pu->phi_count++;
569                 }
570
571         if (pu->phi_count == 1) {
572                 ir_node **tmp;
573                 int i, o;
574                 struct obstack ob;
575
576                 obstack_init(&ob);
577
578                 /* build member set not containing phi interferers */
579                 DBG((dbgphi, 1, "\tPhi-1 class:\n"));
580                 pu->node_count = 1; /*for the phi*/
581                 for (n = pset_first(pc); n; n = pset_next(pc)) {
582                         if (is_Phi(n))
583                                 continue;
584                         if (!phi_ops_interfere(phi, n)) {
585                                 DBG((dbgphi, 1, "\t    %n\n", n));
586                                 obstack_ptr_grow(&ob, n);
587                                 pu->node_count++;
588                         } else {
589                                 DBG((dbgphi, 1, "\t    %n \tdropped\n", n));
590                                 pset_insert_ptr(free_nodes, n);
591                         }
592                 }
593                 tmp = obstack_finish(&ob);
594                 pu->nodes = malloc(pu->node_count * sizeof(*pu->nodes));
595                 pu->nodes[0] = phi;
596                 memcpy(&pu->nodes[1], tmp, (pu->node_count-1) * sizeof(*tmp));
597
598                 /* init conlict graph to life range interference */
599                 DBG((dbgphi, 1, "\tInitial conflicts:\n"));
600                 for (i = 0; i < pu->node_count; ++i)
601                         for (o = i+1; o < pu->node_count; ++o)
602                                 if (phi_ops_interfere(pu->nodes[i], pu->nodes[o]))
603                                         pu_add_conflict(pu, pu->nodes[i], pu->nodes[o]);
604                 pu->conflict_count_org = pu->conflict_count;
605
606                 pu->changed_nodes = new_set(set_cmp_node_stat_t, INITIAL_SLOTS_CHANGED_NODES);
607
608                 obstack_free(&ob, NULL);
609         } else {
610                 DBG((dbgphi, 1, "\tPhi-n class:\n"));
611                 /* TODO */
612         }
613
614         return pu;
615 }
616
617
618 /**
619  * Deletes a phi unit
620  */
621 static void free_pu(phi_unit_t *pu) {
622         if (pu->phi_count == 1) {
623                 free(pu->nodes);
624                 free(pu->changed_nodes);
625                 if (pu->conflicts)
626                         free(pu->conflicts);
627         } else {
628                 /* TODO */
629         }
630         free(pu);
631 }
632
633
634 void be_phi_coalesce(pset *all_phi_classes) {
635         pset *pc;
636
637         pinned_global = pset_new_ptr(INITIAL_SLOTS_PINNED_GLOBAL);
638         free_nodes = pset_new_ptr(INITIAL_SLOTS_FREE_NODES);
639
640         for (pc = pset_first(all_phi_classes); pc; pc = pset_next(all_phi_classes)) {
641                 phi_unit_t *pu = new_pu(pc);
642                 if (pu->phi_count == 1)
643                         pu_coalesce_1_phi(pu);
644                 else
645                         pu_coalesce_n_phi(pu);
646                 free_pu(pu);
647         }
648
649         del_pset(free_nodes);
650         del_pset(pinned_global);
651 }
652
653
654 void be_phi_coal_init(void) {
655         dbgphi = firm_dbg_register("ir.be.phicoal");
656         firm_dbg_set_mask(dbgphi, DEBUG_LVL);
657 }