Removing bound checks from a switch statement

Henrik Mannerström
Thu Feb 18 16:32:00 GMT 2010

Quoting "Christoph Groth" <>:

> I do not know how to solve the problem you described, but another way of
> speeding up a switch statement might be using the GCC extension "Labels
> as Values".

Thank you very much! This was exactly what I was looking for.

I made a completely non-standard, spaghettisized version of the  
program and luckily it did not run any faster than the switch-based  
one, so I can stick to my -ansi option. The earlier reported speedup  
was probably just an outlier in the performance test.

Many thanks! Now I can put this behind me and work on other aspects.

More information about the Gcc-help mailing list