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] Switch stmts and inserting on edges


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?

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

> 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?


Ciao,
Michael.


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