- ir_loop *iv_loop = get_irn_loop(get_nodes_block(iv));
- ir_loop *irn_loop = get_irn_loop(get_nodes_block(irn));
-
- /* only replace nodes that are in the same (or deeper loops) */
- if (get_loop_depth(irn_loop) >= get_loop_depth(iv_loop)) {
- DB((dbg, LEVEL_2, " Replacing %+F\n", irn));
-
- result = reduce(irn, iv, rc, env);
- if (result != irn) {
- node_entry *e, *iv_e;
-
- hook_strength_red(current_ir_graph, irn);
- exchange(irn, result);
- e = get_irn_ne(result, env);
- iv_e = get_irn_ne(iv, env);
- e->header = iv_e->header;
+
+ DB((dbg, LEVEL_2, " Replacing %+F\n", irn));
+
+ result = reduce(irn, iv, rc, env);
+ if (result != irn) {
+ node_entry *e, *iv_e;
+
+ hook_strength_red(current_ir_graph, irn);
+ exchange(irn, result);
+ e = get_irn_ne(result, env);
+ iv_e = get_irn_ne(iv, env);
+ e->header = iv_e->header;
+ ++env->replaced;
+ return 1;
+ }
+ return 0;
+}
+
+/**
+ * check if a given node is a mul with 2, 4, 8
+ */
+static int is_x86_shift_const(ir_node *mul) {
+ ir_node *rc;
+
+ if (! is_Mul(mul))
+ return 0;
+
+ /* normalization put constants on the right side */
+ rc = get_Mul_right(mul);
+ if (is_Const(rc)) {
+ tarval *tv = get_Const_tarval(rc);
+
+ if (tarval_is_long(tv)) {
+ long value = get_tarval_long(tv);
+
+ if (value == 2 || value == 4 || value == 8) {
+ /* do not reduce multiplications by 2, 4, 8 */
+ return 1;
+ }