This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] Switch stmts and inserting on edges
- From: Andrew MacLeod <amacleod at redhat dot com>
- To: Michael Matz <matz at suse dot de>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: 30 May 2003 14:42:15 -0400
- Subject: Re: [tree-ssa] Switch stmts and inserting on edges
- References: <Pine.LNX.4.44.0305302020200.7303-100000@wotan.suse.de>
On Fri, 2003-05-30 at 14:25, Michael Matz wrote:
> Hi,
>
> On 30 May 2003, Andrew MacLeod wrote:
>
> > The problem is that the preceeding case stmt drops into the default
> > case. Arg. That means the default block has 2 predecessors, and the
> > switch stmt has multiple successors, so the only way to insert is to
> > split the edge.
> >
> > Splitting that edge is not trivial...
>
> It shouldn't be any more difficult, than splitting _any_
> (non-abnormal) edge.
>
> > Since it can't be properly split,
>
> Why not?
Well, not without mucking around in the switch stmt expression list
would be the qualifier.
>
> > Id have to go to all the other predecessors, change them to goto a label
> > that would be inserted after the stmt Im trying to insert.
>
> No, the way this would work is to preserve the old default label, to
> which the other blocks still have the edge, and instead redirect the
> target of the split edge (i.e. the switch->default) to be the new block,
> i.e.:
And I beleive thats the trick, I think its easier to change where the
fallthru edges go than it is change the switch->default..
>
> > case blah:
> > <...>
> > goto new_label;
> >
> > default:
> > <inserted_stmt>
> > new_label:
> > default code.
>
>
> case blah:
> <....>
> goto default;
> new_label:
> <inserted_stmt>
> default:
> default code.
>
>
> Then only the edge from the switch needs to be redirected to "new_label".
> Hmm, or is it not possible to replace the default label in this way due to
> some inhomogenity in tree-ssa's representation of switches?
>
I beleive the switch stmt has a list of case elements, and in order for
things to work, I'd have to arrange for the switch stmt to know that the
edge that use to go to a certain block now goes to a different block,
and I dont know how easy that is to map back to the switch case
expression's knowledge of its case targets. Thats the main reason I
asked, I was hoping someone who knew cases better in tree form would be
able to tell me I dont have to hack around like Im afraid Im going to
:-). I suspect in order to do that Id have to go in and start looking at
the case expressions... At least the one for thatr edge. Im hoping I m
wrong...
Andrew