aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorFeng Xue <fxue@os.amperecomputing.com>2020-08-17 23:00:35 +0800
committerFeng Xue <fxue@os.amperecomputing.com>2020-09-15 22:51:28 +0800
commit8f0d743c2dee6afae5c6f861b0642b7b112a4a70 (patch)
treedc5f349561cd3bf9bbdca113a1504741fa88b513 /gcc/match.pd
parent9e89fa0e2d7da77236cad50c0a9a33b7a4b97367 (diff)
downloadgcc-8f0d743c2dee6afae5c6f861b0642b7b112a4a70.zip
gcc-8f0d743c2dee6afae5c6f861b0642b7b112a4a70.tar.gz
gcc-8f0d743c2dee6afae5c6f861b0642b7b112a4a70.tar.bz2
tree-optimization/94234 - add plusminus-with-convert pattern
Add a rule (T)(A) +- (T)(B) -> (T)(A +- B), which works only when (A +- B) could be folded to a simple value. By this rule, a plusminus-mult-with-convert expression could be handed over to the rule (A * C) +- (B * C) -> (A +- B). 2020-09-15 Feng Xue <fxue@os.amperecomputing.com> gcc/ PR tree-optimization/94234 * match.pd (T)(A) +- (T)(B) -> (T)(A +- B): New simplification. gcc/testsuite/ PR tree-optimization/94234 * gcc.dg/pr94234-3.c: New test.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd15
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 46fd880..7d63bb9 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2397,6 +2397,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(plus (convert @0) (op @2 (convert @1))))))
#endif
+/* (T)(A) +- (T)(B) -> (T)(A +- B) only when (A +- B) could be simplified
+ to a simple value. */
+#if GIMPLE
+ (for op (plus minus)
+ (simplify
+ (op (convert @0) (convert @1))
+ (if (INTEGRAL_TYPE_P (type)
+ && INTEGRAL_TYPE_P (TREE_TYPE (@0))
+ && TYPE_PRECISION (type) <= TYPE_PRECISION (TREE_TYPE (@0))
+ && types_match (TREE_TYPE (@0), TREE_TYPE (@1))
+ && !TYPE_OVERFLOW_TRAPS (type)
+ && !TYPE_OVERFLOW_SANITIZED (type))
+ (convert (op! @0 @1)))))
+#endif
+
/* ~A + A -> -1 */
(simplify
(plus:c (bit_not @0) @0)