This is the mail archive of the
`gcc-patches@gcc.gnu.org`
mailing list for the GCC project.

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |

Other format: | [Raw text] |

*From*: Richard Biener <richard dot guenther at gmail dot com>*To*: Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>*Cc*: Jackson Woodruff <jackson dot woodruff at foss dot arm dot com>, "kyrylo dot tkachov at foss dot arm dot com" <kyrylo dot tkachov at foss dot arm dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>*Date*: Thu, 17 Aug 2017 12:20:41 +0200*Subject*: Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)*Authentication-results*: sourceware.org; auth=none*References*: <375649d4-3c43-0c37-3e4d-3913c7213993@foss.arm.com> <CAFiYyc3W59mDXn-pEKNO1S3Uk=2XpowRtT65ZgJb_E8AGnCK-Q@mail.gmail.com> <DB6PR0801MB205392EDB2B58B757167CC26838D0@DB6PR0801MB2053.eurprd08.prod.outlook.com> <CAFiYyc0wGaBuujfTUSVrsAOUoOkoO6SCYB9Mh+kPJ7DP68pSUA@mail.gmail.com> <DB6PR0801MB2053EA8A9D0D899A21DF5CF183830@DB6PR0801MB2053.eurprd08.prod.outlook.com>

On Thu, Aug 17, 2017 at 11:55 AM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote: > Richard Biener wrote: >> On Tue, Aug 15, 2017 at 4:11 PM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> 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 for example. >>> Also 1/y is now available to the reciprocal optimization, see >>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026 for details. >> >> Sure, but on its own it's going to be slower. So this isn't the >> correct way to enable those followup transforms. > > How can it be any slower? It's one division and one multiply in both cases. (x / C) / y is two divisions. If you restrict it to the case where we can transform this to (x * C') / y then it's indeed one. >>>> > x / (- y) -> (-x) / y >>>> >>>> Why? (it's only one of the possible canonicalizations) >>> >>> Same here, y is now available for reciprocal optimization. The >>> negate may now be optimized, for example (a * b) / -y -> (-a*b) / y >>> will use a negated multiple on various targets. >> >> Fair enough. Though if it were x / -(a*b) you'd regress that case. > > Possibly. You might still be able to merge the negate if the result is used in an > addition or multiply, which wouldn't be possible if it were hiding in a subexpression. > 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. Those followup transforms should be done at a place that can look at more complicated patterns. We have the reassoc pass, then backprop (not exactly matching), and the recip pattern matching / cse pass. Richard. > Wilco

**Follow-Ups**:

**References**:**[PATCH] Factor out division by squares and remove division around comparisons (1/2)***From:*Jackson Woodruff

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

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

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

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

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |