From ec64ffc8501c20efdebefb494f3c90ab44199b60 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 14 Mar 2018 08:07:45 +0000 Subject: [PATCH] re PR tree-optimization/84830 (ICE in compute_antic, at tree-ssa-pre.c:2388) 2018-03-14 Richard Biener PR tree-optimization/84830 * tree-ssa-pre.c (compute_antic_aux): Intersect the new ANTIC_IN with the old one to avoid oscillations. * gcc.dg/torture/pr84830.c: New testcase. From-SVN: r258514 --- gcc/ChangeLog | 6 ++++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/torture/pr84830.c | 46 ++++++++++++++++++++++++++ gcc/tree-ssa-pre.c | 29 ++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/torture/pr84830.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5eaafcfb9bb..550e2b6b3e0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-03-14 Richard Biener + + PR tree-optimization/84830 + * tree-ssa-pre.c (compute_antic_aux): Intersect the new ANTIC_IN + with the old one to avoid oscillations. + 2018-03-13 Vladimir Makarov PR target/83712 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a4bf53c8bc4..0175d4342c0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-03-14 Richard Biener + + PR tree-optimization/84830 + * gcc.dg/torture/pr84830.c: New testcase. + 2018-03-14 Marek Polacek PR c++/84596 diff --git a/gcc/testsuite/gcc.dg/torture/pr84830.c b/gcc/testsuite/gcc.dg/torture/pr84830.c new file mode 100644 index 00000000000..d076170d258 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr84830.c @@ -0,0 +1,46 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-fno-tree-ch -fno-tree-vrp" } */ + +int x0; + +void +br (int yp, int oo) +{ + int *qi = &yp; + + if (oo == 0) + { +g8: + if (x0 != 0) + x0 = yp; + else if (oo != 0) + x0 = yp; + + if (x0 == 0) + { + *qi = 0; + x0 = *qi; + } + + if (x0 != 0) + { + ++oo; + goto g8; + } + + if (yp == oo) + yp += !!oo; + } + else + { + x0 = 1; + while (x0 < 2) + { + qi = &oo; + ++oo; + x0 = 1; + } + } + + goto g8; +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index f165a1eb975..c3d2bbac957 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -2154,6 +2154,35 @@ compute_antic_aux (basic_block block, bool block_has_abnormal_pred_edge) /* clean (ANTIC_IN (block)) is defered to after the iteration converged because it can cause non-convergence, see for example PR81181. */ + /* Intersect ANTIC_IN with the old ANTIC_IN. This is required until + we properly represent the maximum expression set, thus not prune + values without expressions during the iteration. */ + if (was_visited + && bitmap_and_into (&ANTIC_IN (block)->values, &old->values)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "warning: intersecting with old ANTIC_IN " + "shrinks the set\n"); + /* Prune expressions not in the value set. */ + bitmap_iterator bi; + unsigned int i; + unsigned int to_clear = -1U; + FOR_EACH_EXPR_ID_IN_SET (ANTIC_IN (block), i, bi) + { + if (to_clear != -1U) + { + bitmap_clear_bit (&ANTIC_IN (block)->expressions, to_clear); + to_clear = -1U; + } + pre_expr expr = expression_for_id (i); + unsigned int value_id = get_expr_value_id (expr); + if (!bitmap_bit_p (&ANTIC_IN (block)->values, value_id)) + to_clear = i; + } + if (to_clear != -1U) + bitmap_clear_bit (&ANTIC_IN (block)->expressions, to_clear); + } + if (!bitmap_set_equal (old, ANTIC_IN (block))) { changed = true;