This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: IVOPT improvement patch


Hi,

> >> patch-2:
> >>
> >> This patch address PR31792 -- sinking computation of replaced IV out
> >> of the loop when it is live outside loop only.
> >
> > ivopts seems like a wrong place for this optimization; it is already quite
> > complicated as it is, and should not do things that are only marginally
> > related. ?Won't scheduling pass_sink_code after ivopts do the same thing?
> 
> There are reasons pass_sink_code can not do this -- the RHS of the
> computation that can be sinked are loop variant

that should not be a problem, it suffices that the computed value is only
used on the exit edge.

> -- though only the
> value from last iteration matters.
> 
> What is more important is that this has impact on the cost computation
> and iv selection -- without this, the use (nonlinear) cost of  the
> live out only ivs can be high and the IVOPT may end up keeping the
> original induction variable in the loop.

Well, you can just adjust the cost for the expected sinking, and let
pass_sink_code do it; that is the simple part of the patch.  Btw.

+
+  if (use->use_pos == IU_OUTSIDE_LOOP_ONLY && !infinite_cost_p (cost))
+    cost.cost /= AVG_LOOP_NITER (data->current_loop);

This causes the loop invariant parts of the cost to be divided by AVG_LOOP_NITER
twice.

Zdenek


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]