+ if (e->pscc == NULL) {
+ e->pscc = obstack_alloc(&env->obst, sizeof(*e->pscc));
+ memset(e->pscc, 0, sizeof(*e->pscc));
+ update_scc(result, e, env);
+ }
+ ++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;
+ }
+ }
+ }
+ return 0;
+}
+
+/**
+ * Check if an IV represents a counter with constant limits.
+ */
+static int is_counter_iv(ir_node *iv, iv_env *env) {
+ node_entry *e = get_irn_ne(iv, env);
+ scc *pscc = e->pscc;
+ ir_node *have_init = NULL;
+ ir_node *have_incr = NULL;
+ ir_opcode code = iro_Bad;
+ ir_node *irn;
+
+ if (pscc->code != 0) {
+ /* already analysed */
+ return pscc->code != iro_Bad;
+ }
+
+ pscc->code = iro_Bad;
+ for (irn = pscc->head; irn != NULL; irn = e->next) {
+ if (is_Add(irn)) {
+ if (have_incr != NULL)
+ return 0;
+
+ have_incr = get_Add_right(irn);
+ if (! is_Const(have_incr)) {
+ have_incr = get_Add_left(irn);
+ if (! is_Const(have_incr))
+ return 0;
+ }
+ code = iro_Add;
+ } else if (is_Sub(irn)) {
+ if (have_incr != NULL)
+ return 0;
+
+ have_incr = get_Sub_right(irn);
+ if (! is_Const(have_incr))
+ return 0;
+ code = iro_Sub;
+ } else if (is_Phi(irn)) {
+ int i;
+
+ for (i = get_Phi_n_preds(irn) - 1; i >= 0; --i) {
+ ir_node *pred = get_Phi_pred(irn, i);
+ node_entry *ne = get_irn_ne(pred, env);
+
+ if (ne->header == e->header)
+ continue;
+ if (have_init != NULL)
+ return 0;
+ have_init = pred;
+ if (! is_Const(pred))
+ return 0;
+ }
+ } else
+ return 0;
+ e = get_irn_ne(irn, env);