From 6f5bdb3486b47df6735bbcf93fd585361122bd50 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 3 Sep 2018 13:28:25 +0000 Subject: [PATCH] 2018-09-03 Richard Biener PR tree-optimization/87197 * tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Mark the new def visited. CSE the VN_INFO hashtable lookup. * gcc.dg/torture/pr87197.c: New testcase. PR tree-optimization/87169 * tree-ssa-sccvn.c (do_rpo_vn): When marking loops for not iterating make sure there's no extra backedges from irreducible regions feeding the header. Mark the destination block executable. * gcc.dg/torture/pr87169.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264057 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 12 ++++++++++ gcc/testsuite/ChangeLog | 8 +++++++ gcc/testsuite/gcc.dg/torture/pr87169.c | 41 ++++++++++++++++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr87197.c | 35 +++++++++++++++++++++++++++++ gcc/tree-ssa-sccvn.c | 30 ++++++++++++++++++++----- 5 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr87169.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr87197.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1fb40e8336f..cd3c0e8178f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2018-09-03 Richard Biener + + PR tree-optimization/87197 + * tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Mark the new def + visited. CSE the VN_INFO hashtable lookup. + + PR tree-optimization/87169 + * tree-ssa-sccvn.c (do_rpo_vn): When marking loops for not + iterating make sure there's no extra backedges from irreducible + regions feeding the header. Mark the destination block + executable. + 2018-09-03 Martin Liska PR driver/83193 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 89dc37721bf..bd06f66b3d6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,11 @@ +2018-09-03 Richard Biener + + PR tree-optimization/87197 + * gcc.dg/torture/pr87197.c: New testcase. + + PR tree-optimization/87169 + * gcc.dg/torture/pr87169.c: New testcase. + 2018-09-03 Martin Liska PR driver/83193 diff --git a/gcc/testsuite/gcc.dg/torture/pr87169.c b/gcc/testsuite/gcc.dg/torture/pr87169.c new file mode 100644 index 00000000000..ed878e0c6b9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr87169.c @@ -0,0 +1,41 @@ +/* { dg-do compile } */ +/* { dg-additional-options "--param rpo-vn-max-loop-depth=7" } */ + +int a, b, c; + +int main () +{ + int d; + b = 1; +L1: + for (; b > 1;) + goto L2; + { + int e[1]; +L3:; + } +L2: + while (a) + { + d--; + goto L1; + } + while (c) + { + if (a) + goto L3; + if (a) + break; + if (a) + goto L2; + while (c) + while (c) + while (c) + while (c) + while (c) + while (c) + while (c) + ; + } + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr87197.c b/gcc/testsuite/gcc.dg/torture/pr87197.c new file mode 100644 index 00000000000..4c702242cfa --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr87197.c @@ -0,0 +1,35 @@ +/* { dg-do compile } */ + +int a, c, e, f, g; +void +h (int i) +{ + a = i; +} +void +j (char *i, long k) +{ + while (k--) + c = *i++; +} +void +l (unsigned char *i, long k) +{ + unsigned char *b = i + k; + while (i < b) + { + h (*i); + i++; + } +} +void +m () +{ + while (e) + { + float d = g; + l ((char *) &d, sizeof (g)); + if (f) + j ((char *) &d, sizeof (g)); + } +} diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index c333b89b204..26d093ea05b 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -1783,11 +1783,13 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert) /* The expression is not yet available, value-number lhs to the new SSA_NAME we created. */ /* Initialize value-number information properly. */ - VN_INFO (result)->valnum = result; - VN_INFO (result)->value_id = get_next_value_id (); + vn_ssa_aux_t result_info = VN_INFO (result); + result_info->valnum = result; + result_info->value_id = get_next_value_id (); + result_info->visited = 1; gimple_seq_add_stmt_without_update (&VN_INFO (result)->expr, new_stmt); - VN_INFO (result)->needs_insertion = true; + result_info->needs_insertion = true; /* ??? PRE phi-translation inserts NARYs without corresponding SSA name result. Re-use those but set their result according to the stmt we just built. */ @@ -1810,7 +1812,7 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert) unsigned int length = vn_nary_length_from_stmt (new_stmt); vn_nary_op_t vno1 = alloc_vn_nary_op_noinit (length, &vn_tables_insert_obstack); - vno1->value_id = VN_INFO (result)->value_id; + vno1->value_id = result_info->value_id; vno1->length = length; vno1->predicated_values = 0; vno1->u.result = result; @@ -6360,12 +6362,28 @@ do_rpo_vn (function *fn, edge entry, bitmap exit_bbs, i < loop_depth (loop) - max_depth; ++i) { basic_block header = superloop_at_depth (loop, i)->header; - rpo_state[bb_to_rpo[header->index]].iterate = false; + bool non_latch_backedge = false; edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, header->preds) if (e->flags & EDGE_DFS_BACK) - e->flags |= EDGE_EXECUTABLE; + { + e->flags |= EDGE_EXECUTABLE; + e->dest->flags |= BB_EXECUTABLE; + /* There can be a non-latch backedge into the header + which is part of an outer irreducible region. We + cannot avoid iterating this block then. */ + if (!dominated_by_p (CDI_DOMINATORS, + e->src, e->dest)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "non-latch backedge %d -> %d " + "forces iteration of loop %d\n", + e->src->index, e->dest->index, loop->num); + non_latch_backedge = true; + } + } + rpo_state[bb_to_rpo[header->index]].iterate = non_latch_backedge; } } -- 2.11.4.GIT