Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-21 Thread Jeff Law
On 05/02/2018 04:05 PM, Jim Wilson wrote: > This improves the code for a switch statement on targets that sign-extend > function arguments, such as RISC-V. Given a simple testcase > > extern void asdf(int); > void foo(int x) { > switch (x) { > case 0: asdf(10); break; > case 1: asdf(11);

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-17 Thread Jim Wilson
On Thu, May 17, 2018 at 12:25 AM, Eric Botcazou wrote: > The patch looks OK to me, modulo: > >> + && ! (INTVAL (range) & (HOST_WIDE_INT_1U << (width - 1 > > I'd use UINTVAL instead of INTVAL here. Thanks. Committed with that change. Jim

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-17 Thread Eric Botcazou
> The following patch implements this optimization. It checks for a range > that does not have the sign-bit set, and an index value that is already > sign extended, and then does a sign extend instead of an zero extend. > > This has been tested with a riscv{32,64}-{elf,linux} builds and

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-16 Thread Jim Wilson
On Wed, May 9, 2018 at 2:20 PM, Jim Wilson wrote: > On Wed, May 2, 2018 at 3:05 PM, Jim Wilson wrote: >> This improves the code for a switch statement on targets that sign-extend >> function arguments, such as RISC-V. Given a simple testcase >> ... >>

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-09 Thread Jim Wilson
On Wed, May 2, 2018 at 3:05 PM, Jim Wilson wrote: > This improves the code for a switch statement on targets that sign-extend > function arguments, such as RISC-V. Given a simple testcase > ... > gcc/ > * expr.c (do_tablejump): When converting index to Pmode, if

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-04 Thread Richard Biener
On Thu, May 3, 2018 at 11:29 PM, Jim Wilson wrote: > On Thu, May 3, 2018 at 12:29 AM, Richard Biener > wrote: >> Just as a note, IIRC all the SUBREG_PROMOTED_* stuff is quite fragile >> - I remember >> Eric fixing things up a bit but some verification

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-03 Thread Jim Wilson
On Thu, May 3, 2018 at 12:29 AM, Richard Biener wrote: > Just as a note, IIRC all the SUBREG_PROMOTED_* stuff is quite fragile > - I remember > Eric fixing things up a bit but some verification would be nice to > have (instrumentation > at RTL level that for

Re: [PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-03 Thread Richard Biener
On Thu, May 3, 2018 at 12:05 AM, Jim Wilson wrote: > This improves the code for a switch statement on targets that sign-extend > function arguments, such as RISC-V. Given a simple testcase > > extern void asdf(int); > void foo(int x) { > switch (x) { > case 0: asdf(10);

[PATCH 1/2, expr.c] Optimize switch with sign-extended index.

2018-05-02 Thread Jim Wilson
This improves the code for a switch statement on targets that sign-extend function arguments, such as RISC-V. Given a simple testcase extern void asdf(int); void foo(int x) { switch (x) { case 0: asdf(10); break; case 1: asdf(11); break; case 2: asdf(12); break; case 3: asdf(13);