Re: Optimization of "switch" stmt in C

George Russell <ger@informatik.uni-nospam-bremen.de>
24 Sep 1999 22:55:19 -0400

          From comp.compilers

Related articles
Optimization of "switch" stmt in C mayur_naik@my-deja.com (1999-09-20)
Re: Optimization of "switch" stmt in C ast@halcyon.com (Andrew Tucker) (1999-09-20)
Re: Optimization of "switch" stmt in C jejones@microware.com (James Jones) (1999-09-20)
Re: Optimization of "switch" stmt in C jcownie@etnus.com (James Cownie) (1999-09-24)
Re: Optimization of "switch" stmt in C ger@informatik.uni-nospam-bremen.de (George Russell) (1999-09-24)
Re: Optimization of "switch" stmt in C vmakarov@cygnus.com (Vladimir Makarov) (1999-09-24)
Re: Optimization of "switch" stmt in C danielv@crt.umontreal.ca (Daniel Villeneuve) (1999-09-27)
Re: Optimization of "switch" stmt in C drh@microsoft.com (Dave Hanson) (1999-09-28)
Re: Optimization of "switch" stmt in C cmilner@virginia.edu (Christopher W. Milner) (1999-10-01)
| List of all articles for this month |

From: George Russell <ger@informatik.uni-nospam-bremen.de>
Newsgroups: comp.compilers
Date: 24 Sep 1999 22:55:19 -0400
Organization: Universitaet Bremen, Germany
References: 99-09-081 99-09-084
Keywords: C, code

mayur_naik@my-deja.com wrote:
> Could any one give me references to web-sites / papers / books
> which discuss the optimization of the "switch" stmt in C?
C is a long way from being the only language with a switch statement.


About 9 years ago, I read a paper published in the late 70s in, I
think, one of the Algol journals. I'm sorry this is a spectacularly
unhelpful reference but if you browse for a few hours in the
periodicals section of a good Computer Science library, I'd say you
had a good chance of finding it. Anyway the paper gave a general
dynamic-programming algorithm for finding the optimal (or for all I
can remember, near-optimal) mix of table lookup, binary trees, and
checking for equality. If you are really going to go all out, maybe
you need something like that.


As I say, I'm really sorry I can't give a better reference, but as
this is surely old stuff to a lot of people, I suspect someone in
comp.compilers can be a bit more precise. Or else surely GCC or some
such compiler must have such an algorithm buried in it, if you can be
bothered to hunt it down.


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.