https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026

--- Comment #10 from Wilco <wilco at gcc dot gnu.org> ---
Author: wilco
Date: Fri Nov 24 16:03:13 2017
New Revision: 255141

URL: https://gcc.gnu.org/viewcvs?rev=255141&root=gcc&view=rev
Log:
Factor out division by squares

This patch implements the some of the division optimizations discussed in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71026.

The division reciprocal optimization now handles divisions by squares:

     x / (y * y) -> x  * (1 / y) * (1 / y)

This requires at least one more division by y before it triggers - the
3 divisions of (1/ y) are then CSEd into a single division.  Overall
this changes 1 division into 1 multiply, which is generally much faster.


2017-11-24  Jackson Woodruff  <jackson.woodr...@arm.com>

    gcc/
        PR tree-optimization/71026
        * 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.

    testsuite/
        PR tree-optimization/71026
        * gfortran.dg/extract_recip_1.f: New test.
        * gcc.dg/extract_recip_3.c: New test.
        * gcc.dg/extract_recip_4.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/extract_recip_3.c
    trunk/gcc/testsuite/gcc.dg/extract_recip_4.c
    trunk/gcc/testsuite/gfortran.dg/extract_recip_1.f
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-math-opts.c

Reply via email to