X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firarch.c;h=acd02825c5d21fc7c780379d350e4d7e7bdd204d;hb=efb58316e745bcec4fa46f76c8f2c69208a44928;hp=7b30379d40e8b4fba383959c6258aeb2dcb765af;hpb=e6a5a50a41ad84093d66a81994a8b0d276baa113;p=libfirm diff --git a/ir/ir/irarch.c b/ir/ir/irarch.c index 7b30379d4..acd02825c 100644 --- a/ir/ir/irarch.c +++ b/ir/ir/irarch.c @@ -22,7 +22,6 @@ * @brief Machine dependent Firm optimizations. * @date 28.9.2004 * @author Sebastian Hack, Michael Beck - * @version $Id$ * * Implements "Strength Reduction of Multiplications by Integer Constants" * by Youfeng Wu. @@ -572,19 +571,19 @@ ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn) ir_tarval *tv; const ir_settings_arch_dep_t *params = be_get_backend_param()->dep_param; - /* If the architecture dependent optimizations were not initialized or this optimization was not enabled. */ if (params == NULL || (opts & arch_dep_mul_to_shift) == 0) - return irn; + return res; - if (!is_Mul(irn) || !mode_is_int(mode)) + assert(is_Mul(irn)); + if (!mode_is_int(mode)) return res; /* we should never do the reverse transformations again (like x+x -> 2*x) */ irg = get_irn_irg(irn); - set_irg_state(irg, IR_GRAPH_STATE_ARCH_DEP); + add_irg_constraints(irg, IR_GRAPH_CONSTRAINT_ARCH_DEP); left = get_binop_left(irn); right = get_binop_right(irn); @@ -600,6 +599,11 @@ ir_node *arch_dep_replace_mul_with_shifts(ir_node *irn) operand = left; } + /* multiplications with 0 are a special case which we leave for + * equivalent_node_Mul because the code here can't handle them */ + if (tv == get_mode_null(mode)) + return res; + if (tv != NULL) { res = do_decomposition(irn, operand, tv); @@ -826,7 +830,7 @@ static ir_node *replace_div_by_mulh(ir_node *div, ir_tarval *tv) { dbg_info *dbg = get_irn_dbg_info(div); ir_node *n = get_binop_left(div); - ir_node *block = get_irn_n(div, -1); + ir_node *block = get_nodes_block(div); ir_mode *mode = get_irn_mode(n); int bits = get_mode_size_bits(mode); ir_node *q; @@ -932,7 +936,7 @@ ir_node *arch_dep_replace_div_by_const(ir_node *irn) if (!mode_is_int(mode)) return irn; - block = get_irn_n(irn, -1); + block = get_nodes_block(irn); dbg = get_irn_dbg_info(irn); bits = get_mode_size_bits(mode); @@ -1035,7 +1039,7 @@ ir_node *arch_dep_replace_mod_by_const(ir_node *irn) left = get_Mod_left(irn); mode = get_irn_mode(left); - block = get_irn_n(irn, -1); + block = get_nodes_block(irn); dbg = get_irn_dbg_info(irn); bits = get_mode_size_bits(mode); n = (bits + 7) / 8;