summaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-12-04 10:38:48 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-12-04 10:38:48 +0100
commit526b4c716a340ee9464965e63eee2b9954fe21f1 (patch)
tree23a2d4dc47394916d3c8e36899a6ebb0d397535b /gcc/match.pd
parent6f1e966874de23d7e47cbaebfb5a9de6759cb089 (diff)
re PR tree-optimization/92734 (Missing match.pd simplification done by fold_binary_loc on generic)
PR tree-optimization/92734 * match.pd ((A +- B) - A -> +- B, (A +- B) -+ B -> A, A - (A +- B) -> -+ B, A +- (B -+ A) -> +- B): Handle nop_convert. * gcc.dg/tree-ssa/pr92734-2.c: New test. From-SVN: r278958
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd26
1 files changed, 16 insertions, 10 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index d3312e5f279..c50b5468c74 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2159,20 +2159,26 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* A - (A +- B) -> -+ B */
/* A +- (B -+ A) -> +- B */
(simplify
- (minus (plus:c @0 @1) @0)
- @1)
+ (minus (nop_convert (plus:c (nop_convert @0) @1)) @0)
+ (view_convert @1))
(simplify
- (minus (minus @0 @1) @0)
- (negate @1))
+ (minus (nop_convert (minus (nop_convert @0) @1)) @0)
+ (if (!ANY_INTEGRAL_TYPE_P (type)
+ || TYPE_OVERFLOW_WRAPS (type))
+ (negate (view_convert @1))
+ (view_convert (negate @1))))
(simplify
- (plus:c (minus @0 @1) @1)
- @0)
+ (plus:c (nop_convert (minus @0 (nop_convert @1))) @1)
+ (view_convert @0))
(simplify
- (minus @0 (plus:c @0 @1))
- (negate @1))
+ (minus @0 (nop_convert (plus:c (nop_convert @0) @1)))
+ (if (!ANY_INTEGRAL_TYPE_P (type)
+ || TYPE_OVERFLOW_WRAPS (type))
+ (negate (view_convert @1))
+ (view_convert (negate @1))))
(simplify
- (minus @0 (minus @0 @1))
- @1)
+ (minus @0 (nop_convert (minus (nop_convert @0) @1)))
+ (view_convert @1))
/* (A +- B) + (C - A) -> C +- B */
/* (A + B) - (A - C) -> B + C */
/* More cases are handled with comparisons. */