This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: switch statement performance
- From: Paul Vixie <paul at vix dot com>
- To: gcc at gcc dot gnu dot org
- Date: Wed, 21 Jan 2004 00:29:18 +0000
- Subject: Re: switch statement performance
> Could you explain a bit more?
>
> 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?
> Was the 'uglier code' particularly simple?
the ugly code was particularly ugly.
> Ideally, we'd like to have GCC generate efficient code automatically;
> maybe not quite as clever as the programmer would have, but there
> shouldn't be a factor of 1000 unless the programmer's *really* clever
> :-).
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?