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