BugFix for a rare case:
[libfirm] / ir / opt / scalar_replace.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Scalar replacement of compounds.
23  * @author  Beyhan Veliev, Michael Beck
24  * @version $Id$
25  */
26 #include "config.h"
27
28 #include <string.h>
29
30 #include "iroptimize.h"
31 #include "scalar_replace.h"
32 #include "irflag_t.h"
33 #include "irouts.h"
34 #include "set.h"
35 #include "pset.h"
36 #include "array.h"
37 #include "tv.h"
38 #include "ircons_t.h"
39 #include "hashptr.h"
40 #include "irgwalk.h"
41 #include "irgmod.h"
42 #include "irnode_t.h"
43 #include "irtools.h"
44 #include "xmalloc.h"
45 #include "debug.h"
46 #include "error.h"
47
48 #define SET_VNUM(node, vnum) set_irn_link(node, INT_TO_PTR(vnum))
49 #define GET_VNUM(node)       (unsigned)PTR_TO_INT(get_irn_link(node))
50
51 /**
52  * A path element entry: it is either an entity
53  * or a tarval, because we evaluate only constant array
54  * accesses like a.b.c[8].d
55  */
56 typedef union {
57         ir_entity *ent;
58         tarval *tv;
59 } path_elem_t;
60
61 /**
62  * An access path, used to assign value numbers
63  * to variables that will be scalar replaced.
64  */
65 typedef struct _path_t {
66         unsigned    vnum;      /**< The value number. */
67         unsigned    path_len;  /**< The length of the access path. */
68         path_elem_t path[1];   /**< The path. */
69 } path_t;
70
71 /** The size of a path in bytes. */
72 #define PATH_SIZE(p)  (sizeof(*(p)) + sizeof((p)->path[0]) * ((p)->path_len - 1))
73
74 typedef struct _scalars_t {
75         ir_entity *ent;              /**< A entity for scalar replacement. */
76         ir_type *ent_owner;          /**< The owner of this entity. */
77 } scalars_t;
78
79 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
80
81 /**
82  * Compare two pathes.
83  *
84  * @return 0 if they are identically
85  */
86 static int path_cmp(const void *elt, const void *key, size_t size) {
87         const path_t *p1 = elt;
88         const path_t *p2 = key;
89         (void) size;
90
91         /* we can use memcmp here, because identical tarvals should have identical addresses */
92         return memcmp(p1->path, p2->path, p1->path_len * sizeof(p1->path[0]));
93 }
94
95 /**
96  * Compare two elements of the scalars_t set.
97  *
98  * @return 0 if they are identically
99  */
100 static int ent_cmp(const void *elt, const void *key, size_t size) {
101         const scalars_t *c1 = elt;
102         const scalars_t *c2 = key;
103         (void) size;
104
105         return c1->ent != c2->ent;
106 }
107
108 /**
109  * Calculate a hash value for a path.
110  */
111 static unsigned path_hash(const path_t *path) {
112         unsigned hash = 0;
113         unsigned i;
114
115         for (i = 0; i < path->path_len; ++i)
116                 hash ^= (unsigned)PTR_TO_INT(path->path[i].ent);
117
118         return hash >> 4;
119 }
120
121 /**
122  * Returns non-zero, if all indeces of a Sel node are constants.
123  *
124  * @param sel  the Sel node that will be checked
125  */
126 static int is_const_sel(ir_node *sel) {
127         int i, n = get_Sel_n_indexs(sel);
128
129         for (i = 0; i < n; ++i) {
130                 ir_node *idx = get_Sel_index(sel, i);
131
132                 if (!is_Const(idx))
133                         return 0;
134         }
135         return 1;
136 }
137
138 /**
139  * Check the mode of a Load/Store with the mode of the entity
140  * that is accessed.
141  * If the mode of the entity and the Load/Store mode do not match, we
142  * have the bad reinterpret case:
143  *
144  * int i;
145  * char b = *(char *)&i;
146  *
147  * We do NOT count this as one value and return address_taken
148  * in that case.
149  * However, we support an often used case. If the mode is two-complement
150  * we allow casts between signed/unsigned.
151  *
152  * @param mode     the mode of the Load/Store
153  * @param ent_mode the mode of the accessed entity
154  */
155 static int check_load_store_mode(ir_mode *mode, ir_mode *ent_mode) {
156         if (ent_mode != mode) {
157                 if (ent_mode == NULL ||
158                     get_mode_size_bits(ent_mode) != get_mode_size_bits(mode) ||
159                     get_mode_sort(ent_mode) != get_mode_sort(mode) ||
160                     get_mode_arithmetic(ent_mode) != irma_twos_complement ||
161                     get_mode_arithmetic(mode) != irma_twos_complement)
162                         return 0;
163         }
164         return 1;
165 }
166
167 /*
168  * Returns non-zero, if the address of an entity
169  * represented by a Sel node (or it's successor Sels) is taken.
170  */
171 int is_address_taken(ir_node *sel)
172 {
173         int       i, input_nr, k;
174         ir_mode   *emode, *mode;
175         ir_node   *value;
176         ir_entity *ent;
177
178         if (! is_const_sel(sel))
179                 return 1;
180
181         for (i = get_irn_n_outs(sel) - 1; i >= 0; --i) {
182                 ir_node *succ = get_irn_out(sel, i);
183
184                 switch (get_irn_opcode(succ)) {
185                 case iro_Load:
186                         /* do not remove volatile variables */
187                         if (get_Load_volatility(succ) == volatility_is_volatile)
188                                 return 1;
189                         /* check if this load is not a hidden conversion */
190                         mode = get_Load_mode(succ);
191                         ent = get_Sel_entity(sel);
192                         emode = get_type_mode(get_entity_type(ent));
193                         if (! check_load_store_mode(mode, emode))
194                                 return 1;
195                         break;
196
197                 case iro_Store:
198                         /* check that Sel is not the Store's value */
199                         value = get_Store_value(succ);
200                         if (value == sel)
201                                 return 1;
202                         /* do not remove volatile variables */
203                         if (get_Store_volatility(succ) == volatility_is_volatile)
204                                 return 1;
205                         /* check if this Store is not a hidden conversion */
206                         mode = get_irn_mode(value);
207                         ent = get_Sel_entity(sel);
208                         emode = get_type_mode(get_entity_type(ent));
209                         if (! check_load_store_mode(mode, emode))
210                                 return 1;
211                         break;
212
213                 case iro_Sel: {
214                         /* Check the Sel successor of Sel */
215                         int res = is_address_taken(succ);
216
217                         if (res)
218                                 return 1;
219                         break;
220                 }
221
222                 case iro_Call:
223                         /* The address of an entity is given as a parameter.
224                          * As long as we do not have analyses that can tell what
225                          * is done with parameters, think is taken.
226                          * One special case: If the Call type tells that it's a
227                          * value parameter, the address is NOT taken.
228                          */
229                         return 1;
230
231                 case iro_Id: {
232                         int res = is_address_taken(succ);
233                         if (res)
234                                 return 1;
235                         break;
236                 }
237
238                 case iro_Tuple:
239                         /* Non-optimized Tuple, happens in inlining */
240                         for (input_nr = get_Tuple_n_preds(succ) - 1; input_nr >= 0; --input_nr) {
241                                 ir_node *pred = get_Tuple_pred(succ, input_nr);
242
243                                 if (pred == sel) {
244                                         /* we found one input */
245                                         for (k = get_irn_n_outs(succ) - 1; k >= 0; --k) {
246                                                 ir_node *proj = get_irn_out(succ, k);
247
248                                                 if (is_Proj(proj) && get_Proj_proj(proj) == input_nr) {
249                                                         int res = is_address_taken(proj);
250                                                         if (res)
251                                                                 return 1;
252                                                 }
253                                         }
254                                 }
255                         }
256                         break;
257
258                 default:
259                         /* another op, the address is taken */
260                         return 1;
261                 }
262         }
263         return 0;
264 }
265
266 /**
267  * Link all leave Sels with the entity.
268  *
269  * @param ent  the entity that will be scalar replaced
270  * @param sel  a Sel node that selects some fields of this entity
271  *
272  * Uses the visited flag to mark already linked Sel nodes.
273  */
274 static void link_all_leave_sels(ir_entity *ent, ir_node *sel) {
275         int i, flag = 1;
276
277         for (i = get_irn_n_outs(sel) - 1; i >= 0; --i) {
278                 ir_node *succ = get_irn_out(sel, i);
279
280                 if (is_Sel(succ)) {
281                         link_all_leave_sels(ent, succ);
282                         flag = 0;
283                 }
284         }
285
286         if (flag) {
287                 /* if Sel nodes with memory inputs are used, a entity can be
288                  * visited more than once causing a ring here, so we use the
289                  * node flag to mark linked nodes
290                  */
291                 if (irn_visited_else_mark(sel))
292                         return;
293
294                 /* we know we are at a leave, because this function is only
295                  * called if the address is NOT taken, so succ must be a Load
296                  * or a Store node
297                  */
298                 set_irn_link(sel, get_entity_link(ent));
299                 set_entity_link(ent, sel);
300         }
301 }
302
303 /* we need a special address that serves as an address taken marker */
304 static char _x;
305 static void *ADDRESS_TAKEN = &_x;
306
307 /**
308  * Find possible scalar replacements.
309  *
310  * @param irg  an IR graph
311  *
312  * This function finds variables on the (members of the) frame type
313  * that can be scalar replaced, because their address is never taken.
314  * If such a variable is found, it's entity link will hold a list of all
315  * Sel nodes, that selects the atomic fields of this entity.
316  * Otherwise, the link will be ADDRESS_TAKEN or NULL.
317  *
318  * @return  non-zero if at least one entity could be replaced
319  *          potentially
320  */
321 static int find_possible_replacements(ir_graph *irg) {
322         ir_node *irg_frame;
323         ir_type *frame_tp;
324         int     i;
325         int     res = 0;
326
327         ir_reserve_resources(irg, IR_RESOURCE_IRN_VISITED);
328         inc_irg_visited(irg);
329
330         /*
331          * First, clear the link field of all interesting entities.
332          */
333         frame_tp = get_irg_frame_type(irg);
334         for (i = get_class_n_members(frame_tp) - 1; i >= 0; --i) {
335                 ir_entity *ent = get_class_member(frame_tp, i);
336                 set_entity_link(ent, NULL);
337         }
338
339         /*
340          * Check the ir_graph for Sel nodes. If the entity of Sel
341          * isn't a scalar replacement set the link of this entity
342          * equal ADDRESS_TAKEN.
343          */
344         irg_frame = get_irg_frame(irg);
345         for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) {
346                 ir_node *succ = get_irn_out(irg_frame, i);
347
348                 if (is_Sel(succ)) {
349                         ir_entity *ent = get_Sel_entity(succ);
350                         ir_type *ent_type;
351
352                         if (get_entity_link(ent) == ADDRESS_TAKEN)
353                                 continue;
354
355                         /*
356                          * Beware: in rare cases even entities on the frame might be
357                          * volatile. This might happen if the entity serves as a store
358                          * to a value that must survive a exception. Do not optimize
359                          * such entities away.
360                          */
361                         if (get_entity_volatility(ent) == volatility_is_volatile) {
362                                 set_entity_link(ent, ADDRESS_TAKEN);
363                                 continue;
364                         }
365
366                         ent_type = get_entity_type(ent);
367
368                         /* we can handle arrays, structs and atomic types yet */
369                         if (is_Array_type(ent_type) || is_Struct_type(ent_type) || is_atomic_type(ent_type)) {
370                                 if (is_address_taken(succ)) {
371                                         if (get_entity_link(ent)) /* killing one */
372                                                 --res;
373                                         set_entity_link(ent, ADDRESS_TAKEN);
374                                 } else {
375                                         /* possible found one */
376                                         if (get_entity_link(ent) == NULL)
377                                                 ++res;
378                                         link_all_leave_sels(ent, succ);
379                                 }
380                         }
381                 }
382         }
383
384         ir_free_resources(irg, IR_RESOURCE_IRN_VISITED);
385         return res;
386 }
387
388 /**
389  * Return a path from the Sel node sel to it's root.
390  *
391  * @param sel  the Sel node
392  * @param len  the length of the path so far
393  */
394 static path_t *find_path(ir_node *sel, unsigned len) {
395         int pos, i, n;
396         path_t *res;
397         ir_node *pred = get_Sel_ptr(sel);
398
399         /* the current Sel node will add some path elements */
400         n    = get_Sel_n_indexs(sel);
401         len += n + 1;
402
403         if (! is_Sel(pred)) {
404                 /* we found the root */
405                 res = XMALLOCF(path_t, path, len);
406                 res->path_len = len;
407         } else
408                 res = find_path(pred, len);
409
410         pos = res->path_len - len;
411
412         res->path[pos++].ent = get_Sel_entity(sel);
413         for (i = 0; i < n; ++i) {
414                 ir_node *index = get_Sel_index(sel, i);
415
416                 res->path[pos++].tv = get_Const_tarval(index);
417         }
418         return res;
419 }
420
421
422 /**
423  * Allocate value numbers for the leaves
424  * in our found entities.
425  *
426  * @param sels  a set that will contain all Sels that have a value number
427  * @param ent   the entity that will be scalar replaced
428  * @param vnum  the first value number we can assign
429  * @param modes a flexible array, containing all the modes of
430  *              the value numbers.
431  *
432  * @return the next free value number
433  */
434 static unsigned allocate_value_numbers(pset *sels, ir_entity *ent, unsigned vnum, ir_mode ***modes)
435 {
436         ir_node *sel, *next;
437         path_t *key, *path;
438         set *pathes = new_set(path_cmp, 8);
439
440         DB((dbg, SET_LEVEL_3, "  Visiting Sel nodes of entity %+F\n", ent));
441         /* visit all Sel nodes in the chain of the entity */
442         for (sel = get_entity_link(ent); sel; sel = next) {
443                 next = get_irn_link(sel);
444
445                 /* we must mark this sel for later */
446                 pset_insert_ptr(sels, sel);
447
448                 key  = find_path(sel, 0);
449                 path = set_find(pathes, key, PATH_SIZE(key), path_hash(key));
450
451                 if (path) {
452                         SET_VNUM(sel, path->vnum);
453                         DB((dbg, SET_LEVEL_3, "  %+F represents value %u\n", sel, path->vnum));
454                 } else {
455                         key->vnum = vnum++;
456
457                         set_insert(pathes, key, PATH_SIZE(key), path_hash(key));
458
459                         SET_VNUM(sel, key->vnum);
460                         DB((dbg, SET_LEVEL_3, "  %+F represents value %u\n", sel, key->vnum));
461
462                         ARR_EXTO(ir_mode *, *modes, (int)((key->vnum + 15) & ~15));
463
464                         (*modes)[key->vnum] = get_type_mode(get_entity_type(get_Sel_entity(sel)));
465
466                         assert((*modes)[key->vnum] && "Value is not atomic");
467
468 #ifdef DEBUG_libfirm
469                         /* Debug output */
470                         {
471                                 unsigned i;
472                                 DB((dbg, SET_LEVEL_2, "  %s", get_entity_name(key->path[0].ent)));
473                                 for (i = 1; i < key->path_len; ++i) {
474                                         if (is_entity(key->path[i].ent))
475                                                 DB((dbg, SET_LEVEL_2, ".%s", get_entity_name(key->path[i].ent)));
476                                         else
477                                                 DB((dbg, SET_LEVEL_2, "[%ld]", get_tarval_long(key->path[i].tv)));
478                                 }
479                                 DB((dbg, SET_LEVEL_2, " = %u (%s)\n", PTR_TO_INT(get_irn_link(sel)), get_mode_name((*modes)[key->vnum])));
480                         }
481 #endif /* DEBUG_libfirm */
482                 }
483                 free(key);
484         }
485
486         del_set(pathes);
487         set_entity_link(ent, NULL);
488         return vnum;
489 }
490
491 /**
492  * A list entry for the fixing lists
493  */
494 typedef struct _list_entry_t {
495         ir_node  *node;   /**< the node that must be fixed */
496         unsigned vnum;    /**< the value number of this node */
497 } list_entry_t;
498
499 /**
500  * environment for memory walker
501  */
502 typedef struct _env_t {
503         int          nvals;       /**< number of values */
504         ir_mode      **modes;     /**< the modes of the values */
505         pset         *sels;       /**< A set of all Sel nodes that have a value number */
506 } env_t;
507
508 /**
509  * topological post-walker.
510  */
511 static void topologic_walker(ir_node *node, void *ctx) {
512         env_t        *env = ctx;
513         ir_node      *adr, *block, *mem, *val;
514         ir_mode      *mode;
515         unsigned     vnum;
516
517         if (is_Load(node)) {
518                 /* a load, check if we can resolve it */
519                 adr = get_Load_ptr(node);
520
521                 DB((dbg, SET_LEVEL_3, "  checking %+F for replacement ", node));
522                 if (! is_Sel(adr)) {
523                         DB((dbg, SET_LEVEL_3, "no Sel input (%+F)\n", adr));
524                         return;
525                 }
526
527                 if (! pset_find_ptr(env->sels, adr)) {
528                         DB((dbg, SET_LEVEL_3, "Sel %+F has no VNUM\n", adr));
529                         return;
530                 }
531
532                 /* ok, we have a Load that will be replaced */
533                 vnum = GET_VNUM(adr);
534                 assert(vnum < (unsigned)env->nvals);
535
536                 DB((dbg, SET_LEVEL_3, "replacing by value %u\n", vnum));
537
538                 block = get_nodes_block(node);
539                 set_cur_block(block);
540
541                 /* check, if we can replace this Load */
542                 val = get_value(vnum, env->modes[vnum]);
543
544                 /* Beware: A Load can contain a hidden conversion in Firm.
545                 This happens for instance in the following code:
546
547                  int i;
548                  unsigned j = *(unsigned *)&i;
549
550                 Handle this here. */
551                 mode = get_Load_mode(node);
552                 if (mode != get_irn_mode(val))
553                         val = new_d_Conv(get_irn_dbg_info(node), val, mode);
554
555                 mem = get_Load_mem(node);
556                 turn_into_tuple(node, pn_Load_max);
557                 set_Tuple_pred(node, pn_Load_M,         mem);
558                 set_Tuple_pred(node, pn_Load_res,       val);
559                 set_Tuple_pred(node, pn_Load_X_regular, new_Jmp());
560                 set_Tuple_pred(node, pn_Load_X_except,  new_Bad());
561         } else if (is_Store(node)) {
562                 DB((dbg, SET_LEVEL_3, "  checking %+F for replacement ", node));
563
564                 /* a Store always can be replaced */
565                 adr = get_Store_ptr(node);
566
567                 if (! is_Sel(adr)) {
568                         DB((dbg, SET_LEVEL_3, "no Sel input (%+F)\n", adr));
569                         return;
570                 }
571
572                 if (! pset_find_ptr(env->sels, adr)) {
573                         DB((dbg, SET_LEVEL_3, "Sel %+F has no VNUM\n", adr));
574                         return;
575                 }
576
577                 vnum = GET_VNUM(adr);
578                 assert(vnum < (unsigned)env->nvals);
579
580                 DB((dbg, SET_LEVEL_3, "replacing by value %u\n", vnum));
581
582                 /* Beware: A Store can contain a hidden conversion in Firm. */
583                 val = get_Store_value(node);
584                 if (get_irn_mode(val) != env->modes[vnum])
585                         val = new_d_Conv(get_irn_dbg_info(node), val, env->modes[vnum]);
586
587                 block = get_nodes_block(node);
588                 set_cur_block(block);
589                 set_value(vnum, val);
590
591                 mem = get_Store_mem(node);
592                 turn_into_tuple(node, pn_Store_max);
593                 set_Tuple_pred(node, pn_Store_M,         mem);
594                 set_Tuple_pred(node, pn_Store_X_regular, new_Jmp());
595                 set_Tuple_pred(node, pn_Store_X_except,  new_Bad());
596         }
597 }
598
599 /**
600  * Make scalar replacement.
601  *
602  * @param sels    A set containing all Sel nodes that have a value number
603  * @param nvals   The number of scalars.
604  * @param modes   A flexible array, containing all the modes of
605  *                the value numbers.
606  */
607 static void do_scalar_replacements(pset *sels, int nvals, ir_mode **modes) {
608         env_t env;
609
610         ssa_cons_start(current_ir_graph, nvals);
611
612         env.nvals     = nvals;
613         env.modes     = modes;
614         env.sels      = sels;
615
616         /*
617          * second step: walk over the graph blockwise in topological order
618          * and fill the array as much as possible.
619          */
620         DB((dbg, SET_LEVEL_3, "Substituting Loads and Stores in %+F\n", current_ir_graph));
621         irg_walk_blkwise_graph(current_ir_graph, NULL, topologic_walker, &env);
622
623         ssa_cons_finish(current_ir_graph);
624 }
625
626 /*
627  * Find possible scalar replacements
628  *
629  * @param irg  The current ir graph.
630  */
631 int scalar_replacement_opt(ir_graph *irg) {
632         unsigned  nvals;
633         int       i;
634         scalars_t key, *value;
635         ir_node   *irg_frame;
636         ir_mode   **modes;
637         set       *set_ent;
638         pset      *sels;
639         ir_type   *ent_type;
640         ir_graph  *rem;
641         int       res = 0;
642
643         if (! get_opt_scalar_replacement())
644                 return 0;
645
646         rem = current_ir_graph;
647         current_ir_graph = irg;
648
649         /* Call algorithm that computes the out edges */
650         assure_irg_outs(irg);
651
652         /* Find possible scalar replacements */
653         if (find_possible_replacements(irg)) {
654                 DB((dbg, SET_LEVEL_1, "Scalar Replacement: %s\n", get_entity_name(get_irg_entity(irg))));
655
656                 /* Insert in set the scalar replacements. */
657                 irg_frame = get_irg_frame(irg);
658                 nvals = 0;
659                 modes = NEW_ARR_F(ir_mode *, 16);
660                 set_ent = new_set(ent_cmp, 8);
661                 sels    = pset_new_ptr(8);
662
663                 for (i = get_irn_n_outs(irg_frame) - 1; i >= 0; --i) {
664                         ir_node *succ = get_irn_out(irg_frame, i);
665
666                         if (is_Sel(succ)) {
667                                 ir_entity *ent = get_Sel_entity(succ);
668
669                                 if (get_entity_link(ent) == NULL || get_entity_link(ent) == ADDRESS_TAKEN)
670                                         continue;
671
672                                 ent_type = get_entity_type(ent);
673
674                                 key.ent       = ent;
675                                 key.ent_owner = get_entity_owner(ent);
676                                 set_insert(set_ent, &key, sizeof(key), HASH_PTR(key.ent));
677
678 #ifdef DEBUG_libfirm
679                                 if (is_Array_type(ent_type)) {
680                                         DB((dbg, SET_LEVEL_1, "  found array %s\n", get_entity_name(ent)));
681                                 } else if (is_Struct_type(ent_type)) {
682                                         DB((dbg, SET_LEVEL_1, "  found struct %s\n", get_entity_name(ent)));
683                                 } else if (is_atomic_type(ent_type))
684                                         DB((dbg, SET_LEVEL_1, "  found atomic value %s\n", get_entity_name(ent)));
685                                 else {
686                                         panic("Neither an array nor a struct or atomic value found in scalar replace");
687                                 }
688 #endif /* DEBUG_libfirm */
689
690                                 nvals = allocate_value_numbers(sels, ent, nvals, &modes);
691                         }
692                 }
693
694                 DB((dbg, SET_LEVEL_1, "  %u values will be needed\n", nvals));
695
696                 /* If scalars were found. */
697                 if (nvals > 0) {
698                         do_scalar_replacements(sels, nvals, modes);
699
700                         foreach_set(set_ent, value) {
701                                 remove_class_member(value->ent_owner, value->ent);
702                         }
703
704                         /*
705                          * We changed the graph, but did NOT introduce new blocks
706                          * neither changed control flow, cf-backedges should be still
707                          * consistent.
708                          */
709                         set_irg_outs_inconsistent(irg);
710                         set_irg_loopinfo_inconsistent(irg);
711
712                         res = 1;
713                 }
714                 del_pset(sels);
715                 del_set(set_ent);
716                 DEL_ARR_F(modes);
717         }
718
719         current_ir_graph = rem;
720         return res;
721 }
722
723 void firm_init_scalar_replace(void) {
724         FIRM_DBG_REGISTER(dbg, "firm.opt.scalar_replace");
725 }