]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR middle-end/55219 (memory explosion on nested conditional expressions)
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 7 Nov 2012 22:37:01 +0000 (22:37 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Wed, 7 Nov 2012 22:37:01 +0000 (22:37 +0000)
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: r193315

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20121107-1.c [new file with mode: 0644]

index 12f22438fab1e2a9abf9494d91a42a1bcd0d362a..f772e92a3deb57a952ea8b4ad5fd9710e7070d02 100644 (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-10-30  Andrey Belevantsev  <abel@ispras.ru>
 
        Backport from mainline
index 5b4fc1fed45b4a0f3e2e00b96928f7cea9d859c8..f11ddf14b75f88e125c6ded367de7c1eb298c7e5 100644 (file)
@@ -6003,10 +6003,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;
 
index bc1b206f4731b2340d58d4b5c38b6092e3941905..1637989fe2b29a01156717cb7c8a3c72b1c6ea29 100644 (file)
@@ -1,3 +1,7 @@
+2012-11-07  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc.c-torture/compile/20121107-1.c: New test.
+
 2012-10-30  Andrey Belevantsev  <abel@ispras.ru>
 
        Backport from mainline
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 (file)
index 0000000..a862067
--- /dev/null
@@ -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);
+}