This is the mail archive of the
mailing list for the GCC project.
Re: switch statement performance
- From: Ian Lance Taylor <ian at wasabisystems dot com>
- To: Paul Vixie <paul at vix dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: 20 Jan 2004 22:54:44 -0500
- Subject: Re: switch statement performance
- References: <20040121002918.9D03014C58@sa.vix.com>
Paul Vixie <firstname.lastname@example.org> writes:
> > You see, the generated code shouldn't be equivalent to an if-else
> > chain. It's supposed to be a binary tree, which would be only at most
> > 6 or 7 branches deep (well, I think we actually do a binary tree for
> > the outside conditions, and then an if-else chain for the inner ones,
> > since not-taken branches are cheaper), and therefore shouldn't have
> > particularly bad performance.
> how long as it been doing this?
For more than ten years.
> so if i have to compile stuff like this on non-gcc platforms (like native
> solaris and tru64 which a lot of bind users seem to have) i'll be at the
> mercy of their compilers?
Well, yes. Though probably their compilers are just fine.
I think it's asking a bit much for gcc to tell you when code might be
poorly compiled by some other compiler.