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: r193313
This commit is contained in:
Eric Botcazou 2012-11-07 22:28:32 +00:00 committed by Eric Botcazou
parent 709eb75ede
commit afcf008998
4 changed files with 27 additions and 2 deletions

View File

@ -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-05 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.c (print_reg): Replace REX_INT_REG_P with

View File

@ -6026,10 +6026,11 @@ fold_binary_op_with_conditional_arg (location_t loc,
}
/* 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;

View File

@ -1,3 +1,7 @@
2012-11-07 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/compile/20121107-1.c: New test.
2012-11-06 Janus Weil <janus@gcc.gnu.org>
PR fortran/54917

View File

@ -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);
}