+ /* We mark the nodes to avoid endless recursion */
+ set_irn_link(arg, VISITED);
+
+ for (i = get_irn_n_outs(arg) - 1; i >= 0; i--) {
+ succ = get_irn_out(arg, i);
+
+ /* We was here.*/
+ if (get_irn_link(succ) == VISITED)
+ continue;
+
+ /* We should not walk over the memory edge.*/
+ if (get_irn_mode(succ) == mode_M)
+ continue;
+
+ /* We have reached a cmp and we must increase the
+ weight with the cmp_weight.*/
+ if (get_irn_op(succ) == op_Cmp) {
+
+ if (get_Cmp_left(succ) == arg)
+ op = get_Cmp_right(succ);
+ else
+ op = get_Cmp_left(succ);
+
+ if (is_irn_constlike(op)) {
+ weight += const_cmp_weight;
+ }
+ else
+ weight += cmp_weight;
+ }
+ else if (is_binop(succ)) {
+ /* We have reached a binop and we must increase the
+ weight with the binop_weight. If the other operand of the
+ binop is a constant we increase the weight with const_binop_weight
+ and call the function recursive.
+ */
+ if (get_binop_left(succ) == arg)
+ op = get_binop_right(succ);
+ else
+ op = get_binop_left(succ);
+
+ if (is_irn_constlike(op)) {
+ weight += const_binop_weight;
+ weight += calc_method_param_weight(succ);
+ }
+ else
+ weight += binop_weight;
+ } else if (is_unop(succ)) {
+ /* We have reached a binop and we must increase the
+ weight with the const_binop_weight and call the function recursive.*/
+ weight += const_binop_weight;
+ weight += calc_method_param_weight(succ);
+ }
+ }
+ set_irn_link(arg, NULL);
+ return weight;
+}
+
+/**
+ * Set a weight for each argument of a ir_graph.
+ * The args with a greater weight are good for optimize.
+ *
+ * @param ent The entity of the ir_graph.
+ */
+static void analyze_method_params_weight(entity *ent)
+{
+ ir_type *mtp;
+ ir_graph *irg;
+ int nparams, i, proj_nr;
+ ir_node *irg_args, *arg;
+
+ mtp = get_entity_type(ent);
+ nparams = get_method_n_params(mtp);
+
+ /* allocate a new array. currently used as 'analysed' flag */
+ ent->param_weight = NEW_ARR_F(float, nparams);
+
+ /* If the method haven't parameters we have
+ * nothing to do.
+ */
+ if (nparams <= 0)
+ return;
+
+ irg = get_entity_irg(ent);
+
+ /* First we initialize the parameter weight with 0. */
+ for (i = nparams - 1; i >= 0; i--)
+ ent->param_weight[i] = null_weight;
+
+ if (! irg) {
+ /* no graph, no better info */