* @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.
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);
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);
{
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;
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);
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;