aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar.christina@arm.com>2023-11-09 13:58:59 +0000
committerTamar Christina <tamar.christina@arm.com>2023-11-09 14:06:06 +0000
commit2d44ab221f64f01fc676be0da1a6774740d713c6 (patch)
treea36b6d8ba9df824cfee21adef93d36aeb28bbbaf
parenta80daa2e52ab8fd8a83eec1379b4a5d4187a1162 (diff)
downloadgcc-2d44ab221f64f01fc676be0da1a6774740d713c6.zip
gcc-2d44ab221f64f01fc676be0da1a6774740d713c6.tar.gz
gcc-2d44ab221f64f01fc676be0da1a6774740d713c6.tar.bz2
middle-end: expand copysign handling from lockstep to nested iters
various optimizations in match.pd only happened on COPYSIGN in lock step which means they exclude IFN_COPYSIGN. COPYSIGN however is restricted to only the C99 builtins and so doesn't work for vectors. The patch expands these optimizations to work as nested iters. This is needed for the second patch which will add the testcase. gcc/ChangeLog: PR tree-optimization/109154 * match.pd: expand existing copysign optimizations.
-rw-r--r--gcc/match.pd48
1 files changed, 24 insertions, 24 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index dbc811b..68a1587 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1086,37 +1086,37 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* cos(copysign(x, y)) -> cos(x). Similarly for cosh. */
(for coss (COS COSH)
- copysigns (COPYSIGN)
- (simplify
- (coss (copysigns @0 @1))
- (coss @0)))
+ (for copysigns (COPYSIGN)
+ (simplify
+ (coss (copysigns @0 @1))
+ (coss @0))))
/* pow(copysign(x, y), z) -> pow(x, z) if z is an even integer. */
(for pows (POW)
- copysigns (COPYSIGN)
- (simplify
- (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)))))
+ (for copysigns (COPYSIGN)
+ (simplify
+ (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::to_wide (@1) & 1) == 0)
- (pows @0 @1))))
+ (for copysigns (COPYSIGN)
+ (simplify
+ (pows (copysigns @0 @2) INTEGER_CST@1)
+ (if ((wi::to_wide (@1) & 1) == 0)
+ (pows @0 @1)))))
(for hypots (HYPOT)
- copysigns (COPYSIGN)
- /* hypot(copysign(x, y), z) -> hypot(x, z). */
- (simplify
- (hypots (copysigns @0 @1) @2)
- (hypots @0 @2))
- /* hypot(x, copysign(y, z)) -> hypot(x, y). */
- (simplify
- (hypots @0 (copysigns @1 @2))
- (hypots @0 @1)))
+ (for copysigns (COPYSIGN)
+ /* hypot(copysign(x, y), z) -> hypot(x, z). */
+ (simplify
+ (hypots (copysigns @0 @1) @2)
+ (hypots @0 @2))
+ /* hypot(x, copysign(y, z)) -> hypot(x, y). */
+ (simplify
+ (hypots @0 (copysigns @1 @2))
+ (hypots @0 @1))))
/* copysign(x, CST) -> [-]abs (x). */
(for copysigns (COPYSIGN_ALL)