X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Fldstopt.c;h=055b6be112b22a1565d5605ca82a95056d82cfb3;hb=4ebc4b6497324aa5d2380a897c75d3c391760ba0;hp=aabac51a159f896bb58f61eed5bdc1d862987b43;hpb=964c2386733675865b27c8a955277677ed9f848c;p=libfirm diff --git a/ir/opt/ldstopt.c b/ir/opt/ldstopt.c index aabac51a1..055b6be11 100644 --- a/ir/opt/ldstopt.c +++ b/ir/opt/ldstopt.c @@ -356,7 +356,7 @@ static ir_entity *find_constant_entity(ir_node *ptr) */ static long get_Sel_array_index_long(ir_node *n, int dim) { ir_node *index = get_Sel_index(n, dim); - assert(get_irn_op(index) == op_Const); + assert(is_Const(index)); return get_tarval_long(get_Const_tarval(index)); } /* get_Sel_array_index_long */ @@ -625,7 +625,7 @@ static unsigned follow_Mem_chain(ir_node *load, ir_node *curr) { for (i = get_Sync_n_preds(pred) - 1; i >= 0; --i) { res |= follow_Mem_chain(load, skip_Proj(get_Sync_pred(pred, i))); if (res) - break; + return res; } } @@ -758,79 +758,80 @@ static unsigned optimize_load(ir_node *load) res |= CF_CHANGED; } - if (variability_constant == get_entity_variability(ent) - && is_atomic_entity(ent)) { - /* Might not be atomic after - lowering of Sels. In this - case we could also load, but - it's more complicated. */ - /* more simpler case: we load the content of a constant value: - * replace it by the constant itself - */ - - /* no memory */ - if (info->projs[pn_Load_M]) { - exchange(info->projs[pn_Load_M], mem); - res |= DF_CHANGED; - } - /* no result :-) */ - if (info->projs[pn_Load_res]) { - if (is_atomic_entity(ent)) { - ir_node *c = copy_const_value(get_irn_dbg_info(load), get_atomic_ent_value(ent)); - - DBG_OPT_RC(load, c); - exchange(info->projs[pn_Load_res], c); - res |= DF_CHANGED; - } - } - exchange(load, new_Bad()); - reduce_adr_usage(ptr); - return res; - } else if (variability_constant == get_entity_variability(ent)) { - compound_graph_path *path = get_accessed_path(ptr); - - if (path) { - ir_node *c; - - assert(is_proper_compound_graph_path(path, get_compound_graph_path_length(path)-1)); - /* - { - int j; - for (j = 0; j < get_compound_graph_path_length(path); ++j) { - ir_entity *node = get_compound_graph_path_node(path, j); - fprintf(stdout, ".%s", get_entity_name(node)); - if (is_Array_type(get_entity_owner(node))) - fprintf(stdout, "[%d]", get_compound_graph_path_array_index(path, j)); - } - printf("\n"); - } - */ - - c = get_compound_ent_value_by_path(ent, path); - free_compound_graph_path(path); - - /* printf(" cons: "); DDMN(c); */ - + if (variability_constant == get_entity_variability(ent)) { + if (is_atomic_entity(ent)) { + /* Might not be atomic after + lowering of Sels. In this + case we could also load, but + it's more complicated. */ + /* more simpler case: we load the content of a constant value: + * replace it by the constant itself + */ + + /* no memory */ if (info->projs[pn_Load_M]) { exchange(info->projs[pn_Load_M], mem); res |= DF_CHANGED; } + /* no result :-) */ if (info->projs[pn_Load_res]) { - exchange(info->projs[pn_Load_res], copy_const_value(get_irn_dbg_info(load), c)); - res |= DF_CHANGED; + if (is_atomic_entity(ent)) { + ir_node *c = copy_const_value(get_irn_dbg_info(load), get_atomic_ent_value(ent)); + + DBG_OPT_RC(load, c); + exchange(info->projs[pn_Load_res], c); + res |= DF_CHANGED; + } } exchange(load, new_Bad()); reduce_adr_usage(ptr); return res; } else { - /* We can not determine a correct access path. E.g., in jack, we load - a byte from an object to generate an exception. Happens in test program - Reflectiontest. - printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent), - get_entity_name(get_irg_entity(current_ir_graph))); - printf(" load: "); DDMN(load); - printf(" ptr: "); DDMN(ptr); - */ + compound_graph_path *path = get_accessed_path(ptr); + + if (path) { + ir_node *c; + + assert(is_proper_compound_graph_path(path, get_compound_graph_path_length(path)-1)); + /* + { + int j; + for (j = 0; j < get_compound_graph_path_length(path); ++j) { + ir_entity *node = get_compound_graph_path_node(path, j); + fprintf(stdout, ".%s", get_entity_name(node)); + if (is_Array_type(get_entity_owner(node))) + fprintf(stdout, "[%d]", get_compound_graph_path_array_index(path, j)); + } + printf("\n"); + } + */ + + c = get_compound_ent_value_by_path(ent, path); + free_compound_graph_path(path); + + /* printf(" cons: "); DDMN(c); */ + + if (info->projs[pn_Load_M]) { + exchange(info->projs[pn_Load_M], mem); + res |= DF_CHANGED; + } + if (info->projs[pn_Load_res]) { + exchange(info->projs[pn_Load_res], copy_const_value(get_irn_dbg_info(load), c)); + res |= DF_CHANGED; + } + exchange(load, new_Bad()); + reduce_adr_usage(ptr); + return res; + } else { + /* We can not determine a correct access path. E.g., in jack, we load + a byte from an object to generate an exception. Happens in test program + Reflectiontest. + printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent), + get_entity_name(get_irg_entity(current_ir_graph))); + printf(" load: "); DDMN(load); + printf(" ptr: "); DDMN(ptr); + */ + } } } } @@ -1200,6 +1201,7 @@ static void do_load_store_optimize(ir_node *n, void *env) { case iro_Phi: wenv->changes |= optimize_phi(n, wenv); + break; default: ; @@ -1684,7 +1686,7 @@ static void do_dfs(ir_graph *irg, loop_env *env) { /** * Initialize new phase data. We do this always explicit, so return NULL here */ -static void *init_loop_data(ir_phase *ph, ir_node *irn, void *data) { +static void *init_loop_data(ir_phase *ph, const ir_node *irn, void *data) { (void)ph; (void)irn; (void)data; @@ -1727,9 +1729,6 @@ void optimize_load_store(ir_graph *irg) { assert(get_irg_pinned(irg) != op_pin_state_floats && "LoadStore optimization needs pinned graph"); - if (! get_opt_redundant_loadstore()) - return; - /* we need landing pads */ remove_critical_cf_edges(irg);