+ ivi->new_increment = new_r_Mul (current_ir_graph, block_inc, ivi->increment, mul_const,
+ get_irn_mode(mul_const));
+ if (!(get_irn_op(mul_init) == op_Phi)){
+ ivi->new_init = new_r_Mul (current_ir_graph, block_init, ivi->init, mul_const,
+ get_irn_mode(mul_const));
+ ivi->new_init = my_new_r_Add(current_ir_graph, block_init, ivi->new_init,
+ ivi->new_increment);
+ } else
+ ivi->new_init = new_r_Mul (current_ir_graph, block_init, ivi->init, mul_const,
+ get_irn_mode(mul_const));
+
+ /* Generate a new basic induction variable. Break the data flow loop
+ initially by using an Unknown node. */
+
+ in[ivi->op_pred_pos] = new_Unknown(get_irn_mode(ivi->new_init));
+
+ in[ivi->init_pred_pos] = ivi->new_init;
+ ivi->new_phi = new_r_Phi(current_ir_graph, get_nodes_block(ivi->itervar_phi), 2, in,
+ get_irn_mode(mul_const));
+ mark_irn_visited(ivi->new_phi);
+
+ if (ivi->operation_code == op_Add)
+ ivi->new_op = my_new_r_Add(current_ir_graph, get_nodes_block(ivi->op),
+ ivi->new_increment,ivi-> new_phi);
+ else if (ivi->operation_code == op_Sub)
+ ivi->new_op = my_new_r_Sub(current_ir_graph, get_nodes_block(ivi->op),ivi-> new_phi,
+ ivi->new_increment);
+
+ set_Phi_pred(ivi->new_phi, ivi->op_pred_pos, ivi->new_op);
+
+ // This for search for a reducible successor of reduc_var.
+ reduce_var_pred = get_irn_n_outs(reduce_var);
+ if (reduce_var_pred == 1) {
+ ir_node *old_ind =get_irn_out(reduce_var, 0);
+ if(get_irn_op(old_ind) == op_Add || get_irn_op(old_ind) == op_Sub ||
+ get_irn_op(old_ind) == op_Mul){
+ ivi->reducible = 1;
+ ivi->reducible_node = old_ind;
+ }
+ }
+ /* Replace the use of the strength reduced value. */
+ exchange(reduce_var, ivi->new_phi);
+ return 1;
+ }
+ else { /* ivi->reducible */
+ if(ivi->new_phi == NULL){
+ ivi->init = new_r_Mul (current_ir_graph, block_init,
+ mul_const, ivi->init,
+ get_irn_mode(mul_const));
+ if(ivi->cmp != NULL)
+ ivi->cmp_const = new_r_Mul (current_ir_graph, ivi->cmp_init_block,
+ ivi->cmp_const, mul_const, get_irn_mode(mul_const));
+ ivi->increment = new_r_Mul (current_ir_graph, block_inc,
+ ivi->increment, mul_const, get_irn_mode(mul_const));
+ }else {
+ ivi->new_init = new_r_Mul (current_ir_graph, block_init,
+ mul_const, ivi->new_init,
+ get_irn_mode(mul_const));
+ ivi->new_increment = new_r_Mul (current_ir_graph, block_inc,
+ ivi->new_increment, mul_const,
+ get_irn_mode(mul_const));
+ }
+ if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
+ printf("\nReducing operation is : "); DDMN(reduce_var);
+ printf("in graph : "); DDMG(current_ir_graph);
+ }
+ return 1;
+ }
+ }
+ else if (get_irn_op (reduce_var) == op_Add){
+ ir_node *add_init = NULL;
+ ir_node *add_const = NULL;
+
+ // Search for constant of add.
+ ir_node *add_right = get_Add_right(reduce_var);
+ ir_node *add_left = get_Add_left(reduce_var);
+ ir_op *add_right_op = get_irn_op(add_right);
+ ir_op *add_left_op = get_irn_op(add_left);
+
+ n_reduced_expressions++;
+
+ if (add_right_op != op_Const)
+ add_init = add_right;
+ else if (add_left_op != op_Const)
+ add_init = add_left;
+ if (add_right_op == op_Const || add_right_op == op_SymConst)
+ add_const = add_right;
+ else if (add_left_op == op_Const || add_left_op == op_SymConst)
+ add_const = add_left;
+ if (add_const == NULL) return 0;
+ if (ivi->new_phi == NULL){
+ ivi->init = my_new_r_Add(current_ir_graph, block_init,
+ add_const, ivi->init);
+ if (ivi->cmp != NULL)
+ ivi->cmp_const = my_new_r_Add(current_ir_graph, ivi->cmp_init_block,
+ add_const, ivi->cmp_const);
+ } else {
+ ivi->new_init = my_new_r_Add(current_ir_graph, block_init,
+ add_const, ivi->new_init);
+ }
+ if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
+ printf("\nReducing operation is : "); DDMN(reduce_var);
+ printf("in graph : "); DDMG(current_ir_graph);
+ }
+ return 1;
+ }
+ else if (get_irn_op(reduce_var) == op_Sub) {
+ ir_node *sub_init = NULL;
+ ir_node *sub_const = NULL;
+ ir_node *sub_right = get_Sub_right(reduce_var);
+ ir_node *sub_left = get_Sub_left(reduce_var);
+ ir_op *sub_right_op = get_irn_op(sub_right);
+ ir_op *sub_left_op = get_irn_op(sub_left);
+
+ n_reduced_expressions++;
+
+ /* Search for constant of Sub. */
+ if (sub_right_op != op_Const)
+ sub_init = sub_right;
+ else if (sub_left_op != op_Const)
+ sub_init = sub_left;
+ if (sub_right_op == op_Const)
+ sub_const = sub_right;
+ else if (sub_left_op == op_Const)
+ sub_const = sub_left;
+
+ if (sub_const == NULL)
+ return 0;
+
+ if (ivi->new_phi == NULL) {
+ ivi->init = my_new_r_Sub(current_ir_graph, block_init,
+ ivi->init, sub_const);
+ if (ivi->cmp != NULL)
+ ivi->cmp_const = my_new_r_Sub(current_ir_graph, ivi->cmp_init_block,
+ ivi->cmp_const,sub_const);
+ } else
+ ivi->new_init = my_new_r_Sub (current_ir_graph, block_init,
+ ivi->new_init, sub_const);
+ if (get_opt_strength_red_verbose() && get_firm_verbosity() > 1) {
+ printf("\nReducing operation is : "); DDMN(reduce_var);
+ printf("in graph : "); DDMG(current_ir_graph);
+ }
+ return 1;
+ }
+ return 0;
+}