2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Load/Store optimizations.
23 * @author Michael Beck
32 #include "iroptimize.h"
34 #include "irgraph_t.h"
42 #include "dbginfo_t.h"
43 #include "iropt_dbg.h"
49 #include "opt_polymorphy.h"
52 #include "irphase_t.h"
56 /** The debug handle. */
57 DEBUG_ONLY(static firm_dbg_module_t *dbg;)
60 #include "cacheopt/cachesim.h"
64 #define IMAX(a,b) ((a) > (b) ? (a) : (b))
66 #define MAX_PROJ IMAX(IMAX(pn_Load_max, pn_Store_max), pn_Call_max)
69 DF_CHANGED = 1, /**< data flow changed */
70 CF_CHANGED = 2, /**< control flow changed */
76 typedef struct _walk_env_t {
77 struct obstack obst; /**< list of all stores */
78 unsigned changes; /**< a bitmask of graph changes */
81 /** A Load/Store info. */
82 typedef struct _ldst_info_t {
83 ir_node *projs[MAX_PROJ]; /**< list of Proj's of this node */
84 ir_node *exc_block; /**< the exception block if available */
85 int exc_idx; /**< predecessor index in the exception block */
86 unsigned visited; /**< visited counter for breaking loops */
90 * flags for control flow.
93 BLOCK_HAS_COND = 1, /**< Block has conditional control flow */
94 BLOCK_HAS_EXC = 2 /**< Block has exceptional control flow */
100 typedef struct _block_info_t {
101 unsigned flags; /**< flags for the block */
104 /** the master visited flag for loop detection. */
105 static unsigned master_visited = 0;
107 #define INC_MASTER() ++master_visited
108 #define MARK_NODE(info) (info)->visited = master_visited
109 #define NODE_VISITED(info) (info)->visited >= master_visited
112 * get the Load/Store info of a node
114 static ldst_info_t *get_ldst_info(ir_node *node, struct obstack *obst) {
115 ldst_info_t *info = get_irn_link(node);
118 info = obstack_alloc(obst, sizeof(*info));
119 memset(info, 0, sizeof(*info));
120 set_irn_link(node, info);
123 } /* get_ldst_info */
126 * get the Block info of a node
128 static block_info_t *get_block_info(ir_node *node, struct obstack *obst) {
129 block_info_t *info = get_irn_link(node);
132 info = obstack_alloc(obst, sizeof(*info));
133 memset(info, 0, sizeof(*info));
134 set_irn_link(node, info);
137 } /* get_block_info */
140 * update the projection info for a Load/Store
142 static unsigned update_projs(ldst_info_t *info, ir_node *proj)
144 long nr = get_Proj_proj(proj);
146 assert(0 <= nr && nr <= MAX_PROJ && "Wrong proj from LoadStore");
148 if (info->projs[nr]) {
149 /* there is already one, do CSE */
150 exchange(proj, info->projs[nr]);
154 info->projs[nr] = proj;
160 * update the exception block info for a Load/Store node.
162 * @param info the load/store info struct
163 * @param block the exception handler block for this load/store
164 * @param pos the control flow input of the block
166 static unsigned update_exc(ldst_info_t *info, ir_node *block, int pos)
168 assert(info->exc_block == NULL && "more than one exception block found");
170 info->exc_block = block;
175 /** Return the number of uses of an address node */
176 #define get_irn_n_uses(adr) get_irn_n_edges(adr)
179 * walker, collects all Load/Store/Proj nodes
181 * walks from Start -> End
183 static void collect_nodes(ir_node *node, void *env)
185 ir_opcode opcode = get_irn_opcode(node);
186 ir_node *pred, *blk, *pred_blk;
187 ldst_info_t *ldst_info;
188 walk_env_t *wenv = env;
190 if (opcode == iro_Proj) {
191 pred = get_Proj_pred(node);
192 opcode = get_irn_opcode(pred);
194 if (opcode == iro_Load || opcode == iro_Store || opcode == iro_Call) {
195 ldst_info = get_ldst_info(pred, &wenv->obst);
197 wenv->changes |= update_projs(ldst_info, node);
200 * Place the Proj's to the same block as the
201 * predecessor Load. This is always ok and prevents
202 * "non-SSA" form after optimizations if the Proj
203 * is in a wrong block.
205 blk = get_nodes_block(node);
206 pred_blk = get_nodes_block(pred);
207 if (blk != pred_blk) {
208 wenv->changes |= DF_CHANGED;
209 set_nodes_block(node, pred_blk);
212 } else if (opcode == iro_Block) {
215 for (i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) {
216 ir_node *pred_block, *proj;
217 block_info_t *bl_info;
220 pred = proj = get_Block_cfgpred(node, i);
223 pred = get_Proj_pred(proj);
224 is_exc = get_Proj_proj(proj) == pn_Generic_X_except;
227 /* ignore Bad predecessors, they will be removed later */
231 pred_block = get_nodes_block(pred);
232 bl_info = get_block_info(pred_block, &wenv->obst);
234 if (is_fragile_op(pred) && is_exc)
235 bl_info->flags |= BLOCK_HAS_EXC;
236 else if (is_irn_forking(pred))
237 bl_info->flags |= BLOCK_HAS_COND;
239 opcode = get_irn_opcode(pred);
240 if (is_exc && (opcode == iro_Load || opcode == iro_Store || opcode == iro_Call)) {
241 ldst_info = get_ldst_info(pred, &wenv->obst);
243 wenv->changes |= update_exc(ldst_info, node, i);
247 } /* collect_nodes */
250 * Returns an entity if the address ptr points to a constant one.
252 * @param ptr the address
254 * @return an entity or NULL
256 static ir_entity *find_constant_entity(ir_node *ptr)
259 ir_op *op = get_irn_op(ptr);
261 if (op == op_SymConst && (get_SymConst_kind(ptr) == symconst_addr_ent)) {
262 ir_entity *ent = get_SymConst_entity(ptr);
263 if (variability_constant == get_entity_variability(ent))
266 } else if (op == op_Sel) {
267 ir_entity *ent = get_Sel_entity(ptr);
268 ir_type *tp = get_entity_owner(ent);
270 /* Do not fiddle with polymorphism. */
271 if (is_Class_type(get_entity_owner(ent)) &&
272 ((get_entity_n_overwrites(ent) != 0) ||
273 (get_entity_n_overwrittenby(ent) != 0) ) )
276 if (is_Array_type(tp)) {
280 for (i = 0, n = get_Sel_n_indexs(ptr); i < n; ++i) {
282 tarval *tlower, *tupper;
283 ir_node *index = get_Sel_index(ptr, i);
284 tarval *tv = computed_value(index);
286 /* check if the index is constant */
287 if (tv == tarval_bad)
290 bound = get_array_lower_bound(tp, i);
291 tlower = computed_value(bound);
292 bound = get_array_upper_bound(tp, i);
293 tupper = computed_value(bound);
295 if (tlower == tarval_bad || tupper == tarval_bad)
298 if (tarval_cmp(tv, tlower) & pn_Cmp_Lt)
300 if (tarval_cmp(tupper, tv) & pn_Cmp_Lt)
303 /* ok, bounds check finished */
307 if (variability_constant == get_entity_variability(ent))
311 ptr = get_Sel_ptr(ptr);
315 } /* find_constant_entity */
318 * Return the Selection index of a Sel node from dimension n
320 static long get_Sel_array_index_long(ir_node *n, int dim) {
321 ir_node *index = get_Sel_index(n, dim);
322 assert(is_Const(index));
323 return get_tarval_long(get_Const_tarval(index));
324 } /* get_Sel_array_index_long */
327 * Returns the accessed component graph path for an
328 * node computing an address.
330 * @param ptr the node computing the address
331 * @param depth current depth in steps upward from the root
334 static compound_graph_path *rec_get_accessed_path(ir_node *ptr, int depth) {
335 compound_graph_path *res = NULL;
336 ir_entity *root, *field;
339 if (get_irn_op(ptr) == op_SymConst) {
340 /* a SymConst. If the depth is 0, this is an access to a global
341 * entity and we don't need a component path, else we know
342 * at least it's length.
344 assert(get_SymConst_kind(ptr) == symconst_addr_ent);
345 root = get_SymConst_entity(ptr);
346 res = (depth == 0) ? NULL : new_compound_graph_path(get_entity_type(root), depth);
348 assert(get_irn_op(ptr) == op_Sel);
349 /* it's a Sel, go up until we find the root */
350 res = rec_get_accessed_path(get_Sel_ptr(ptr), depth+1);
352 /* fill up the step in the path at the current position */
353 field = get_Sel_entity(ptr);
354 path_len = get_compound_graph_path_length(res);
355 pos = path_len - depth - 1;
356 set_compound_graph_path_node(res, pos, field);
358 if (is_Array_type(get_entity_owner(field))) {
359 assert(get_Sel_n_indexs(ptr) == 1 && "multi dim arrays not implemented");
360 set_compound_graph_path_array_index(res, pos, get_Sel_array_index_long(ptr, 0));
364 } /* rec_get_accessed_path */
366 /** Returns an access path or NULL. The access path is only
367 * valid, if the graph is in phase_high and _no_ address computation is used.
369 static compound_graph_path *get_accessed_path(ir_node *ptr) {
370 return rec_get_accessed_path(ptr, 0);
371 } /* get_accessed_path */
374 static void reduce_adr_usage(ir_node *ptr);
377 * Update a Load that may lost it's usage.
379 static void handle_load_update(ir_node *load) {
380 ldst_info_t *info = get_irn_link(load);
382 /* do NOT touch volatile loads for now */
383 if (get_Load_volatility(load) == volatility_is_volatile)
386 if (! info->projs[pn_Load_res] && ! info->projs[pn_Load_X_except]) {
387 ir_node *ptr = get_Load_ptr(load);
388 ir_node *mem = get_Load_mem(load);
390 /* a Load which value is neither used nor exception checked, remove it */
391 exchange(info->projs[pn_Load_M], mem);
392 if (info->projs[pn_Load_X_regular])
393 exchange(info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
395 reduce_adr_usage(ptr);
397 } /* handle_load_update */
400 * A Use of an address node is vanished. Check if this was a Proj
401 * node and update the counters.
403 static void reduce_adr_usage(ir_node *ptr) {
405 if (get_irn_n_edges(ptr) <= 0) {
406 /* this Proj is dead now */
407 ir_node *pred = get_Proj_pred(ptr);
410 ldst_info_t *info = get_irn_link(pred);
411 info->projs[get_Proj_proj(ptr)] = NULL;
413 /* this node lost it's result proj, handle that */
414 handle_load_update(pred);
418 } /* reduce_adr_usage */
421 * Check, if an already existing value of mode old_mode can be converted
422 * into the needed one new_mode without loss.
424 static int can_use_stored_value(ir_mode *old_mode, ir_mode *new_mode) {
425 if (old_mode == new_mode)
428 /* if both modes are two-complement ones, we can always convert the
429 Stored value into the needed one. */
430 if (get_mode_size_bits(old_mode) >= get_mode_size_bits(new_mode) &&
431 get_mode_arithmetic(old_mode) == irma_twos_complement &&
432 get_mode_arithmetic(new_mode) == irma_twos_complement)
435 } /* can_use_stored_value */
438 * Check whether a Call is at least pure, ie. does only read memory.
440 static unsigned is_Call_pure(ir_node *call) {
441 ir_type *call_tp = get_Call_type(call);
442 unsigned prop = get_method_additional_properties(call_tp);
444 /* check first the call type */
445 if ((prop & (mtp_property_const|mtp_property_pure)) == 0) {
446 /* try the called entity */
447 ir_node *ptr = get_Call_ptr(call);
449 if (is_Global(ptr)) {
450 ir_entity *ent = get_Global_entity(ptr);
452 prop = get_entity_additional_properties(ent);
455 return (prop & (mtp_property_const|mtp_property_pure)) != 0;
459 * Follow the memory chain as long as there are only Loads,
460 * alias free Stores, and constant Calls and try to replace the
461 * current Load by a previous ones.
462 * Note that in unreachable loops it might happen that we reach
463 * load again, as well as we can fall into a cycle.
464 * We break such cycles using a special visited flag.
466 * INC_MASTER() must be called before dive into
468 static unsigned follow_Mem_chain(ir_node *load, ir_node *curr) {
470 ldst_info_t *info = get_irn_link(load);
472 ir_node *ptr = get_Load_ptr(load);
473 ir_node *mem = get_Load_mem(load);
474 ir_mode *load_mode = get_Load_mode(load);
476 for (pred = curr; load != pred; ) {
477 ldst_info_t *pred_info = get_irn_link(pred);
480 * BEWARE: one might think that checking the modes is useless, because
481 * if the pointers are identical, they refer to the same object.
482 * This is only true in strong typed languages, not in C were the following
483 * is possible a = *(ir_type1 *)p; b = *(ir_type2 *)p ...
485 if (is_Store(pred) && get_Store_ptr(pred) == ptr &&
486 can_use_stored_value(get_irn_mode(get_Store_value(pred)), load_mode)) {
488 * a Load immediately after a Store -- a read after write.
489 * We may remove the Load, if both Load & Store does not have an exception handler
490 * OR they are in the same MacroBlock. In the latter case the Load cannot
491 * throw an exception when the previous Store was quiet.
493 * Why we need to check for Store Exception? If the Store cannot
494 * be executed (ROM) the exception handler might simply jump into
495 * the load MacroBlock :-(
496 * We could make it a little bit better if we would know that the exception
497 * handler of the Store jumps directly to the end...
499 if ((pred_info->projs[pn_Store_X_except] == NULL && info->projs[pn_Load_X_except] == NULL) ||
500 get_nodes_MacroBlock(load) == get_nodes_MacroBlock(pred)) {
501 ir_node *value = get_Store_value(pred);
503 DBG_OPT_RAW(load, value);
505 /* add an convert if needed */
506 if (get_irn_mode(get_Store_value(pred)) != load_mode) {
507 value = new_r_Conv(current_ir_graph, get_nodes_block(load), value, load_mode);
510 if (info->projs[pn_Load_M])
511 exchange(info->projs[pn_Load_M], mem);
514 if (info->projs[pn_Load_X_except]) {
515 exchange( info->projs[pn_Load_X_except], new_Bad());
518 if (info->projs[pn_Load_X_regular]) {
519 exchange( info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
523 if (info->projs[pn_Load_res])
524 exchange(info->projs[pn_Load_res], value);
527 reduce_adr_usage(ptr);
528 return res | DF_CHANGED;
530 } else if (is_Load(pred) && get_Load_ptr(pred) == ptr &&
531 can_use_stored_value(get_Load_mode(pred), load_mode)) {
533 * a Load after a Load -- a read after read.
534 * We may remove the second Load, if it does not have an exception handler
535 * OR they are in the same MacroBlock. In the later case the Load cannot
536 * throw an exception when the previous Load was quiet.
538 * Here, there is no need to check if the previous Load has an exception
539 * hander because they would have exact the same exception...
541 if (info->projs[pn_Load_X_except] == NULL || get_nodes_MacroBlock(load) == get_nodes_MacroBlock(pred)) {
544 DBG_OPT_RAR(load, pred);
546 /* the result is used */
547 if (info->projs[pn_Load_res]) {
548 if (pred_info->projs[pn_Load_res] == NULL) {
549 /* create a new Proj again */
550 pred_info->projs[pn_Load_res] = new_r_Proj(current_ir_graph, get_nodes_block(pred), pred, get_Load_mode(pred), pn_Load_res);
552 value = pred_info->projs[pn_Load_res];
554 /* add an convert if needed */
555 if (get_Load_mode(pred) != load_mode) {
556 value = new_r_Conv(current_ir_graph, get_nodes_block(load), value, load_mode);
559 exchange(info->projs[pn_Load_res], value);
562 if (info->projs[pn_Load_M])
563 exchange(info->projs[pn_Load_M], mem);
566 if (info->projs[pn_Load_X_except]) {
567 exchange(info->projs[pn_Load_X_except], new_Bad());
570 if (info->projs[pn_Load_X_regular]) {
571 exchange( info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
576 reduce_adr_usage(ptr);
577 return res |= DF_CHANGED;
581 if (is_Store(pred)) {
582 /* check if we can pass through this store */
583 ir_alias_relation rel = get_alias_relation(
586 get_irn_mode(get_Store_value(pred)),
588 /* if the might be an alias, we cannot pass this Store */
591 pred = skip_Proj(get_Store_mem(pred));
592 } else if (is_Load(pred)) {
593 pred = skip_Proj(get_Load_mem(pred));
594 } else if (is_Call(pred)) {
595 if (is_Call_pure(pred)) {
596 /* The called graph is at least pure, so there are no Store's
597 in it. We can handle it like a Load and skip it. */
598 pred = skip_Proj(get_Call_mem(pred));
600 /* there might be Store's in the graph, stop here */
604 /* follow only Load chains */
608 /* check for cycles */
609 if (NODE_VISITED(pred_info))
611 MARK_NODE(pred_info);
617 /* handle all Sync predecessors */
618 for (i = get_Sync_n_preds(pred) - 1; i >= 0; --i) {
619 res |= follow_Mem_chain(load, skip_Proj(get_Sync_pred(pred, i)));
626 } /* follow_Mem_chain */
631 * @param load the Load node
633 static unsigned optimize_load(ir_node *load)
635 ldst_info_t *info = get_irn_link(load);
636 ir_node *mem, *ptr, *new_node;
640 /* do NOT touch volatile loads for now */
641 if (get_Load_volatility(load) == volatility_is_volatile)
644 /* the address of the load to be optimized */
645 ptr = get_Load_ptr(load);
648 * Check if we can remove the exception from a Load:
649 * This can be done, if the address is from an Sel(Alloc) and
650 * the Sel type is a subtype of the allocated type.
652 * This optimizes some often used OO constructs,
653 * like x = new O; x->t;
655 if (info->projs[pn_Load_X_except]) {
657 ir_node *mem = get_Sel_mem(ptr);
659 /* FIXME: works with the current FE, but better use the base */
660 if (is_Alloc(skip_Proj(mem))) {
661 /* ok, check the types */
662 ir_entity *ent = get_Sel_entity(ptr);
663 ir_type *s_type = get_entity_type(ent);
664 ir_type *a_type = get_Alloc_type(mem);
666 if (is_SubClass_of(s_type, a_type)) {
667 /* ok, condition met: there can't be an exception because
668 * Alloc guarantees that enough memory was allocated */
670 exchange(info->projs[pn_Load_X_except], new_Bad());
671 info->projs[pn_Load_X_except] = NULL;
672 exchange(info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
673 info->projs[pn_Load_X_regular] = NULL;
677 } else if (is_Alloc(skip_Proj(skip_Cast(ptr)))) {
678 /* simple case: a direct load after an Alloc. Firm Alloc throw
679 * an exception in case of out-of-memory. So, there is no way for an
680 * exception in this load.
681 * This code is constructed by the "exception lowering" in the Jack compiler.
683 exchange(info->projs[pn_Load_X_except], new_Bad());
684 info->projs[pn_Load_X_except] = NULL;
685 exchange(info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
686 info->projs[pn_Load_X_regular] = NULL;
691 /* The mem of the Load. Must still be returned after optimization. */
692 mem = get_Load_mem(load);
694 if (! info->projs[pn_Load_res] && ! info->projs[pn_Load_X_except]) {
695 /* a Load which value is neither used nor exception checked, remove it */
696 exchange(info->projs[pn_Load_M], mem);
698 if (info->projs[pn_Load_X_regular]) {
699 /* should not happen, but if it does, remove it */
700 exchange(info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
704 reduce_adr_usage(ptr);
705 return res | DF_CHANGED;
708 /* Load from a constant polymorphic field, where we can resolve
710 new_node = transform_node_Load(load);
711 if (new_node != load) {
712 if (info->projs[pn_Load_M]) {
713 exchange(info->projs[pn_Load_M], mem);
714 info->projs[pn_Load_M] = NULL;
716 if (info->projs[pn_Load_X_except]) {
717 exchange(info->projs[pn_Load_X_except], new_Bad());
718 info->projs[pn_Load_X_except] = NULL;
721 if (info->projs[pn_Load_X_regular]) {
722 exchange(info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
723 info->projs[pn_Load_X_regular] = NULL;
726 if (info->projs[pn_Load_res])
727 exchange(info->projs[pn_Load_res], new_node);
730 reduce_adr_usage(ptr);
731 return res | DF_CHANGED;
734 /* check if we can determine the entity that will be loaded */
735 ent = find_constant_entity(ptr);
737 if ((allocation_static == get_entity_allocation(ent)) &&
738 (visibility_external_allocated != get_entity_visibility(ent))) {
739 /* a static allocation that is not external: there should be NO exception
742 /* no exception, clear the info field as it might be checked later again */
743 if (info->projs[pn_Load_X_except]) {
744 exchange(info->projs[pn_Load_X_except], new_Bad());
745 info->projs[pn_Load_X_except] = NULL;
748 if (info->projs[pn_Load_X_regular]) {
749 exchange(info->projs[pn_Load_X_regular], new_r_Jmp(current_ir_graph, get_nodes_block(load)));
750 info->projs[pn_Load_X_regular] = NULL;
754 if (variability_constant == get_entity_variability(ent)) {
755 if (is_atomic_entity(ent)) {
756 /* Might not be atomic after
757 lowering of Sels. In this
758 case we could also load, but
759 it's more complicated. */
760 /* more simpler case: we load the content of a constant value:
761 * replace it by the constant itself
765 if (info->projs[pn_Load_M]) {
766 exchange(info->projs[pn_Load_M], mem);
770 if (info->projs[pn_Load_res]) {
771 if (is_atomic_entity(ent)) {
772 ir_node *c = copy_const_value(get_irn_dbg_info(load), get_atomic_ent_value(ent));
775 exchange(info->projs[pn_Load_res], c);
780 reduce_adr_usage(ptr);
783 compound_graph_path *path = get_accessed_path(ptr);
788 assert(is_proper_compound_graph_path(path, get_compound_graph_path_length(path)-1));
792 for (j = 0; j < get_compound_graph_path_length(path); ++j) {
793 ir_entity *node = get_compound_graph_path_node(path, j);
794 fprintf(stdout, ".%s", get_entity_name(node));
795 if (is_Array_type(get_entity_owner(node)))
796 fprintf(stdout, "[%d]", get_compound_graph_path_array_index(path, j));
802 c = get_compound_ent_value_by_path(ent, path);
803 free_compound_graph_path(path);
805 /* printf(" cons: "); DDMN(c); */
807 if (info->projs[pn_Load_M]) {
808 exchange(info->projs[pn_Load_M], mem);
811 if (info->projs[pn_Load_res]) {
812 exchange(info->projs[pn_Load_res], copy_const_value(get_irn_dbg_info(load), c));
816 reduce_adr_usage(ptr);
819 /* We can not determine a correct access path. E.g., in jack, we load
820 a byte from an object to generate an exception. Happens in test program
822 printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent),
823 get_entity_name(get_irg_entity(current_ir_graph)));
824 printf(" load: "); DDMN(load);
825 printf(" ptr: "); DDMN(ptr);
833 /* Check, if the address of this load is used more than once.
834 * If not, this load cannot be removed in any case. */
835 if (get_irn_n_uses(ptr) <= 1)
839 * follow the memory chain as long as there are only Loads
840 * and try to replace current Load or Store by a previous one.
841 * Note that in unreachable loops it might happen that we reach
842 * load again, as well as we can fall into a cycle.
843 * We break such cycles using a special visited flag.
846 res = follow_Mem_chain(load, skip_Proj(mem));
848 } /* optimize_load */
851 * Check whether a value of mode new_mode would completely overwrite a value
852 * of mode old_mode in memory.
854 static int is_completely_overwritten(ir_mode *old_mode, ir_mode *new_mode)
856 return get_mode_size_bits(new_mode) >= get_mode_size_bits(old_mode);
857 } /* is_completely_overwritten */
860 * follow the memory chain as long as there are only Loads and alias free Stores.
862 * INC_MASTER() must be called before dive into
864 static unsigned follow_Mem_chain_for_Store(ir_node *store, ir_node *curr) {
866 ldst_info_t *info = get_irn_link(store);
868 ir_node *ptr = get_Store_ptr(store);
869 ir_node *mem = get_Store_mem(store);
870 ir_node *value = get_Store_value(store);
871 ir_mode *mode = get_irn_mode(value);
872 ir_node *block = get_nodes_block(store);
873 ir_node *mblk = get_Block_MacroBlock(block);
875 for (pred = curr; pred != store;) {
876 ldst_info_t *pred_info = get_irn_link(pred);
879 * BEWARE: one might think that checking the modes is useless, because
880 * if the pointers are identical, they refer to the same object.
881 * This is only true in strong typed languages, not is C were the following
882 * is possible *(ir_type1 *)p = a; *(ir_type2 *)p = b ...
883 * However, if the mode that is written have a bigger or equal size the the old
884 * one, the old value is completely overwritten and can be killed ...
886 if (is_Store(pred) && get_Store_ptr(pred) == ptr &&
887 get_nodes_MacroBlock(pred) == mblk &&
888 is_completely_overwritten(get_irn_mode(get_Store_value(pred)), mode)) {
890 * a Store after a Store in the same block -- a write after write.
891 * We may remove the first Store, if it does not have an exception handler.
893 * TODO: What, if both have the same exception handler ???
895 if (get_Store_volatility(pred) != volatility_is_volatile && !pred_info->projs[pn_Store_X_except]) {
896 DBG_OPT_WAW(pred, store);
897 exchange(pred_info->projs[pn_Store_M], get_Store_mem(pred));
899 reduce_adr_usage(ptr);
902 } else if (is_Load(pred) && get_Load_ptr(pred) == ptr &&
903 value == pred_info->projs[pn_Load_res]) {
905 * a Store of a value just loaded from the same address
906 * -- a write after read.
907 * We may remove the Store, if it does not have an exception
910 if (! info->projs[pn_Store_X_except]) {
911 DBG_OPT_WAR(store, pred);
912 exchange(info->projs[pn_Store_M], mem);
914 reduce_adr_usage(ptr);
919 if (is_Store(pred)) {
920 /* check if we can pass thru this store */
921 ir_alias_relation rel = get_alias_relation(
924 get_irn_mode(get_Store_value(pred)),
926 /* if the might be an alias, we cannot pass this Store */
929 pred = skip_Proj(get_Store_mem(pred));
930 } else if (get_irn_op(pred) == op_Load) {
931 ir_alias_relation rel = get_alias_relation(
932 current_ir_graph, get_Load_ptr(pred), get_Load_mode(pred),
937 pred = skip_Proj(get_Load_mem(pred));
939 /* follow only Load chains */
943 /* check for cycles */
944 if (NODE_VISITED(pred_info))
946 MARK_NODE(pred_info);
952 /* handle all Sync predecessors */
953 for (i = get_Sync_n_preds(pred) - 1; i >= 0; --i) {
954 res |= follow_Mem_chain_for_Store(store, skip_Proj(get_Sync_pred(pred, i)));
960 } /* follow_Mem_chain_for_Store */
965 * @param store the Store node
967 static unsigned optimize_store(ir_node *store) {
970 if (get_Store_volatility(store) == volatility_is_volatile)
973 ptr = get_Store_ptr(store);
975 /* Check, if the address of this Store is used more than once.
976 * If not, this Store cannot be removed in any case. */
977 if (get_irn_n_uses(ptr) <= 1)
980 mem = get_Store_mem(store);
982 /* follow the memory chain as long as there are only Loads */
984 return follow_Mem_chain_for_Store(store, skip_Proj(mem));
985 } /* optimize_store */
988 * walker, optimizes Phi after Stores to identical places:
989 * Does the following optimization:
992 * val1 val2 val3 val1 val2 val3
994 * Store Store Store \ | /
1001 * This reduces the number of stores and allows for predicated execution.
1002 * Moves Stores back to the end of a function which may be bad.
1004 * This is only possible if the predecessor blocks have only one successor.
1006 static unsigned optimize_phi(ir_node *phi, walk_env_t *wenv)
1009 ir_node *store, *old_store, *ptr, *block, *phi_block, *phiM, *phiD, *exc, *projM;
1011 ir_node **inM, **inD, **projMs;
1013 dbg_info *db = NULL;
1015 block_info_t *bl_info;
1018 /* Must be a memory Phi */
1019 if (get_irn_mode(phi) != mode_M)
1022 n = get_Phi_n_preds(phi);
1026 /* must be only one user */
1027 projM = get_Phi_pred(phi, 0);
1028 if (get_irn_n_edges(projM) != 1)
1031 store = skip_Proj(projM);
1033 if (get_irn_op(store) != op_Store)
1036 block = get_nodes_block(store);
1038 /* abort on dead blocks */
1039 if (is_Block_dead(block))
1042 /* check if the block is post dominated by Phi-block
1043 and has no exception exit */
1044 bl_info = get_irn_link(block);
1045 if (bl_info->flags & BLOCK_HAS_EXC)
1048 phi_block = get_nodes_block(phi);
1049 if (! block_strictly_postdominates(phi_block, block))
1052 /* this is the address of the store */
1053 ptr = get_Store_ptr(store);
1054 mode = get_irn_mode(get_Store_value(store));
1055 info = get_irn_link(store);
1056 exc = info->exc_block;
1058 for (i = 1; i < n; ++i) {
1059 ir_node *pred = get_Phi_pred(phi, i);
1061 if (get_irn_n_edges(pred) != 1)
1064 pred = skip_Proj(pred);
1065 if (!is_Store(pred))
1068 if (ptr != get_Store_ptr(pred) || mode != get_irn_mode(get_Store_value(pred)))
1071 info = get_irn_link(pred);
1073 /* check, if all stores have the same exception flow */
1074 if (exc != info->exc_block)
1077 /* abort on dead blocks */
1078 block = get_nodes_block(pred);
1079 if (is_Block_dead(block))
1082 /* check if the block is post dominated by Phi-block
1083 and has no exception exit. Note that block must be different from
1084 Phi-block, else we would move a Store from end End of a block to its
1086 bl_info = get_irn_link(block);
1087 if (bl_info->flags & BLOCK_HAS_EXC)
1089 if (block == phi_block || ! block_postdominates(phi_block, block))
1094 * ok, when we are here, we found all predecessors of a Phi that
1095 * are Stores to the same address and size. That means whatever
1096 * we do before we enter the block of the Phi, we do a Store.
1097 * So, we can move the Store to the current block:
1099 * val1 val2 val3 val1 val2 val3
1101 * | Str | | Str | | Str | \ | /
1107 * Is only allowed if the predecessor blocks have only one successor.
1110 NEW_ARR_A(ir_node *, projMs, n);
1111 NEW_ARR_A(ir_node *, inM, n);
1112 NEW_ARR_A(ir_node *, inD, n);
1113 NEW_ARR_A(int, idx, n);
1115 /* Prepare: Collect all Store nodes. We must do this
1116 first because we otherwise may loose a store when exchanging its
1119 for (i = n - 1; i >= 0; --i) {
1122 projMs[i] = get_Phi_pred(phi, i);
1123 assert(is_Proj(projMs[i]));
1125 store = get_Proj_pred(projMs[i]);
1126 info = get_irn_link(store);
1128 inM[i] = get_Store_mem(store);
1129 inD[i] = get_Store_value(store);
1130 idx[i] = info->exc_idx;
1132 block = get_nodes_block(phi);
1134 /* second step: create a new memory Phi */
1135 phiM = new_rd_Phi(get_irn_dbg_info(phi), current_ir_graph, block, n, inM, mode_M);
1137 /* third step: create a new data Phi */
1138 phiD = new_rd_Phi(get_irn_dbg_info(phi), current_ir_graph, block, n, inD, mode);
1140 /* rewire memory and kill the node */
1141 for (i = n - 1; i >= 0; --i) {
1142 ir_node *proj = projMs[i];
1145 ir_node *store = get_Proj_pred(proj);
1146 exchange(proj, inM[i]);
1151 /* fourth step: create the Store */
1152 store = new_rd_Store(db, current_ir_graph, block, phiM, ptr, phiD);
1154 co_set_irn_name(store, co_get_irn_ident(old_store));
1157 projM = new_rd_Proj(NULL, current_ir_graph, block, store, mode_M, pn_Store_M);
1159 info = get_ldst_info(store, &wenv->obst);
1160 info->projs[pn_Store_M] = projM;
1162 /* fifths step: repair exception flow */
1164 ir_node *projX = new_rd_Proj(NULL, current_ir_graph, block, store, mode_X, pn_Store_X_except);
1166 info->projs[pn_Store_X_except] = projX;
1167 info->exc_block = exc;
1168 info->exc_idx = idx[0];
1170 for (i = 0; i < n; ++i) {
1171 set_Block_cfgpred(exc, idx[i], projX);
1175 /* the exception block should be optimized as some inputs are identical now */
1181 /* sixth step: replace old Phi */
1182 exchange(phi, projM);
1184 return res | DF_CHANGED;
1185 } /* optimize_phi */
1188 * walker, do the optimizations
1190 static void do_load_store_optimize(ir_node *n, void *env) {
1191 walk_env_t *wenv = env;
1193 switch (get_irn_opcode(n)) {
1196 wenv->changes |= optimize_load(n);
1200 wenv->changes |= optimize_store(n);
1204 wenv->changes |= optimize_phi(n, wenv);
1210 } /* do_load_store_optimize */
1213 typedef struct scc {
1214 ir_node *head; /**< the head of the list */
1217 /** A node entry. */
1218 typedef struct node_entry {
1219 unsigned DFSnum; /**< the DFS number of this node */
1220 unsigned low; /**< the low number of this node */
1221 ir_node *header; /**< the header of this node */
1222 int in_stack; /**< flag, set if the node is on the stack */
1223 ir_node *next; /**< link to the next node the the same scc */
1224 scc *pscc; /**< the scc of this node */
1225 unsigned POnum; /**< the post order number for blocks */
1228 /** A loop entry. */
1229 typedef struct loop_env {
1230 ir_phase ph; /**< the phase object */
1231 ir_node **stack; /**< the node stack */
1232 int tos; /**< tos index */
1233 unsigned nextDFSnum; /**< the current DFS number */
1234 unsigned POnum; /**< current post order number */
1236 unsigned changes; /**< a bitmask of graph changes */
1240 * Gets the node_entry of a node
1242 static node_entry *get_irn_ne(ir_node *irn, loop_env *env) {
1243 ir_phase *ph = &env->ph;
1244 node_entry *e = phase_get_irn_data(&env->ph, irn);
1247 e = phase_alloc(ph, sizeof(*e));
1248 memset(e, 0, sizeof(*e));
1249 phase_set_irn_data(ph, irn, e);
1255 * Push a node onto the stack.
1257 * @param env the loop environment
1258 * @param n the node to push
1260 static void push(loop_env *env, ir_node *n) {
1263 if (env->tos == ARR_LEN(env->stack)) {
1264 int nlen = ARR_LEN(env->stack) * 2;
1265 ARR_RESIZE(ir_node *, env->stack, nlen);
1267 env->stack[env->tos++] = n;
1268 e = get_irn_ne(n, env);
1273 * pop a node from the stack
1275 * @param env the loop environment
1277 * @return The topmost node
1279 static ir_node *pop(loop_env *env) {
1280 ir_node *n = env->stack[--env->tos];
1281 node_entry *e = get_irn_ne(n, env);
1288 * Check if irn is a region constant.
1289 * The block or irn must strictly dominate the header block.
1291 * @param irn the node to check
1292 * @param header_block the header block of the induction variable
1294 static int is_rc(ir_node *irn, ir_node *header_block) {
1295 ir_node *block = get_nodes_block(irn);
1297 return (block != header_block) && block_dominates(block, header_block);
1300 typedef struct phi_entry phi_entry;
1302 ir_node *phi; /**< A phi with a region const memory. */
1303 int pos; /**< The position of the region const memory */
1304 ir_node *load; /**< the newly created load for this phi */
1309 * Move loops out of loops if possible.
1311 * @param pscc the loop described by an SCC
1312 * @param env the loop environment
1314 static void move_loads_out_of_loops(scc *pscc, loop_env *env) {
1315 ir_node *phi, *load, *next, *other, *next_other;
1318 phi_entry *phi_list = NULL;
1320 /* collect all outer memories */
1321 for (phi = pscc->head; phi != NULL; phi = next) {
1322 node_entry *ne = get_irn_ne(phi, env);
1325 /* check all memory Phi's */
1329 assert(get_irn_mode(phi) == mode_M && "DFS geturn non-memory Phi");
1331 for (j = get_irn_arity(phi) - 1; j >= 0; --j) {
1332 ir_node *pred = get_irn_n(phi, j);
1333 node_entry *pe = get_irn_ne(pred, env);
1335 if (pe->pscc != ne->pscc) {
1336 /* not in the same SCC, is region const */
1337 phi_entry *pe = phase_alloc(&env->ph, sizeof(*pe));
1341 pe->next = phi_list;
1346 /* no Phis no fun */
1347 assert(phi_list != NULL && "DFS found a loop without Phi");
1349 for (load = pscc->head; load; load = next) {
1351 node_entry *ne = get_irn_ne(load, env);
1354 if (is_Load(load)) {
1355 ldst_info_t *info = get_irn_link(load);
1356 ir_node *ptr = get_Load_ptr(load);
1358 /* for now, we cannot handle Loads with exceptions */
1359 if (info->projs[pn_Load_res] == NULL || info->projs[pn_Load_X_regular] != NULL || info->projs[pn_Load_X_except] != NULL)
1362 /* for now, we can only handle Load(Global) */
1363 if (! is_Global(ptr))
1365 ent = get_Global_entity(ptr);
1366 load_mode = get_Load_mode(load);
1367 for (other = pscc->head; other != NULL; other = next_other) {
1368 node_entry *ne = get_irn_ne(other, env);
1369 next_other = ne->next;
1371 if (is_Store(other)) {
1372 ir_alias_relation rel = get_alias_relation(
1374 get_Store_ptr(other),
1375 get_irn_mode(get_Store_value(other)),
1377 /* if the might be an alias, we cannot pass this Store */
1378 if (rel != no_alias)
1381 /* only pure Calls are allowed here, so ignore them */
1383 if (other == NULL) {
1388 /* for now, we cannot handle more than one input */
1389 if (phi_list->next != NULL)
1392 /* yep, no aliasing Store found, Load can be moved */
1393 DB((dbg, LEVEL_1, " Found a Load that could be moved: %+F\n", load));
1395 db = get_irn_dbg_info(load);
1396 for (pe = phi_list; pe != NULL; pe = pe->next) {
1398 ir_node *phi = pe->phi;
1399 ir_node *blk = get_nodes_block(phi);
1400 ir_node *pred = get_Block_cfgpred_block(blk, pos);
1403 pe->load = irn = new_rd_Load(db, current_ir_graph, pred, get_Phi_pred(phi, pos), ptr, load_mode);
1404 ninfo = get_ldst_info(irn, phase_obst(&env->ph));
1406 ninfo->projs[pn_Load_M] = mem = new_r_Proj(current_ir_graph, pred, irn, mode_M, pn_Load_M);
1407 set_Phi_pred(phi, pos, mem);
1409 ninfo->projs[pn_Load_res] = new_r_Proj(current_ir_graph, pred, irn, load_mode, pn_Load_res);
1411 DB((dbg, LEVEL_1, " Created %+F in %+F\n", irn, pred));
1414 /* now kill the old Load */
1415 exchange(info->projs[pn_Load_M], get_Load_mem(load));
1416 exchange(info->projs[pn_Load_res], ninfo->projs[pn_Load_res]);
1418 env->changes |= DF_CHANGED;
1422 } /* move_loads_out_of_loops */
1425 * Process a loop SCC.
1427 * @param pscc the SCC
1428 * @param env the loop environment
1430 static void process_loop(scc *pscc, loop_env *env) {
1431 ir_node *irn, *next, *header = NULL;
1432 node_entry *b, *h = NULL;
1433 int j, only_phi, num_outside, process = 0;
1436 /* find the header block for this scc */
1437 for (irn = pscc->head; irn; irn = next) {
1438 node_entry *e = get_irn_ne(irn, env);
1439 ir_node *block = get_nodes_block(irn);
1442 b = get_irn_ne(block, env);
1445 if (h->POnum < b->POnum) {
1456 /* check if this scc contains only Phi, Loads or Stores nodes */
1460 for (irn = pscc->head; irn; irn = next) {
1461 node_entry *e = get_irn_ne(irn, env);
1464 switch (get_irn_opcode(irn)) {
1466 if (is_Call_pure(irn)) {
1467 /* pure calls can be treated like loads */
1471 /* non-pure calls must be handle like may-alias Stores */
1474 /* cannot handle CopyB yet */
1478 if (get_Load_volatility(irn) == volatility_is_volatile) {
1479 /* cannot handle loops with volatile Loads */
1485 if (get_Store_volatility(irn) == volatility_is_volatile) {
1486 /* cannot handle loops with volatile Stores */
1495 for (j = get_irn_arity(irn) - 1; j >= 0; --j) {
1496 ir_node *pred = get_irn_n(irn, j);
1497 node_entry *pe = get_irn_ne(pred, env);
1499 if (pe->pscc != e->pscc) {
1500 /* not in the same SCC, must be a region const */
1501 if (! is_rc(pred, header)) {
1502 /* not a memory loop */
1508 } else if (out_rc != pred) {
1519 /* found a memory loop */
1520 DB((dbg, LEVEL_2, " Found a memory loop:\n "));
1521 if (only_phi && num_outside == 1) {
1522 /* a phi cycle with only one real predecessor can be collapsed */
1523 DB((dbg, LEVEL_2, " Found an USELESS Phi cycle:\n "));
1525 for (irn = pscc->head; irn; irn = next) {
1526 node_entry *e = get_irn_ne(irn, env);
1529 exchange(irn, out_rc);
1531 env->changes |= DF_CHANGED;
1535 /* set the header for every node in this scc */
1536 for (irn = pscc->head; irn; irn = next) {
1537 node_entry *e = get_irn_ne(irn, env);
1540 DB((dbg, LEVEL_2, " %+F,", irn));
1542 DB((dbg, LEVEL_2, "\n"));
1544 move_loads_out_of_loops(pscc, env);
1548 } /* process_loop */
1553 * @param pscc the SCC
1554 * @param env the loop environment
1556 static void process_scc(scc *pscc, loop_env *env) {
1557 ir_node *head = pscc->head;
1558 node_entry *e = get_irn_ne(head, env);
1560 #ifdef DEBUG_libfirm
1562 ir_node *irn, *next;
1564 DB((dbg, LEVEL_4, " SCC at %p:\n ", pscc));
1565 for (irn = pscc->head; irn; irn = next) {
1566 node_entry *e = get_irn_ne(irn, env);
1570 DB((dbg, LEVEL_4, " %+F,", irn));
1572 DB((dbg, LEVEL_4, "\n"));
1576 if (e->next != NULL) {
1577 /* this SCC has more than one member */
1578 process_loop(pscc, env);
1583 * Do Tarjan's SCC algorithm and drive load/store optimization.
1585 * @param irn start at this node
1586 * @param env the loop environment
1588 static void dfs(ir_node *irn, loop_env *env)
1591 node_entry *node = get_irn_ne(irn, env);
1593 mark_irn_visited(irn);
1595 node->DFSnum = env->nextDFSnum++;
1596 node->low = node->DFSnum;
1600 if (is_Phi(irn) || is_Sync(irn)) {
1601 n = get_irn_arity(irn);
1602 for (i = 0; i < n; ++i) {
1603 ir_node *pred = get_irn_n(irn, i);
1604 node_entry *o = get_irn_ne(pred, env);
1606 if (irn_not_visited(pred)) {
1608 node->low = MIN(node->low, o->low);
1610 if (o->DFSnum < node->DFSnum && o->in_stack)
1611 node->low = MIN(o->DFSnum, node->low);
1613 } else if (is_fragile_op(irn)) {
1614 ir_node *pred = get_fragile_op_mem(irn);
1615 node_entry *o = get_irn_ne(pred, env);
1617 if (irn_not_visited(pred)) {
1619 node->low = MIN(node->low, o->low);
1621 if (o->DFSnum < node->DFSnum && o->in_stack)
1622 node->low = MIN(o->DFSnum, node->low);
1623 } else if (is_Proj(irn)) {
1624 ir_node *pred = get_Proj_pred(irn);
1625 node_entry *o = get_irn_ne(pred, env);
1627 if (irn_not_visited(pred)) {
1629 node->low = MIN(node->low, o->low);
1631 if (o->DFSnum < node->DFSnum && o->in_stack)
1632 node->low = MIN(o->DFSnum, node->low);
1635 /* IGNORE predecessors */
1638 if (node->low == node->DFSnum) {
1639 scc *pscc = phase_alloc(&env->ph, sizeof(*pscc));
1647 e = get_irn_ne(x, env);
1649 e->next = pscc->head;
1653 process_scc(pscc, env);
1658 * Do the DFS on the memory edges a graph.
1660 * @param irg the graph to process
1661 * @param env the loop environment
1663 static void do_dfs(ir_graph *irg, loop_env *env) {
1664 ir_graph *rem = current_ir_graph;
1665 ir_node *endblk, *end;
1668 current_ir_graph = irg;
1669 inc_irg_visited(irg);
1671 /* visit all memory nodes */
1672 endblk = get_irg_end_block(irg);
1673 for (i = get_Block_n_cfgpreds(endblk) - 1; i >= 0; --i) {
1674 ir_node *pred = get_Block_cfgpred(endblk, i);
1676 pred = skip_Proj(pred);
1677 if (is_Return(pred))
1678 dfs(get_Return_mem(pred), env);
1679 else if (is_Raise(pred))
1680 dfs(get_Raise_mem(pred), env);
1681 else if (is_fragile_op(pred))
1682 dfs(get_fragile_op_mem(pred), env);
1684 assert(0 && "Unknown EndBlock predecessor");
1688 /* visit the keep-alives */
1689 end = get_irg_end(irg);
1690 for (i = get_End_n_keepalives(end) - 1; i >= 0; --i) {
1691 ir_node *ka = get_End_keepalive(end, i);
1693 if (is_Phi(ka) && irn_not_visited(ka))
1696 current_ir_graph = rem;
1700 * Initialize new phase data. We do this always explicit, so return NULL here
1702 static void *init_loop_data(ir_phase *ph, const ir_node *irn, void *data) {
1707 } /* init_loop_data */
1710 * Optimize Loads/Stores in loops.
1712 * @param irg the graph
1714 static int optimize_loops(ir_graph *irg) {
1717 env.stack = NEW_ARR_F(ir_node *, 128);
1722 phase_init(&env.ph, "ldstopt", irg, PHASE_DEFAULT_GROWTH, init_loop_data, NULL);
1724 /* calculate the SCC's and drive loop optimization. */
1727 DEL_ARR_F(env.stack);
1728 phase_free(&env.ph);
1731 } /* optimize_loops */
1734 * do the load store optimization
1736 void optimize_load_store(ir_graph *irg) {
1739 FIRM_DBG_REGISTER(dbg, "firm.opt.ldstopt");
1741 assert(get_irg_phase_state(irg) != phase_building);
1742 assert(get_irg_pinned(irg) != op_pin_state_floats &&
1743 "LoadStore optimization needs pinned graph");
1745 /* we need landing pads */
1746 remove_critical_cf_edges(irg);
1750 /* for Phi optimization post-dominators are needed ... */
1751 assure_postdoms(irg);
1753 if (get_opt_alias_analysis()) {
1754 assure_irg_address_taken_computed(irg);
1755 assure_irp_globals_address_taken_computed();
1758 obstack_init(&env.obst);
1761 /* init the links, then collect Loads/Stores/Proj's in lists */
1763 irg_walk_graph(irg, firm_clear_link, collect_nodes, &env);
1765 /* now we have collected enough information, optimize */
1766 irg_walk_graph(irg, NULL, do_load_store_optimize, &env);
1768 env.changes |= optimize_loops(irg);
1770 obstack_free(&env.obst, NULL);
1772 /* Handle graph state */
1774 set_irg_outs_inconsistent(irg);
1777 if (env.changes & CF_CHANGED) {
1778 /* is this really needed: Yes, control flow changed, block might
1779 have Bad() predecessors. */
1780 set_irg_doms_inconsistent(irg);
1782 } /* optimize_load_store */