Removing bound checks from a switch statement

Henrik Mannerström henrik.mannerstrom@helsinki.fi
Thu Feb 18 16:32:00 GMT 2010


Quoting "Christoph Groth" <cwg@falma.de>:

> 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".
>
> http://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html

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



More information about the Gcc-help mailing list