From: Richard Biener Date: Thu, 28 Apr 2016 12:34:28 +0000 (+0000) Subject: re PR tree-optimization/70840 (revisit reassoc handling of pow / powi, amend match... X-Git-Tag: basepoints/gcc-8~7347 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de3fbea3b3c62a501f446d363240a67b60888299;p=thirdparty%2Fgcc.git re PR tree-optimization/70840 (revisit reassoc handling of pow / powi, amend match.pd for powi) 2016-04-28 Richard Biener PR tree-optimization/70840 * match.pd: powi(-x, y) and powi(|x|,y) -> powi(x,y) if y is even; Fix pow(copysign(x, y), z) -> pow(x, z) and add powi variant; Mark x * pow(x,c) -> pow(x,c+1) commutative. Add powi(x,y) * powi(z,y) -> powi(x*z,y). From-SVN: r235566 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0284c895ae64..f8bbb313a0a4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-04-28 Richard Biener + + PR tree-optimization/70840 + * match.pd: powi(-x, y) and powi(|x|,y) -> powi(x,y) if y is even; + Fix pow(copysign(x, y), z) -> pow(x, z) and add powi variant; + Mark x * pow(x,c) -> pow(x,c+1) commutative. + Add powi(x,y) * powi(z,y) -> powi(x*z,y). + 2015-04-28 Kyrylo Tkachov * config/aarch64/aarch64.h (WORD_REGISTER_OPERATIONS): Define to 0 diff --git a/gcc/match.pd b/gcc/match.pd index f645157a4f4a..0e63328c43c9 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -366,6 +366,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (with { HOST_WIDE_INT n; } (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) (pows @0 @1))))) + /* Likewise for powi. */ + (for pows (POWI) + (simplify + (pows (op @0) INTEGER_CST@1) + (if (wi::bit_and (@1, 1) == 0) + (pows @0 @1)))) /* Strip negate and abs from both operands of hypot. */ (for hypots (HYPOT) (simplify @@ -396,10 +402,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (for pows (POW) copysigns (COPYSIGN) (simplify - (pows (copysigns @0 @1) REAL_CST@1) + (pows (copysigns @0 @2) REAL_CST@1) (with { HOST_WIDE_INT n; } (if (real_isinteger (&TREE_REAL_CST (@1), &n) && (n & 1) == 0) (pows @0 @1))))) +/* Likewise for powi. */ +(for pows (POWI) + copysigns (COPYSIGN) + (simplify + (pows (copysigns @0 @2) INTEGER_CST@1) + (if (wi::bit_and (@1, 1) == 0) + (pows @0 @1)))) (for hypots (HYPOT) copysigns (COPYSIGN) @@ -2781,7 +2794,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) /* Simplify x * pow(x,c) -> pow(x,c+1). */ (simplify - (mult @0 (POW:s @0 REAL_CST@1)) + (mult:c @0 (POW:s @0 REAL_CST@1)) (if (!TREE_OVERFLOW (@1)) (POW @0 (plus @1 { build_one_cst (type); })))) @@ -2819,6 +2832,11 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (mult (POW:s @0 @1) (POW:s @2 @1)) (POW (mult @0 @2) @1)) + /* Simplify powi(x,y) * powi(z,y) -> powi(x*z,y). */ + (simplify + (mult (POWI:s @0 @1) (POWI:s @2 @1)) + (POWI (mult @0 @2) @1)) + /* Simplify pow(x,c) / x -> pow(x,c-1). */ (simplify (rdiv (POW:s @0 REAL_CST@1) @0)