This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Implement switch statements with bit tests
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Roger Sayle <roger at www dot eyesopen dot com>
- Cc: Andi Kleen <ak at suse dot de>, Jan Hubicka <jh at suse dot cz>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 23 Jan 2003 21:34:51 -0800
- Subject: Re: [PATCH] Implement switch statements with bit tests
- References: <Pine.LNX.4.44.0301231845570.16282-100000@www.eyesopen.com>
Roger Sayle <roger@www.eyesopen.com> writes:
OK, I see. This is for switches with few code blocks compared to the
number of entries.
> The one caveat to the above approach is that this is only a win
> if the target provides an efficient instruction to perform 1<<x.
> To account for this, I introduce a new target macro that allows
> backends to disable this implementation strategy. The default
> value of CASE_USE_BIT_TESTS checks the optabs to see if the
> target .md defines an ashlsi3 pattern. This is a heuristic, as
> I suspect there may be targets that define ashlsi3 but actually
> implement it via an inlined loop or a library call. On these
> targets, the patch below will not affect correctness, but may
> negatively impact performance unless the target's .h file is
> tweaked to contain the line:
>
> #define CASE_USE_BIT_TESTS 0
>
> [Is there a better way to test for an efficient left shift insn?]
Yes, there is. Use rtx_cost().
> The following patch has been tested by a complete bootstrap, all
> languages except Ada and treelang, on i686-pc-linux-gnu with no
> new regressions. It has also been bootstrapped on i686-pc-cygwin.
>
> Ok for mainline?
Other than using rtx_cost instead of inventing a new macro, this all
looks good.
--
- Geoffrey Keating <geoffk@geoffk.org>