This is the mail archive of the gcc-cvs@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]

r228840 - in /trunk/gcc: ChangeLog generic-matc...


Author: rsandifo
Date: Thu Oct 15 09:50:07 2015
New Revision: 228840

URL: https://gcc.gnu.org/viewcvs?rev=228840&root=gcc&view=rev
Log:
PR67945: Fix oscillation between pow representations

This patch fixes some fallout from my patch to move the sqrt and cbrt
folding rules to match.pd.  The rules included canonicalisations like:

       sqrt(sqrt(x))->pow(x,1/4)

which in the original code was only ever done at the generic level.
My patch meant that we'd do it whenever we tried to fold a gimple
statement, and eventually it would win over the sincos optimisation
that replaces pow(x,1/4) with sqrt(sqrt(x)).

Following a suggestion from Richard B, the patch adds a new
PROP_gimple_* flag to say whether fp routines have been optimised
for the target.  If so, match.pd should only transform calls to math
functions if the result is actually an optimisation, not just an
IL simplification or canonicalisation.  The question then of course
is: which rules are which?  I've added block comments that describe
the criteria I was using.

A slight wart is that we need to use the cfun global to access
the PROP_gimple_* flag; there's no local function pointer available.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
on powerc64-linux-gnu.

gcc/
	PR tree-optimization/67945
	* tree-pass.h (PROP_gimple_opt_math): New property flag.
	* generic-match-head.c (canonicalize_math_p): New function.
	* gimple-match-head.c: Include tree-pass.h.
	(canonicalize_math_p): New function.
	* match.pd: Group math built-in rules into simplifications
	and canonicalizations.  Guard the latter with canonicalize_math_p.
	* tree-ssa-math-opts.c (pass_data_cse_sincos): Provide the
	PROP_gimple_opt_math property.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/generic-match-head.c
    trunk/gcc/gimple-match-head.c
    trunk/gcc/match.pd
    trunk/gcc/tree-pass.h
    trunk/gcc/tree-ssa-math-opts.c


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