]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR tree-optimization/70840 (revisit reassoc handling of pow / powi, amend match...
authorRichard Biener <rguenther@suse.de>
Thu, 28 Apr 2016 12:34:28 +0000 (12:34 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 28 Apr 2016 12:34:28 +0000 (12:34 +0000)
2016-04-28  Richard Biener  <rguenther@suse.de>

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

gcc/ChangeLog
gcc/match.pd

index 0284c895ae64573d8a0537f50d0d2cffd81f1376..f8bbb313a0a46aeffca014e4633e099368e54566 100644 (file)
@@ -1,3 +1,11 @@
+2016-04-28  Richard Biener  <rguenther@suse.de>
+
+       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  <kyrylo.tkachov@arm.com>
 
        * config/aarch64/aarch64.h (WORD_REGISTER_OPERATIONS): Define to 0
index f645157a4f4aed1af8e6f01a1591643ebbc1c133..0e63328c43c911ff0e5de3c5f51729c9365d95ff 100644 (file)
@@ -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)