[PATCH] Add support on powerpc to change CASE_VALUES_THRESHOLD

Richard Guenther richard.guenther@gmail.com
Fri Jul 1 07:57:00 GMT 2011


On Thu, Jun 30, 2011 at 7:06 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> On Thu, Jun 30, 2011 at 12:31:44PM +0200, Richard Guenther wrote:
>> On Thu, Jun 30, 2011 at 12:34 AM, Michael Meissner
>> <meissner@linux.vnet.ibm.com> wrote:
>> > On the powerpc, switch statements can be expensive, and we would like to be
>> > able to tune the threshold of when the compiler generates if statements
>> > vs. using a table jump operation (and different processors within the powerpc
>> > have different limits).  This patch adds a powerpc tuning option to control
>> > this.
>> >
>> > I've done bootstraps and make checks with no regressions.  Is this ok to apply
>> > to the trunk?  At this time, I am not changing the default value (4).  With the
>> > option, I've seen a few spec 2006 benchmarks run faster, and a few run slower.
>>
>> Hmm.  This hook looks like it could be turned into a --param.  In fact
>> it doesn't get whatever context information, so I wonder if any target
>> does something fancy.
>
> I've done it also as a --param.  I tend to think it is better as a param, and
> then other people can tune their code.  One slight problem is the default for
> CASE_VALUES_THRESHOLD depends on whether you have a named casesi pattern that
> is active (HAVE_casesi ? 4 : 5).  Either we need two separate parameters, or we
> have just one parameter, and if that is 0, fall back to the 4 or 5 value.
>
> This patch swtiches to use --param to set the value.  Is it acceptable to check
> in?  I've done a bootstrap and I'm about to do a make check.

Looks good to me.  Please leave others 24h to comment on the
special zero value (no idea if we have precedent for it, but it sounds
ok to me).

Thanks,
Richard.

> [gcc]
> 2011-06-30  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>        * params.def (PARAM_CASE_VALUES_THRESHOLD): New parameter to
>        override CASE_VALUES_THRESHOLD.
>
>        * stmt.c (toplevel): Include params.h.
>        (case_values_threshold): Use the --param case-values-threshold
>        value if non-zero, otherwise use machine dependent value.
>        (expand_case): Use case_values_threshold.
>
>        * Makefile.in (stmt.o): Add $(PARAMS_H) dependency.
>
>        * doc/invoke.texi (--param case-values-threshold): Document.
>
> [gcc/testsuite]
> 2011-06-30  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>        * gcc.target/powerpc/ppc-switch-1.c: New test for
>        -mcase-values-threshold.
>        * gcc.target/powerpc/ppc-switch-2.c: Ditto.
>
> --
> Michael Meissner, IBM
> 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
> meissner@linux.vnet.ibm.com     fax +1 (978) 399-6899
>



More information about the Gcc-patches mailing list