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: fche at redhat dot com (Frank Ch. Eigler)
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>
- Date: 30 May 2003 14:08:50 -0400
- Subject: Re: [tree-ssa] Switch stmts and inserting on edges
- References: <1054308237.15548.195.camel@p4>
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