This is the mail archive of the gcc@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]

Re: Question re: SSA Aggressive Dead Code Elimination


Hi,

On Wed, 27 Jun 2001, Daniel Berlin wrote:

> The initial removing of the edge isn't strictly wrong, as long as you
> update the phi nodes accordingly.

Well, suppose, you initially had this code:
a=b+c;
if (a>d) { b=b+c; }
return b;

which is the back-translated RTL.  If you in this situation remove any
edge resulting from the compare, there is no way, that you still have the
same semantic as the above code.  That is why the removing of the edge
really was wrong from the beginning.
SSA-transformed and optimized this should be:
a=b1+c;
if (a>d) {;}
b2 = phi[b1, a];
return b2;

which translated back from SSA (and useless copies coalesced away) will
get:
a=b+c;
if (a>d) b=a;
return b;

I.e. you really need that edge up to the end (because that is the one on
which you insert a copy insn to eliminate the phi node, which because of
the non-criticality of that edge gets placed into the empty block).  If
you remove the edge, there is exactly one path from ENTRY to EXIT, whereas
originally there were two, doing different things, clearly not the same.
So my point is, that even if you fiddle with the PHI node, to make
everything correct SSA again, it nevertheless will not produce code having
the same semantic as the original one, which kind of breaks conservative
optimization approach ;-)


> Right.
> In no case can you just remove edges. You either have to update the
> phi nodes approriately, or not remove the edges.

Right too ;)  In this case not removing the edge.


Ciao,
Michael.


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