This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Why does gcc suck at switch()?
- From: law at redhat dot com
- To: Matthew Wilcox <willy at debian dot org>
- Cc: gcc at gcc dot gnu dot org, acpi-devel at lists dot sourceforge dot net
- Date: Sat, 11 Oct 2003 21:20:47 -0600
- Subject: Re: Why does gcc suck at switch()?
- Reply-to: law at redhat dot com
In message <20031003145614.GP24824@parcelfarce.linux.theplanet.co.uk>, Matthew
Wilcox writes:
>
>Why does gcc generate worse code for switch() statements than for
>multiple-if?
Because it apparently is trying to do the tests in range form rather
than naively generating a simple test for each case in the switch
(there's no way to actually verify that since you didn't provide a
complete testcase).
The range-forms can be more effective in some cases or at least that's
the claim. I'm not particularly familiar with that code so I've never
tried to re-tune it. [ I have noticed it generating spectacularly bad
code in certain circumstances, yours may just be another of those cases. ]
jeff