[tree-ssa] Switch stmts and inserting on edges
Frank Ch. Eigler
fche@redhat.com
Fri May 30 18:42:00 GMT 2003
amacleod wrote:
> [...]
> I have an edge from the switch stmt to the default case that I need to
> insert a copy on.
> [...]
> case blah:
> <...>
> goto new_label;
>
> default:
> <inserted_stmt>
> new_label:
> default code.
> [...]
That's not bad - it's only needed if the previous case falls through.
> Any other suggestions? I havent thought of anything I actually like....
How about forking the switch() into two, with the first one containing
the inserted statement?
switch (expr)
{
case <1...N>: break;
default: <inserted_stmt>
}
switch (expr)
{
<unmodified>
}
... or using a temporary variable as a flag?
switch (expr)
{
int default_fallthrough = 0;
case <1..M>: break;
case <N>: stmt; stmt; /* fallthrough */
default_fallthrough = 1;
default:
if (! default_fallthrough) { <inserted_stmt> }
<old default code>
}
- FChE
More information about the Gcc
mailing list