diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-11-07 22:26:02 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-11-07 22:26:02 +0000 |
commit | dd64a6f7c8165c204b3cc2f353562df0b6bf335d (patch) | |
tree | 74bd2163ff68dcf5d867b4f057ef2ecff1bc162a | |
parent | 05bb5b0630a9460d8888c1be83298f27d93e462c (diff) | |
download | gcc-dd64a6f7c8165c204b3cc2f353562df0b6bf335d.zip gcc-dd64a6f7c8165c204b3cc2f353562df0b6bf335d.tar.gz gcc-dd64a6f7c8165c204b3cc2f353562df0b6bf335d.tar.bz2 |
re PR middle-end/55219 (memory explosion on nested conditional expressions)
PR middle-end/55219
* fold-const.c (fold_binary_op_with_conditional_arg): Do not fold if
the argument is itself a conditional expression.
From-SVN: r193312
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/fold-const.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/compile/20121107-1.c | 14 |
4 files changed, 27 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 294b3a5..b11e703 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2012-11-07 Eric Botcazou <ebotcazou@adacore.com> + + PR middle-end/55219 + * fold-const.c (fold_binary_op_with_conditional_arg): Do not fold if + the argument is itself a conditional expression. + 2012-11-07 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/55122 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 62a4e21..4fa1fd6 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5987,10 +5987,11 @@ fold_binary_op_with_conditional_arg (location_t loc, cond_code = VEC_COND_EXPR; /* This transformation is only worthwhile if we don't have to wrap ARG - in a SAVE_EXPR and the operation can be simplified on at least one - of the branches once its pushed inside the COND_EXPR. */ + in a SAVE_EXPR and the operation can be simplified without recursing + on at least one of the branches once its pushed inside the COND_EXPR. */ if (!TREE_CONSTANT (arg) && (TREE_SIDE_EFFECTS (arg) + || TREE_CODE (arg) == COND_EXPR || TREE_CODE (arg) == VEC_COND_EXPR || TREE_CONSTANT (true_value) || TREE_CONSTANT (false_value))) return NULL_TREE; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 311188c..302daff 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-11-07 Eric Botcazou <ebotcazou@adacore.com> + + * gcc.c-torture/compile/20121107-1.c: New test. + 2012-11-07 Vladimir Makarov <vmakarov@redhat.com> PR rtl-optimization/55151 diff --git a/gcc/testsuite/gcc.c-torture/compile/20121107-1.c b/gcc/testsuite/gcc.c-torture/compile/20121107-1.c new file mode 100644 index 0000000..a862067 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20121107-1.c @@ -0,0 +1,14 @@ +/* PR middle-end/55219 */ +/* Testcase by Markus Trippelsdorf <markus@trippelsdorf.de> */ + +int x, c, d, e, f, g, h, i; +double j; +const int k; +const enum { B } a; +void +fn1 (void) +{ + h = (g ? c : g ? f : g ? e : g ? i : g ? f : g ? e : g ? d : x) + + (a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a ? : a + ? j : a ? : 0 ? : a ? : a ? : a ? : a ? : a ? : a ? k : a ? : x); +} |