[PR45098,4/10] Iv init cost.

Submitted by Tom de Vries on May 18, 2011, 4:50 p.m.

Details

Message ID 4DD3F8E9.6000004@codesourcery.com
State New
Headers show

Commit Message

Tom de Vries May 18, 2011, 4:50 p.m.
On 05/17/2011 09:17 AM, Tom de Vries wrote:
> On 05/17/2011 09:10 AM, Tom de Vries wrote:
>> Hi Zdenek,
>>
>> I have a patch set for for PR45098.
>>
>> 01_object-size-target.patch
>> 02_pr45098-rtx-cost-set.patch
>> 03_pr45098-computation-cost.patch
>> 04_pr45098-iv-init-cost.patch
>> 05_pr45098-bound-cost.patch
>> 06_pr45098-bound-cost.test.patch
>> 07_pr45098-nowrap-limits-iterations.patch
>> 08_pr45098-nowrap-limits-iterations.test.patch
>> 09_pr45098-shift-add-cost.patch
>> 10_pr45098-shift-add-cost.test.patch
>>
>> I will sent out the patches individually.
>>
> 
> OK for trunk?
> 
> Thanks,
> - Tom

Resubmitting with comment.

The init cost of an iv will in general not be zero. It will be
exceptional that the iv register happens to be initialized with the
proper value at no cost. In general, there will at the very least be a
regcopy or a const set.

2011-05-05  Tom de Vries  <tom@codesourcery.com>

	PR target/45098
	* tree-ssa-loop-ivopts.c (determine_iv_cost): Prevent
	cost_base.cost == 0.

Comments

Zdenek Dvorak May 18, 2011, 8:52 p.m.
Hi,

> Resubmitting with comment.
> 
> The init cost of an iv will in general not be zero. It will be
> exceptional that the iv register happens to be initialized with the
> proper value at no cost. In general, there will at the very least be a
> regcopy or a const set.

OK.  Please add a comment explaining this to the code,

Zdenek

> 2011-05-05  Tom de Vries  <tom@codesourcery.com>
> 
> 	PR target/45098
> 	* tree-ssa-loop-ivopts.c (determine_iv_cost): Prevent
> 	cost_base.cost == 0.

> Index: gcc/tree-ssa-loop-ivopts.c
> ===================================================================
> --- gcc/tree-ssa-loop-ivopts.c	(revision 173380)
> +++ gcc/tree-ssa-loop-ivopts.c	(working copy)
> @@ -4688,6 +4688,8 @@ determine_iv_cost (struct ivopts_data *d
>  
>    base = cand->iv->base;
>    cost_base = force_var_cost (data, base, NULL);
> +  if (cost_base.cost == 0)
> +      cost_base.cost = COSTS_N_INSNS (1);
>    cost_step = add_cost (TYPE_MODE (TREE_TYPE (base)), data->speed);
>  
>    cost = cost_step + adjust_setup_cost (data, cost_base.cost);
Richard Sandiford May 25, 2011, 1:44 p.m.
Sorry for being so late.  I was just curious...

Tom de Vries <vries@codesourcery.com> writes:
> The init cost of an iv will in general not be zero. It will be
> exceptional that the iv register happens to be initialized with the
> proper value at no cost. In general, there will at the very least be a
> regcopy or a const set.
>
> 2011-05-05  Tom de Vries  <tom@codesourcery.com>
>
> 	PR target/45098
> 	* tree-ssa-loop-ivopts.c (determine_iv_cost): Prevent
> 	cost_base.cost == 0.
> Index: gcc/tree-ssa-loop-ivopts.c
> ===================================================================
> --- gcc/tree-ssa-loop-ivopts.c	(revision 173380)
> +++ gcc/tree-ssa-loop-ivopts.c	(working copy)
> @@ -4688,6 +4688,8 @@ determine_iv_cost (struct ivopts_data *d
>  
>    base = cand->iv->base;
>    cost_base = force_var_cost (data, base, NULL);
> +  if (cost_base.cost == 0)
> +      cost_base.cost = COSTS_N_INSNS (1);
>    cost_step = add_cost (TYPE_MODE (TREE_TYPE (base)), data->speed);
>  
>    cost = cost_step + adjust_setup_cost (data, cost_base.cost);

...why does this reasoning apply only to this call to force_var_cost?

Richard

Patch hide | download patch | download mbox

Index: gcc/tree-ssa-loop-ivopts.c
===================================================================
--- gcc/tree-ssa-loop-ivopts.c	(revision 173380)
+++ gcc/tree-ssa-loop-ivopts.c	(working copy)
@@ -4688,6 +4688,8 @@  determine_iv_cost (struct ivopts_data *d
 
   base = cand->iv->base;
   cost_base = force_var_cost (data, base, NULL);
+  if (cost_base.cost == 0)
+      cost_base.cost = COSTS_N_INSNS (1);
   cost_step = add_cost (TYPE_MODE (TREE_TYPE (base)), data->speed);
 
   cost = cost_step + adjust_setup_cost (data, cost_base.cost);