aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@gcc.gnu.org>2018-02-15 12:17:05 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2018-02-15 12:17:05 +0100
commit3eb1eecf29e1e28982b297e565ee291be8636532 (patch)
treeeb1440321b077086e6d4ec1064117f8c5cbfc6d4 /gcc/match.pd
parent8fa4bd81cb7cefa30212d79664963c1b6bbb9667 (diff)
downloadgcc-3eb1eecf29e1e28982b297e565ee291be8636532.zip
gcc-3eb1eecf29e1e28982b297e565ee291be8636532.tar.gz
gcc-3eb1eecf29e1e28982b297e565ee291be8636532.tar.bz2
re PR tree-optimization/84334 (Stack overflow with -Ofast -frounding-math)
PR tree-optimization/84334 * match.pd ((A +- CST1) +- CST2 -> A + CST3): If A is also a CONSTANT_CLASS_P, punt. * gcc.dg/pr84334.c: New test. From-SVN: r257683
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd9
1 files changed, 6 insertions, 3 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index f759711..4452b58 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -1733,9 +1733,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
CONSTANT_CLASS_P@2)
/* If one of the types wraps, use that one. */
(if (!ANY_INTEGRAL_TYPE_P (type) || TYPE_OVERFLOW_WRAPS (type))
- (if (outer_op == PLUS_EXPR)
- (plus (view_convert @0) (inner_op @2 (view_convert @1)))
- (minus (view_convert @0) (neg_inner_op @2 (view_convert @1))))
+ /* If all 3 captures are CONSTANT_CLASS_P, punt, as we might recurse
+ forever if something doesn't simplify into a constant. */
+ (if (!CONSTANT_CLASS_P (@0))
+ (if (outer_op == PLUS_EXPR)
+ (plus (view_convert @0) (inner_op @2 (view_convert @1)))
+ (minus (view_convert @0) (neg_inner_op @2 (view_convert @1)))))
(if (!ANY_INTEGRAL_TYPE_P (TREE_TYPE (@0))
|| TYPE_OVERFLOW_WRAPS (TREE_TYPE (@0)))
(if (outer_op == PLUS_EXPR)