This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Hashing of "switch/case" selections


Interesting comment. I will take it into account.

    Andy

Michael Meissner wrote:

> On Thu, Jan 04, 2001 at 01:39:10AM -0800, Zack Weinberg wrote:
> > On Wed, Dec 27, 2000 at 10:43:40PM -0600, Andy Walker wrote:
> > [much interesting stuff]
> > > My experience as a programmer is that programs are almost never written
> > > with switches to more than a few hundred cases.  I personally have never
> > > seen one.  More than that, and the programmer finds a more efficient,
> > > more readable, more maintainable solution, and he can do so because he
> > > has a deep knowledge of the problem that is unavailable to the
> > > compiler.  My seat-of-pants estimate is that 400 cases is a good, maybe
> > > even high, maximum for Hash evaluations.  A program containing a switch
> > > statement with more than 400 cases in it probably has enough other
> > > severe design problems that it will never be worth running anyway.
> >
> > This is true in my experience for code written by humans, but not
> > necessarily for machine-generated code.  Take a look at insn-attrtab.c
> > in your GCC build directory, or at cp/parse.c in the source tree.
>
> Some of the simulators in the gdb releases have the ability to build very giant
> switch tables to speed up decoding machine instructions, though we haven't
> built them with the largest tables in quite some time, because the compiler's
> memory was going into the gigabytes.
>
> At a former job, I recall hearing that they had built a profiler/simulator for
> the machine, and used a completely dense 65k element switch table.
>
> --
> Michael Meissner, Red Hat, Inc.  (GCC group)
> PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
> Work:     meissner@redhat.com           phone: +1 978-486-9304
> Non-work: meissner@spectacle-pond.org   fax:   +1 978-692-4482


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]