Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-03-06 Thread Ramana Radhakrishnan
Hi Prathamesh, Could you split out the ARM specific portions into a separate patch please in a patch series? >@deftypefn {Target Hook} void TARGET_EXPAND_DIVMOD_LIBFUNC (bool >@var{unsignedp}, machine_mode @var{mode}, @var{rtx}, @var{rtx}, rtx >*@var{quot}, rtx *@var{rem}) >Expand divmod libfun

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-31 Thread Jim Wilson
On Fri, Jan 29, 2016 at 12:09 AM, Richard Biener wrote: > I wonder if rather than introducing a target hook ports could use > a define_expand expanding to a libcall for this case? Of the two divmod libcall APIs, one requires a stack temporary, which would be awkward to allocate in a define_expand

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-31 Thread Jim Wilson
On Sun, Jan 31, 2016 at 8:43 PM, Jim Wilson wrote: >> Are we certain that the libcall is a win for any target? >> I would have expected a default of >> q = x / y >> r = x - (q * y) >> to be most efficient on modern machines. Even more so on targets like ARM >> that have multiply-a

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-31 Thread Jim Wilson
On Sun, Jan 31, 2016 at 2:15 PM, Richard Henderson wrote: > On 01/29/2016 12:37 AM, Richard Biener wrote: >>> >>> To workaround this, I defined a new hook expand_divmod_libfunc, which >>> targets must override for expanding call to target-specific dimovd. >>> The "default" hook default_expand_divm

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-31 Thread Richard Henderson
On 01/29/2016 12:37 AM, Richard Biener wrote: To workaround this, I defined a new hook expand_divmod_libfunc, which targets must override for expanding call to target-specific dimovd. The "default" hook default_expand_divmod_libfunc() expands call to libgcc2.c:__udivmoddi4() since that's the only

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-29 Thread Richard Biener
On Thu, 28 Jan 2016, Jim Wilson wrote: > On Thu, Jan 28, 2016 at 5:37 AM, Richard Biener wrote: > >> To workaround this, I defined a new hook expand_divmod_libfunc, which > >> targets must override for expanding call to target-specific dimovd. > >> The "default" hook default_expand_divmod_libfunc

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-28 Thread Jim Wilson
On Thu, Jan 28, 2016 at 5:37 AM, Richard Biener wrote: >> To workaround this, I defined a new hook expand_divmod_libfunc, which >> targets must override for expanding call to target-specific dimovd. >> The "default" hook default_expand_divmod_libfunc() expands call to >> libgcc2.c:__udivmoddi4() s

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-28 Thread Richard Biener
On Wed, 27 Jan 2016, Prathamesh Kulkarni wrote: > On 11 November 2015 at 19:04, Richard Biener wrote: > > On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > > > >> On 11 November 2015 at 16:03, Richard Biener wrote: > >> > On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > >> > > >> >> On 10 Novem

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2016-01-27 Thread Prathamesh Kulkarni
On 11 November 2015 at 19:04, Richard Biener wrote: > On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > >> On 11 November 2015 at 16:03, Richard Biener wrote: >> > On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: >> > >> >> On 10 November 2015 at 20:11, Richard Biener wrote: >> >> > On Mon, 9 Nov

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-11 Thread Richard Biener
On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > On 11 November 2015 at 16:03, Richard Biener wrote: > > On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > > > >> On 10 November 2015 at 20:11, Richard Biener wrote: > >> > On Mon, 9 Nov 2015, Prathamesh Kulkarni wrote: > >> > > >> >> On 4 Novembe

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-11 Thread Prathamesh Kulkarni
On 11 November 2015 at 16:03, Richard Biener wrote: > On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > >> On 10 November 2015 at 20:11, Richard Biener wrote: >> > On Mon, 9 Nov 2015, Prathamesh Kulkarni wrote: >> > >> >> On 4 November 2015 at 20:35, Richard Biener wrote: >> >> > >> >> > Btw, di

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-11 Thread Richard Biener
On Wed, 11 Nov 2015, Prathamesh Kulkarni wrote: > On 10 November 2015 at 20:11, Richard Biener wrote: > > On Mon, 9 Nov 2015, Prathamesh Kulkarni wrote: > > > >> On 4 November 2015 at 20:35, Richard Biener wrote: > >> > > >> > Btw, did you investigate code gen differences on x86_64/i586? That >

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-11 Thread Prathamesh Kulkarni
On 10 November 2015 at 20:11, Richard Biener wrote: > On Mon, 9 Nov 2015, Prathamesh Kulkarni wrote: > >> On 4 November 2015 at 20:35, Richard Biener wrote: >> > >> > Btw, did you investigate code gen differences on x86_64/i586? That >> > target expands all divisions/modulo ops via divmod, relyi

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-10 Thread Richard Sandiford
Richard Biener writes: > On Mon, 9 Nov 2015, Prathamesh Kulkarni wrote: >> c) Gating the divmod transform - >> I tried gating it on checks for optab_handlers on div and mod, however >> this doesn't enable transform for arm cortex-a9 >> anymore (cortex-a9 doesn't have hardware instructions for inte

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-10 Thread Richard Biener
On Mon, 9 Nov 2015, Prathamesh Kulkarni wrote: > On 4 November 2015 at 20:35, Richard Biener wrote: > > > > Btw, did you investigate code gen differences on x86_64/i586? That > > target expands all divisions/modulo ops via divmod, relying on CSE > > solely as the HW always computes both div and

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-09 Thread Prathamesh Kulkarni
On 4 November 2015 at 20:35, Richard Biener wrote: > On Wed, 4 Nov 2015, Prathamesh Kulkarni wrote: > >> On 2 November 2015 at 18:31, Richard Biener wrote: >> > On Mon, 2 Nov 2015, Prathamesh Kulkarni wrote: >> > >> >> On 2 November 2015 at 13:20, Prathamesh Kulkarni >> >> wrote: >> >> > On 30 O

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-04 Thread Richard Biener
On Wed, 4 Nov 2015, Prathamesh Kulkarni wrote: > On 2 November 2015 at 18:31, Richard Biener wrote: > > On Mon, 2 Nov 2015, Prathamesh Kulkarni wrote: > > > >> On 2 November 2015 at 13:20, Prathamesh Kulkarni > >> wrote: > >> > On 30 October 2015 at 15:57, Richard Biener > >> > wrote: > >> >>

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-03 Thread Prathamesh Kulkarni
On 2 November 2015 at 18:31, Richard Biener wrote: > On Mon, 2 Nov 2015, Prathamesh Kulkarni wrote: > >> On 2 November 2015 at 13:20, Prathamesh Kulkarni >> wrote: >> > On 30 October 2015 at 15:57, Richard Biener >> > wrote: >> >> On Fri, Oct 30, 2015 at 8:39 AM, Prathamesh Kulkarni >> >> wrot

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-02 Thread Richard Biener
On Mon, 2 Nov 2015, Prathamesh Kulkarni wrote: > On 2 November 2015 at 13:20, Prathamesh Kulkarni > wrote: > > On 30 October 2015 at 15:57, Richard Biener > > wrote: > >> On Fri, Oct 30, 2015 at 8:39 AM, Prathamesh Kulkarni > >> wrote: > >>> Hi, > >>> I have attached revamped version of Kugan'

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-02 Thread Prathamesh Kulkarni
On 2 November 2015 at 13:20, Prathamesh Kulkarni wrote: > On 30 October 2015 at 15:57, Richard Biener > wrote: >> On Fri, Oct 30, 2015 at 8:39 AM, Prathamesh Kulkarni >> wrote: >>> Hi, >>> I have attached revamped version of Kugan's patch >>> (https://gcc.gnu.org/ml/gcc/2013-06/msg00100.html) f

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-11-01 Thread Prathamesh Kulkarni
On 30 October 2015 at 15:57, Richard Biener wrote: > On Fri, Oct 30, 2015 at 8:39 AM, Prathamesh Kulkarni > wrote: >> Hi, >> I have attached revamped version of Kugan's patch >> (https://gcc.gnu.org/ml/gcc/2013-06/msg00100.html) for PR43721. >> Test-case: http://pastebin.com/QMfpXLD9 >> divmod pa

Re: [RFC PR43721] Optimize a/b and a%b to single divmod call

2015-10-30 Thread Richard Biener
On Fri, Oct 30, 2015 at 8:39 AM, Prathamesh Kulkarni wrote: > Hi, > I have attached revamped version of Kugan's patch > (https://gcc.gnu.org/ml/gcc/2013-06/msg00100.html) for PR43721. > Test-case: http://pastebin.com/QMfpXLD9 > divmod pass dump: http://pastebin.com/yMY1ikCp > Assembly: http://past

[RFC PR43721] Optimize a/b and a%b to single divmod call

2015-10-30 Thread Prathamesh Kulkarni
Hi, I have attached revamped version of Kugan's patch (https://gcc.gnu.org/ml/gcc/2013-06/msg00100.html) for PR43721. Test-case: http://pastebin.com/QMfpXLD9 divmod pass dump: http://pastebin.com/yMY1ikCp Assembly: http://pastebin.com/kk2HZpvA The approach I took is similar to sincos pass, which i