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]

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


ping


From: Jackson Woodruff <jackson.woodruff@foss.arm.com>
Sent: 06 September 2017 10:55
To: Richard Biener
Cc: Wilco Dijkstra; kyrylo.tkachov@foss.arm.com; Joseph S. Myers; GCC Patches
Subject: Re: [PATCH] Factor out division by squares and remove division around comparisons (2/2)
  

Hi all,

A minor improvement came to mind while updating other parts of this patch.

I've updated a testcase to make it more clear and a condition now uses a 
call to is_division_by rather than manually checking those conditions.

Jackson

On 08/30/2017 05:32 PM, Jackson Woodruff wrote:
> Hi all,
> 
> I've attached a new version of the patch in response to a few of Wilco's 
> comments in person.
> 
> The end product of the pass is still the same, but I have fixed several 
> bugs.
> 
> Now tested independently of the other patches.
> 
> On 08/15/2017 03:07 PM, Richard Biener wrote:
>> On Thu, Aug 10, 2017 at 4:10 PM, Jackson Woodruff
>> <jackson.woodruff@foss.arm.com> wrote:
>>> Hi all,
>>>
>>> The patch implements the some of the division optimizations discussed in
>>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026 .
>>>
>>> We now reassociate (as discussed in the bug report):
>>>
>>>      x / (y * y) -> x  * (1 / y) * (1 / y)
>>>
>>> If it is reasonable to do so. This is done with
>>> -funsafe-math-optimizations.
>>>
>>> Bootstrapped and regtested with part (1/2). OK for trunk?
>>
>> I believe your enhancement shows the inherent weakness of
>> CSE of reciprocals in that it works from the defs.  It will
>> handle x / (y * y) but not x / (y * y * y).
>>
>> I think a rewrite of this mini-pass is warranted.
> 
> I suspect that there might be more to gain by of handling the case of
> x / (y * z) rather than the case of x / (y**n), but I agree that this 
> pass could do more.
> 
>>
>> Richard.
>>
>>> Jackson
>>>
>>> gcc/
>>>
>>> 2017-08-03  Jackson Woodruff  <jackson.woodruff@arm.com>
>>>
>>>          PR 71026/tree-optimization
>>>          * tree-ssa-math-opts (is_division_by_square,
>>>          is_square_of, insert_sqaure_reciprocals): New.
>>>          (insert_reciprocals): Change to insert reciprocals
>>>          before a division by a square.
>>>          (execute_cse_reciprocals_1): Change to consider
>>>          division by a square.
>>>
>>>
>>> gcc/testsuite
>>>
>>> 2017-08-03  Jackson Woodruff  <jackson.woodruff@arm.com>
>>>
>>>          PR 71026/tree-optimization
>>>          * gcc.dg/associate_division_1.c: New.
>>>
> 
> Thanks,
> 
> Jackson.
> 
> Updated ChangeLog:
> 
> gcc/
> 
> 2017-08-30  Jackson Woodruff  <jackson.woodruff@arm.com>
> 
>      PR 71026/tree-optimization
>      * tree-ssa-math-opts (is_division_by_square, is_square_of): New.
>      (insert_reciprocals): Change to insert reciprocals
>      before a division by a square and to insert the square
>      of a reciprocal.
>      (execute_cse_reciprocals_1): Change to consider
>      division by a square.
>      (register_division_in): Add importance parameter.
> 
> gcc/testsuite
> 
> 2017-08-30  Jackson Woodruff  <jackson.woodruff@arm.com>
> 
>      PR 71026/tree-optimization
>      * gcc.dg/extract_recip_3.c: New.
>      * gcc.dg/extract_recip_4.c: New.
>      * gfortran.dg/extract_recip_1.f: New.
    

Attachment: patchfile-2
Description: patchfile-2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]