Re: RISC-V: Add divmod instruction support

2023-04-28 Thread Jeff Law via Gcc-patches
On 2/17/23 07:02, Matevos Mehrabyan via Gcc-patches wrote: Hi all, If we have division and remainder calculations with the same operands: a = b / c; d = b % c; We can replace the calculation of remainder with multiplication + subtraction, using the result from the previous division:

Re: RISC-V: Add divmod instruction support

2023-02-28 Thread Maciej W. Rozycki
On Mon, 20 Feb 2023, Alexander Monakov wrote: > > > That's the kind of stuff I'd expect to happen at the tree level though, > > > before expand. > > > > The GIMPLE pass forming divmod could indeed choose to emit the > > div + mul/sub sequence instead if an actual divmod pattern isn't available.

Re: RISC-V: Add divmod instruction support

2023-02-20 Thread Alexander Monakov via Gcc-patches
On Mon, 20 Feb 2023, Richard Biener via Gcc-patches wrote: > On Sun, Feb 19, 2023 at 2:15 AM Maciej W. Rozycki wrote: > > > > > The problem is you don't see it as a divmod in expand_divmod unless you > > > expose > > > a divmod optab. See tree-ssa-mathopts.cc's divmod handling. > > > > That'

Re: RISC-V: Add divmod instruction support

2023-02-20 Thread Richard Biener via Gcc-patches
On Sun, Feb 19, 2023 at 2:15 AM Maciej W. Rozycki wrote: > > On Sat, 18 Feb 2023, Jeff Law wrote: > > > > Barring the fusion case, which indeed asks for a dedicated `divmod' > > > pattern (and then I suppose a post-reload splitter or a peephole so that > > > where one of the two results produced

Re: RISC-V: Add divmod instruction support

2023-02-20 Thread Andrew Waterman via Gcc-patches
On Sat, Feb 18, 2023 at 1:30 PM Palmer Dabbelt wrote: > > On Sat, 18 Feb 2023 13:06:02 PST (-0800), jeffreya...@gmail.com wrote: > > > > > > On 2/18/23 11:26, Palmer Dabbelt wrote: > >> On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: > >>> Hi all, > >>> If we have division

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Maciej W. Rozycki
On Sat, 18 Feb 2023, Jeff Law wrote: > > Barring the fusion case, which indeed asks for a dedicated `divmod' > > pattern (and then I suppose a post-reload splitter or a peephole so that > > where one of the two results produced has eventually turned out unused, we > > have means to discard the u

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Jeff Law via Gcc-patches
On 2/18/23 14:30, Palmer Dabbelt wrote: On Sat, 18 Feb 2023 13:06:02 PST (-0800), jeffreya...@gmail.com wrote: On 2/18/23 11:26, Palmer Dabbelt wrote: On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: Hi all, If we have division and remainder calculations with the s

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Palmer Dabbelt
On Sat, 18 Feb 2023 13:06:02 PST (-0800), jeffreya...@gmail.com wrote: On 2/18/23 11:26, Palmer Dabbelt wrote: On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: Hi all, If we have division and remainder calculations with the same operands:   a = b / c;   d = b % c; We

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Jeff Law via Gcc-patches
On 2/18/23 12:31, Maciej W. Rozycki wrote: On Sat, 18 Feb 2023, Andrew Pinski via Gcc-patches wrote: If we have division and remainder calculations with the same operands: a = b / c; d = b % c; We can replace the calculation of remainder with multiplication + subtraction, using the r

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Jeff Law via Gcc-patches
On 2/18/23 11:26, Palmer Dabbelt wrote: On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: Hi all, If we have division and remainder calculations with the same operands:   a = b / c;   d = b % c; We can replace the calculation of remainder with multiplication + subtrac

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Prathamesh Kulkarni via Gcc-patches
On Sun, 19 Feb 2023 at 01:01, Maciej W. Rozycki wrote: > > On Sat, 18 Feb 2023, Andrew Pinski via Gcc-patches wrote: > > > > > If we have division and remainder calculations with the same operands: > > > > > > > > a = b / c; > > > > d = b % c; > > > > > > > > We can replace the calculation of

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Maciej W. Rozycki
On Sat, 18 Feb 2023, Andrew Pinski via Gcc-patches wrote: > > > If we have division and remainder calculations with the same operands: > > > > > > a = b / c; > > > d = b % c; > > > > > > We can replace the calculation of remainder with multiplication + > > > subtraction, using the result from

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Palmer Dabbelt
On Sat, 18 Feb 2023 10:42:51 PST (-0800), pins...@gmail.com wrote: On Sat, Feb 18, 2023 at 10:27 AM Palmer Dabbelt wrote: On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: > Hi all, > If we have division and remainder calculations with the same operands: > > a = b / c;

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Andrew Pinski via Gcc-patches
On Sat, Feb 18, 2023 at 10:27 AM Palmer Dabbelt wrote: > > On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: > > Hi all, > > If we have division and remainder calculations with the same operands: > > > > a = b / c; > > d = b % c; > > > > We can replace the calculation of

Re: RISC-V: Add divmod instruction support

2023-02-18 Thread Palmer Dabbelt
On Fri, 17 Feb 2023 06:02:40 PST (-0800), gcc-patches@gcc.gnu.org wrote: Hi all, If we have division and remainder calculations with the same operands: a = b / c; d = b % c; We can replace the calculation of remainder with multiplication + subtraction, using the result from the previous div

RISC-V: Add divmod instruction support

2023-02-17 Thread Matevos Mehrabyan via Gcc-patches
Hi all, If we have division and remainder calculations with the same operands: a = b / c; d = b % c; We can replace the calculation of remainder with multiplication + subtraction, using the result from the previous division: a = b / c; d = a * c; d = b - d; Which will be faster. Curre