Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-02-27 Thread Segher Boessenkool
Hi! On Sun, Feb 26, 2023 at 01:10:41PM -, Roger Sayle wrote: > This patch teaches simplify-rtx.cc to err on the side of caution, by never > creating (new) FFS, POPCOUNT or PARITY rtx with mismatched modes, > matching the documentation. > * simplify-rtx.cc

RE: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-02-26 Thread Roger Sayle
Boessenkool' > ; Roger Sayle > Cc: 'GCC Patches' > Subject: Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY. > > On Sun, Jan 01, 2023 at 03:55:26PM -, Roger Sayle wrote: > > In 2011, the rtl.texi documentation was updated to reflect that the > > modes of

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-02-21 Thread Jakub Jelinek via Gcc-patches
On Sun, Jan 01, 2023 at 03:55:26PM -, Roger Sayle wrote: > In 2011, the rtl.texi documentation was updated to reflect that the > modes of the RTX unary operations FFS, POPCOUNT and PARITY must > match those of their operands. Unfortunately, some of the transformations > in simplify-rtx.cc

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-03 Thread Segher Boessenkool
On Mon, Jan 02, 2023 at 09:20:33AM -0700, Jeff Law wrote: > On 1/2/23 08:59, Jakub Jelinek wrote: > >See the PR50161 thread in > >https://gcc.gnu.org/legacy-ml/gcc-patches/2011-08/threads.html#01847 Nasty nasty nasty. > >The options are to disallow different modes, which is what my patch did >

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread Jeff Law via Gcc-patches
On 1/2/23 10:30, ro...@nextmovesoftware.com wrote: Hi Jeff, On 2 Jan 2023, at 15:45, Jeff Law wrote: On 1/1/23 08:55, Roger Sayle wrote: In 2011, the rtl.texi documentation was updated to reflect that the modes of the RTX unary operations FFS, POPCOUNT and PARITY must match those of

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread Jeff Law via Gcc-patches
On 1/2/23 10:22, Jakub Jelinek wrote: On Mon, Jan 02, 2023 at 09:20:33AM -0700, Jeff Law wrote: In fact Raphael and I were about to submit a patch which takes advantage of that capability to improve the code slightly for risc-v. Just use a pattern with zero_extend or sign_extend around it

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread ro...@nextmovesoftware.com
Hi Jeff, > On 2 Jan 2023, at 15:45, Jeff Law wrote: > On 1/1/23 08:55, Roger Sayle wrote: >> In 2011, the rtl.texi documentation was updated to reflect that the >> modes of the RTX unary operations FFS, POPCOUNT and PARITY must >> match those of their operands. Unfortunately, some of the

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread Jakub Jelinek via Gcc-patches
On Mon, Jan 02, 2023 at 09:20:33AM -0700, Jeff Law wrote: > > > In fact Raphael and I were about to submit a patch which takes advantage > > > of > > > that capability to improve the code slightly for risc-v. > > > > Just use a pattern with zero_extend or sign_extend around it or subreg of > >

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread Jeff Law via Gcc-patches
On 1/2/23 08:59, Jakub Jelinek wrote: On Mon, Jan 02, 2023 at 08:45:15AM -0700, Jeff Law via Gcc-patches wrote: On 1/1/23 08:55, Roger Sayle wrote: In 2011, the rtl.texi documentation was updated to reflect that the modes of the RTX unary operations FFS, POPCOUNT and PARITY must match those

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread Jakub Jelinek via Gcc-patches
On Mon, Jan 02, 2023 at 08:45:15AM -0700, Jeff Law via Gcc-patches wrote: > On 1/1/23 08:55, Roger Sayle wrote: > > In 2011, the rtl.texi documentation was updated to reflect that the > > modes of the RTX unary operations FFS, POPCOUNT and PARITY must > > match those of their operands.

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-02 Thread Jeff Law via Gcc-patches
On 1/1/23 08:55, Roger Sayle wrote: In 2011, the rtl.texi documentation was updated to reflect that the modes of the RTX unary operations FFS, POPCOUNT and PARITY must match those of their operands. Unfortunately, some of the transformations in simplify-rtx.cc predate this tightening of RTL

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-01 Thread ro...@nextmovesoftware.com
The motivation for the current design (requiring the result and the operand to have the same mode) was from PR middle-end/50161. The challenge there is that when the RTL optimizers can determine that the operand is a constant, simplify_rtx sees just a CONST_INT with VOIDmode and therefore

Re: [PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-01 Thread Segher Boessenkool
Hi! On Sun, Jan 01, 2023 at 03:55:26PM -, Roger Sayle wrote: > In 2011, the rtl.texi documentation was updated to reflect that the > modes of the RTX unary operations FFS, POPCOUNT and PARITY must > match those of their operands. Is that not a limitation we should try to get rid of? It does

[PATCH] Fix RTL simplifications of FFS, POPCOUNT and PARITY.

2023-01-01 Thread Roger Sayle
In 2011, the rtl.texi documentation was updated to reflect that the modes of the RTX unary operations FFS, POPCOUNT and PARITY must match those of their operands. Unfortunately, some of the transformations in simplify-rtx.cc predate this tightening of RTL semantics, and have not (until now) been