From: Richard Biener <richard.guenther@gmail.com>
To: Wilco Dijkstra <Wilco.Dijkstra@arm.com>
Cc: Jackson Woodruff <jackson.woodruff@foss.arm.com>,
"kyrylo.tkachov@foss.arm.com" <kyrylo.tkachov@foss.arm.com>,
"Joseph S. Myers" <joseph@codesourcery.com>,
GCC Patches <gcc-patches@gcc.gnu.org>, nd <nd@arm.com>
Subject: Re: [PATCH] Factor out division by squares and remove division around comparisons (1/2)
Date: Thu, 17 Aug 2017 10:39:00 -0000 [thread overview]
Message-ID: <CAFiYyc2rgwMEVOFEFH3Ndzoc0KdAcU4a0_b-M6y=6jNcRHhJUg@mail.gmail.com> (raw)
In-Reply-To: <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
next prev parent reply other threads:[~2017-08-17 10:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-10 14:11 Jackson Woodruff
2017-08-10 15:26 ` Jackson Woodruff
2017-08-11 0:15 ` Joseph Myers
2017-08-15 14:22 ` Richard Biener
2017-08-15 14:43 ` Wilco Dijkstra
2017-08-17 10:20 ` Richard Biener
2017-08-17 10:29 ` Wilco Dijkstra
2017-08-17 10:39 ` Richard Biener [this message]
2017-08-17 12:46 ` Joseph Myers
2017-08-24 21:26 ` Jeff Law
2017-08-29 12:13 ` Jackson Woodruff
2017-08-29 13:31 ` Richard Biener
2017-08-30 10:45 ` Jackson Woodruff
2017-08-30 13:26 ` Richard Biener
2017-09-06 9:55 ` Jackson Woodruff
2017-09-13 18:37 ` Jeff Law
2017-09-13 21:20 ` Wilco Dijkstra
2017-09-15 12:07 ` Richard Biener
2017-09-15 16:50 ` Jeff Law
2017-09-16 21:39 ` Bernhard Reutner-Fischer
2017-10-13 18:18 ` Jeff Law
2017-10-13 18:53 ` Wilco Dijkstra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAFiYyc2rgwMEVOFEFH3Ndzoc0KdAcU4a0_b-M6y=6jNcRHhJUg@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=Wilco.Dijkstra@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jackson.woodruff@foss.arm.com \
--cc=joseph@codesourcery.com \
--cc=kyrylo.tkachov@foss.arm.com \
--cc=nd@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).