[tree-ssa] edge insertion/split problem

Andrew MacLeod amacleod@redhat.com
Tue Jun 17 13:23:00 GMT 2003


On Mon, 2003-06-16 at 19:37, Andrew MacLeod wrote:
> On Mon, 2003-06-16 at 19:29, law@redhat.com wrote:
> > In message <1055795716.8783.439.camel@p4>, Andrew MacLeod writes:
> 
> 
> >  >I think I prefer to handle it by adding a default: case, unless there is
> >  >strong objection. Then we keep the "nice clean" structure of the switch
> >  >:-) ha.
> > I don't have a strong objection.
> > 
> >  >I think I;ll just send you a patch later for the first try :-)
> > OK.  I'm going to go ahead and start checking in the known working
> > parts of the EH cleanup patch.  There's a fair number of bits that
> > can be broken out and installed with measurable benefits.  That should
> > keep me busy for the rest of today :-)
> 
> I wont get to it until late tonight now.  You should be able to give it
> a try in the morning. 
> 
Arg, here's a case where Im finding our containers to be a royal pain. 
You'd think adding a default case would be simple..

Turns out, nothing is simple here.

We have 2 choices. 
- Add a default case.
    In order to do that, we need to insert a default case at the end of
the SWITCH_BODY tree list. Thats doesn't seem like a problem. The
problem is redirecting any blocks which fallthru to the DEST block. I
struggled with this one for a while last night. In order to find out
which ones they are, we need to look at all the predecessors of DEST
which are *dominated* by the last case label in the list. Ick Ick. If
any of these are FALLTHRU edges, we have to add a GOTO the DEST block. 
Im really not crazy about using dominators to do this. That seems like
overkill.

- As Jeff suggested, look at all predecessors of the DEST block except
for SRC, and if they dont end in a GOTO, add a GOTO.
  The difficulty is that there can be an arbitrary number of them which
fall through.
  ie
  switch (A)
    {
     case 42:
       if (X)
           stmt1;
       else
         if (Y)
            stmt2;
         else
            stmt3;
    }
  DEST;
  
stmt1, stmt2, and stmt3 all fall through to the DEST block. 

As Im typing this, I got a flash <ouch>, and it occurs to me that I can
simply insert a GOTO DEST on each of these edges, if there isn't one
already. If there isn't one, it'll get added in the right place.  I
think That'll work fine.

I could check for the GOTO, and perhaps I will, but it is an extra call 

I think we'll find out shortly, Im going to try that right now.

Andrew



More information about the Gcc mailing list