optimization of switch statements on i386

Godmar Back godmar@gmail.com
Mon Feb 11 19:52:00 GMT 2008


Even if I placed a call to a 'noreturn' function in the default: case,
the compiler couldn't optimize the default branch away. (It won't
produce any code to continue after the function call, but my desire is
to eliminate the test leading to the default: branch.)

Following on the original topic of discussion, how about if I use
computed gotos?

If the reasoning of gcc's developers is correct, and it's the lack of
a casesi instruction on x86 that set the minimum of arm to use a table
jump to 5, then I may be able to produce faster code for 4 arms using
computed gotos; especially since I cannot convince gcc to eliminate
the check for the default case. Do you agree with that?

 - Godmar

On Feb 11, 2008 1:47 PM, Diego Novillo <dnovillo@google.com> wrote:
> On 11 Feb 2008 09:54:19 -0800, Ian Lance Taylor <iant@google.com> wrote:
>
> >  gcc_unreachable means nothing special to gcc.
>
> But it does have control-flow connotations.  The function ultimately
> expands into fancy_abort, which is marked noreturn. We do use that
> fact in the optimizer.
>
>
> Diego.
>



More information about the Gcc-help mailing list