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: pretty-ipa merge 15: loop finiteness testing


> >
> > SCEV actually does not need preheaders (or at least, it would be easy to
> > modify it not to, if some code that assumes preheaders creeped in);
> > however, there are cases where preheaders make it possible to get better
> > results, e.g. if you have a loop with two entry edges like this:
> >
> > loop
> > ?{
> > ? ?i_1 = phi (3, 5, i_2);
> > ? ?i_2 = i_1 + 1;
> > ?}
> >
> > There is no way how to express the scev of i_1, while after introducing
> > the preheaders, we get
> >
> > i_0 = phi (3,5);
> > loop
> > ?{
> > ? ?i_1 = phi (i_0, i_2);
> > ? ?i_2 = i_1 + 1;
> > ?}
> >
> > and i_1 = {i_0, +, 1}.

Hmm, interesting, I definitly didn't considered this case and I guess it
is not that incommon.

BTW libstdc++ has also quite few loops with exit conditions as:
  tmp = i<100;
  tmp2 = __builtin_expect (tmp);
  if (tmp != 0)
    exit_loop;
We probably ought to handle it, there are several real dead loops
comming from iterators not removed in tramp3d because of this.
After inlining we strip away the expects and are happy.
}
> >
> >> ?How far did you get on maintaining the loop structure plan?
> >
> > At some point, we were able to maintain the loop structure through
> > all of tree-ssa optimizations, we just never got to switch it on. ?I am
> > not sure whether this still works (I'd suspect that it does not),
> 
> It would be a worthy goal for 4.5 at least.  But I wonder what we do
> during inlining - do we properly duplicate loop information?

We do nothing, however gluing loop trees should not be that difficult.
I guess for time being I will keep pure-const constructing preheaders,
we can also move the construction into very end of early optimization
queue if we want.

Honza
> 
> Richard.


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