This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Improve cost computations in IVOPTS
- From: Zdenek Dvorak <rakdver at kam dot mff dot cuni dot cz>
- To: Eric Botcazou <ebotcazou at adacore dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Mon, 25 May 2009 21:01:39 +0200
- Subject: Re: [PATCH] Improve cost computations in IVOPTS
- References: <200905251255.53720.ebotcazou@adacore.com>
Hi,
> 2009-05-25 Eric Botcazou <ebotcazou@adacore.com>
>
> * tree-ssa-loop-ivopts.c (strip_offset_1) <MULT_EXPR>: New case.
> (force_expr_to_var_cost) <NEGATE_EXPR>: Likewise.
> (ptr_difference_cost): Use affine combinations to compute it.
> (difference_cost): Likewise.
> (get_computation_cost_at): Compute more accurate cost for addresses
> if the ratio is a multiplier allowed in addresses.
> For non-addresses, consider that an additional offset or symbol is
> added only once.
OK (with the changes proposed by Richard), and
> @@ -3415,8 +3447,8 @@ ptr_difference_cost (struct ivopts_data
> unsigned HOST_WIDE_INT *offset, bitmap *depends_on)
> {
> HOST_WIDE_INT diff = 0;
> - comp_cost cost;
> - bool speed = optimize_loop_for_speed_p (data->current_loop);
> + aff_tree aff_e1, aff_e2;
> + tree type;
>
> gcc_assert (TREE_CODE (e1) == ADDR_EXPR);
>
> @@ -3434,12 +3466,14 @@ ptr_difference_cost (struct ivopts_data
>
> *symbol_present = false;
> *var_present = true;
> -
> - cost = force_var_cost (data, e1, depends_on);
> - cost = add_costs (cost, force_var_cost (data, e2, depends_on));
> - cost.cost += add_cost (Pmode, speed);
>
> - return cost;
> + type = signed_type_for (TREE_TYPE (e1));
> + tree_to_aff_combination (e1, type, &aff_e1);
> + tree_to_aff_combination (e2, type, &aff_e2);
> + aff_combination_scale (&aff_e2, double_int_minus_one);
> + aff_combination_add (&aff_e1, &aff_e2);
> +
> + return force_var_cost (data, aff_combination_to_tree (&aff_e1), depends_on);
> }
assuming that compile time and memory consumption are not significantly
affected by this (and other similar) changes -- ivopts tries rather hard
to avoid folding things and creating new expressions in the phase of the
computation of the costs, as I used to run into problems with memory requirements
otherwise.
Zdenek