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]
Other format: [Raw text]

Re: [tree-ssa] edge insertion/split problem


In message <1055795716.8783.439.camel@p4>, Andrew MacLeod writes:
 >The problem we are having here is the code to handle switch stmt's is
 >assuming the edge from SWITCH is going to a CASE.  IN this example,
 >there is an edge to the fallthrough block. Hmm. No empty default case
 >huh? that would be nice and consistant. I wasn't thinking we ever had to
 >deal with SWITCH->fallthrough case. Clearly that will need to be handled
 >differently.
 >
 >umm. So that should be the only edge from the SWITCH block marked
 >FALLTHRU right?
I think so.


 >If so, then it can be handled without too much hassle, and yes, we'll
 >need to insert goto's from all the cases.. what a pain. Are you sure we
 >don't just want to always have a "default" case block? :-) 
Well, there's a certain simplicity in that :-)  It does affect code
generation though (and not in a good way).   Or at least it used to.
I vaguely remembering someone poking at that problem recently.

[ The basic idea being if the head and tails of the explicit case values
  have the same target as the default, then those explicit case values
  can be eliminated since they are indistinguishable from the default
  case value. ]

 > Actually, maybe that is the easiest way to do it. We add an ELSE block
 >on the fallthrough edge from a COND_EXPR if one doesn't exist. If a
 >FALLTHRU block exists for a SWITCH, that means there is no default case
 >right? So we can turn any code on that edge into a DEFAULT case... n'est
 >pas?  Then no farting around with goto's.
 >
 >DO I have to fudge much crap to do that?. I suppose the last case in the
 >switch might need a 'break' goto inserted. 
Unknown.  Rather than making it the last case, I'd make it the first
case and have an explicit break at the end of the default.  That saves
you from having to muck around with the code for any of the other
case values.

As you ask, the interesting question is how much work would be necessary
to make that work.  I don't really know offhand.

 >- Find the last stmt in the last case.. is there a simple way to do
 >that?) 
Unknown.

 >- if it isn't a 'goto', add a 'goto the label in DEST block'.
 >- Create new block. Add default case. Insert code here. 
Seems reasonable.  Note I think we have two case lists.

 >When I change the edge from the switch to the default case, do I need to
 >do anything else to have it recognize it, or is that it?
I don't think you'd have to do anything else.

 >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 :-)


Jeff


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