This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH] Implement switch statements with bit tests


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>


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