summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-02 15:13:45 +0000
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-02 15:13:45 +0000
commit6eb99d8abbd976c74d7d6ea67b8710d047fd3348 (patch)
tree12cfedd860ac2a60929d04de3b2faa9c19e70e6d
parent2cc03db8ab8e662fa2597a4631b890e75443f918 (diff)
downloadgcc-6eb99d8abbd976c74d7d6ea67b8710d047fd3348.tar.gz
2012-04-02 Richard Guenther <rguenther@suse.de>
PR tree-optimization/52756 * tree-ssa-threadupdate.c (def_split_header_continue_p): New function. (thread_through_loop_header): After threading through the loop latch remove the split part from the loop and clear further threading opportunities that would create a multiple entry loop. * gcc.dg/torture/pr52756.c: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186085 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog8
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr52756.c9
-rw-r--r--gcc/tree-ssa-threadupdate.c46
4 files changed, 68 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index a020c700929..2d4fb1d49d4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
2012-04-02 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/52756
+ * tree-ssa-threadupdate.c (def_split_header_continue_p): New function.
+ (thread_through_loop_header): After threading through the loop latch
+ remove the split part from the loop and clear further threading
+ opportunities that would create a multiple entry loop.
+
+2012-04-02 Richard Guenther <rguenther@suse.de>
+
PR rtl-optimization/52800
* cprop.c (execute_rtl_cprop): Call cleanup_cfg with
CLEANUP_CFG_CHANGED.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2d95e0ed0d9..a10bea7efce 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2012-04-02 Richard Guenther <rguenther@suse.de>
+ PR tree-optimization/52756
+ * gcc.dg/torture/pr52756.c: New testcase.
+
+2012-04-02 Richard Guenther <rguenther@suse.de>
+
PR middle-end/52803
* gcc.dg/pr52803.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr52756.c b/gcc/testsuite/gcc.dg/torture/pr52756.c
new file mode 100644
index 00000000000..175b414e17d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr52756.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+void Env_FetchObj0AttrOffset (unsigned int NumFields, int *Status)
+{
+ int Found = 0;
+ if (NumFields)
+ while ((*Status == 0) && NumFields-- > 0 && Found == 0)
+ Found = 1;
+}
diff --git a/gcc/tree-ssa-threadupdate.c b/gcc/tree-ssa-threadupdate.c
index 4532886ca96..000bd3f2e40 100644
--- a/gcc/tree-ssa-threadupdate.c
+++ b/gcc/tree-ssa-threadupdate.c
@@ -826,6 +826,17 @@ determine_bb_domination_status (struct loop *loop, basic_block bb)
return (bb_reachable ? DOMST_DOMINATING : DOMST_LOOP_BROKEN);
}
+/* Return true if BB is part of the new pre-header that is created
+ when threading the latch to DATA. */
+
+static bool
+def_split_header_continue_p (const_basic_block bb, const void *data)
+{
+ const_basic_block new_header = (const_basic_block) data;
+ return (bb->loop_father == new_header->loop_father
+ && bb != new_header);
+}
+
/* Thread jumps through the header of LOOP. Returns true if cfg changes.
If MAY_PEEL_LOOP_HEADERS is false, we avoid threading from entry edges
to the inside of the loop. */
@@ -990,11 +1001,46 @@ thread_through_loop_header (struct loop *loop, bool may_peel_loop_headers)
if (latch->aux)
{
+ basic_block *bblocks;
+ unsigned nblocks, i;
+
/* First handle the case latch edge is redirected. */
loop->latch = thread_single_edge (latch);
gcc_assert (single_succ (loop->latch) == tgt_bb);
loop->header = tgt_bb;
+ /* Remove the new pre-header blocks from our loop. */
+ bblocks = XCNEWVEC (basic_block, loop->num_nodes);
+ nblocks = dfs_enumerate_from (header, 0, def_split_header_continue_p,
+ bblocks, loop->num_nodes, tgt_bb);
+ for (i = 0; i < nblocks; i++)
+ {
+ remove_bb_from_loops (bblocks[i]);
+ add_bb_to_loop (bblocks[i], loop_outer (loop));
+ }
+ free (bblocks);
+
+ /* Cancel remaining threading requests that would make the
+ loop a multiple entry loop. */
+ FOR_EACH_EDGE (e, ei, header->preds)
+ {
+ edge e2;
+ if (e->aux == NULL)
+ continue;
+
+ if (THREAD_TARGET2 (e))
+ e2 = THREAD_TARGET2 (e);
+ else
+ e2 = THREAD_TARGET (e);
+
+ if (e->src->loop_father != e2->dest->loop_father
+ && e2->dest != loop->header)
+ {
+ free (e->aux);
+ e->aux = NULL;
+ }
+ }
+
/* Thread the remaining edges through the former header. */
thread_block (header, false);
}