clean up latch blocks (+rfc)

Zdenek Dvorak rakdver@atrey.karlin.mff.cuni.cz
Tue Dec 6 15:21:00 GMT 2005


Hello,

> > > > I think it would be much cleaner to just persuade code sinking
> > > > not to move statements into empty loop latches (one simple way might
> be
> > > > to eliminate the latch forwarder blocks before sinking is run, since
> > > > sinking will only move the code to the existing blocks).
> 
> By the way, we're seeing a similar phenomenon later on in the compiler -
> during tree-outof-ssa some copies are inserted into a (previously empty)
> latch block. Later on, this prevents the modulo-scheduler at the RTL level
> from scheduling the loop. This seems to happen to all vectorizer testcases
> that have an unaligned load on powerpc. We generally generate the following
> code:
> 
>       v0 <-- vload
> loop:
>       v1 = phi <v0, v2>
>       v2 = vload
>       vx = realign_load <v1, v2>
>       use vx
>       if ... goto loop
> 
> When going out of ssa, the copy v1=v2 is inserted in the latch block.
> Any thought on where is the best place to handle this (is it possible to
> tweak tree-outof-ssa? or better try to clean it up just before sms?)

well, on ppc you would probably get the best code by unrolling the loop
twice, which makes it possible to eliminate the v1 = v2 copy completely:

       v1 <-- vload
 loop:
       v2 = vload
       vx = realign_load <v1, v2>
       use vx

       v1 = vload
       vx = realign_load <v2, v1>
       use vx

       if ... goto loop

As far as SMS is concerned, I guess the best would be to teach it to
handle loops with statements after exit; there is nothing that much
special about them.

Zdenek



More information about the Gcc-patches mailing list