Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-10-13 Thread Wilco Dijkstra
Jeff Law wrote: >> Btw reminds me a little bit of >> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=28417 > I wouldn't expect 28417 > to move forward without something other than Tege and Denys pushing on it. Hmm that doesn't look optimal. You can typically do a multiply with the magic constant

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-10-13 Thread Jeff Law
On 09/16/2017 03:39 PM, Bernhard Reutner-Fischer wrote: > On 15 September 2017 18:50:26 CEST, Jeff Law wrote: >> On 09/13/2017 03:20 PM, Wilco Dijkstra wrote: >>> Jeff Law wrote: On 09/06/2017 03:55 AM, Jackson Woodruff wrote: > On 08/30/2017 01:46 PM, Richard Biener

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-09-16 Thread Bernhard Reutner-Fischer
On 15 September 2017 18:50:26 CEST, Jeff Law wrote: >On 09/13/2017 03:20 PM, Wilco Dijkstra wrote: >> Jeff Law wrote: >>> On 09/06/2017 03:55 AM, Jackson Woodruff wrote: On 08/30/2017 01:46 PM, Richard Biener wrote: >> >rdivtmp = 1 / (y*C); >tem = x

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-09-15 Thread Jeff Law
On 09/13/2017 03:20 PM, Wilco Dijkstra wrote: > Jeff Law wrote: >> On 09/06/2017 03:55 AM, Jackson Woodruff wrote: >>> On 08/30/2017 01:46 PM, Richard Biener wrote: > rdivtmp = 1 / (y*C); tem = x *rdivtmp; tem2= z * rdivtmp; instead of rdivtmp = 1/y;

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-09-15 Thread Richard Biener
On Wed, Sep 13, 2017 at 11:20 PM, Wilco Dijkstra wrote: > Jeff Law wrote: >> On 09/06/2017 03:55 AM, Jackson Woodruff wrote: >> > On 08/30/2017 01:46 PM, Richard Biener wrote: > rdivtmp = 1 / (y*C); tem = x *rdivtmp; tem2= z * rdivtmp;

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-09-13 Thread Wilco Dijkstra
Jeff Law wrote: > On 09/06/2017 03:55 AM, Jackson Woodruff wrote: > > On 08/30/2017 01:46 PM, Richard Biener wrote: >>>   rdivtmp = 1 / (y*C); >>>   tem = x *rdivtmp; >>>   tem2= z * rdivtmp; >>> >>> instead of >>> >>>   rdivtmp = 1/y; >>>   tem = x * 1/C * rdivtmp; >>>   tem2 = z * 1/C *

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-09-13 Thread Jeff Law
On 09/06/2017 03:55 AM, Jackson Woodruff wrote: > On 08/30/2017 01:46 PM, Richard Biener wrote: >> On Wed, Aug 30, 2017 at 11:46 AM, Jackson Woodruff >> wrote: >>> On 08/29/2017 01:13 PM, Richard Biener wrote: On Tue, Aug 29, 2017 at 1:35 PM, Jackson

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-09-06 Thread Jackson Woodruff
On 08/30/2017 01:46 PM, Richard Biener wrote: On Wed, Aug 30, 2017 at 11:46 AM, Jackson Woodruff wrote: On 08/29/2017 01:13 PM, Richard Biener wrote: On Tue, Aug 29, 2017 at 1:35 PM, Jackson Woodruff wrote: Hi all, Apologies

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-30 Thread Richard Biener
On Wed, Aug 30, 2017 at 11:46 AM, Jackson Woodruff wrote: > On 08/29/2017 01:13 PM, Richard Biener wrote: >> >> On Tue, Aug 29, 2017 at 1:35 PM, Jackson Woodruff >> wrote: >>> >>> Hi all, >>> >>> Apologies again to those CC'ed, who

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-30 Thread Jackson Woodruff
On 08/29/2017 01:13 PM, Richard Biener wrote: On Tue, Aug 29, 2017 at 1:35 PM, Jackson Woodruff wrote: Hi all, Apologies again to those CC'ed, who (again) received this twice. Joseph: Yes you are correct. I misread the original thread, now fixed. Richard: I've

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-29 Thread Richard Biener
On Tue, Aug 29, 2017 at 1:35 PM, Jackson Woodruff wrote: > Hi all, > > Apologies again to those CC'ed, who (again) received this twice. > > Joseph: Yes you are correct. I misread the original thread, now fixed. > > Richard: I've moved the optimizations out of

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-29 Thread Jackson Woodruff
Hi all, Apologies again to those CC'ed, who (again) received this twice. Joseph: Yes you are correct. I misread the original thread, now fixed. Richard: I've moved the optimizations out of fold-const.c. One has been replicated in match.pd, and the other (x / C +- y / C -> (x +- y) / C) I've

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-24 Thread Jeff Law
On 08/17/2017 03:55 AM, Wilco Dijkstra wrote: > Richard Biener wrote: >> On Tue, Aug 15, 2017 at 4:11 PM, Wilco Dijkstra >> wrote: >>> Richard Biener wrote: > We also change the association of > > x / (y * C) -> (x / C) / y > > If C is a

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-17 Thread Joseph Myers
On Thu, 17 Aug 2017, Richard Biener wrote: > > Without global analysis it seems best to move constants/negates to the > > toplevel if they can't be trivially removed in a subexpression. Eg. -x > > / (a * b * -c). > > Sure. So both patterns are canonicalization which is fine for match.pd. >

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-17 Thread Richard Biener
On Thu, Aug 17, 2017 at 11:55 AM, Wilco Dijkstra wrote: > Richard Biener wrote: >> On Tue, Aug 15, 2017 at 4:11 PM, Wilco Dijkstra >> wrote: >> > Richard Biener wrote: > We also change the association of > > x / (y * C) -> (x /

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-17 Thread Wilco Dijkstra
Richard Biener wrote: > On Tue, Aug 15, 2017 at 4:11 PM, Wilco Dijkstra > wrote: > > Richard Biener wrote: >>> > We also change the association of >>> > >>> >  x / (y * C) -> (x / C) / y >>> > >>> > If C is a constant. >>> >>> Why's that profitable? >> >> It enables

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-17 Thread Richard Biener
On Tue, Aug 15, 2017 at 4:11 PM, Wilco Dijkstra wrote: > Richard Biener wrote: >> > We also change the association of >> > >> > x / (y * C) -> (x / C) / y >> > >> > If C is a constant. >> >> Why's that profitable? > > It enables (x * C1) / (y * C2) -> (x * C1/C2) / y

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-15 Thread Wilco Dijkstra
Richard Biener wrote: > > We also change the association of > > > >  x / (y * C) -> (x / C) / y > > > > If C is a constant. > > Why's that profitable? It enables (x * C1) / (y * C2) -> (x * C1/C2) / y for example. Also 1/y is now available to the reciprocal optimization, see

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-15 Thread Richard Biener
On Thu, Aug 10, 2017 at 4:09 PM, Jackson Woodruff wrote: > Hi all, > > The patch implements the division opitmizations discussed in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026 . > > The implemented change differs slightly from the > proposed one in that we

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-10 Thread Joseph Myers
On Thu, 10 Aug 2017, Jackson Woodruff wrote: > > We also change: > > > > x / (- y) -> (-x) / y > > > > Which requires -fno-trapping-math. I don't see why that requires -fno-trapping-math. The exceptions should be identical from both variants, as should the result, as far as defined by C

Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-10 Thread Jackson Woodruff
And have now attached that patch. Jackson On 08/10/2017 03:09 PM, Jackson Woodruff wrote: Hi all, The patch implements the division opitmizations discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026 . The implemented change differs slightly from the proposed one in that we

[PATCH] Factor out division by squares and remove division around comparisons (1/2)

2017-08-10 Thread Jackson Woodruff
Hi all, The patch implements the division opitmizations discussed in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026 . The implemented change differs slightly from the proposed one in that we re-associate: C / x comparison 0.0 -> x comparison' 0.0 Where C is any constant and