summaryrefslogtreecommitdiff
path: root/gcc/cfgloopanal.c
diff options
context:
space:
mode:
authorbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-07 10:19:26 +0000
committerbstarynk <bstarynk@138bc75d-0d04-0410-961f-82ee72b054a4>2012-11-07 10:19:26 +0000
commit80879cf9009417726906a880af907e2de8683a84 (patch)
tree5d10fee949bcec7e27a86f73f02f55f09633b3d4 /gcc/cfgloopanal.c
parentd42d3fad6998402ea943bc2a3159cad09eb288d5 (diff)
downloadgcc-80879cf9009417726906a880af907e2de8683a84.tar.gz
2012-11-07 Basile Starynkevitch <basile@starynkevitch.net>
MELT branch merged with trunk rev 193285 using svnmerge.py git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@193288 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgloopanal.c')
-rw-r--r--gcc/cfgloopanal.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/cfgloopanal.c b/gcc/cfgloopanal.c
index c3cf3edf9b9..ba7c2626635 100644
--- a/gcc/cfgloopanal.c
+++ b/gcc/cfgloopanal.c
@@ -483,3 +483,36 @@ single_likely_exit (struct loop *loop)
VEC_free (edge, heap, exits);
return found;
}
+
+
+/* Gets basic blocks of a LOOP. Header is the 0-th block, rest is in dfs
+ order against direction of edges from latch. Specially, if
+ header != latch, latch is the 1-st block. */
+
+VEC (basic_block, heap) *
+get_loop_hot_path (const struct loop *loop)
+{
+ basic_block bb = loop->header;
+ VEC (basic_block, heap) *path = NULL;
+ bitmap visited = BITMAP_ALLOC (NULL);
+
+ while (true)
+ {
+ edge_iterator ei;
+ edge e;
+ edge best = NULL;
+
+ VEC_safe_push (basic_block, heap, path, bb);
+ bitmap_set_bit (visited, bb->index);
+ FOR_EACH_EDGE (e, ei, bb->succs)
+ if ((!best || e->probability > best->probability)
+ && !loop_exit_edge_p (loop, e)
+ && !bitmap_bit_p (visited, e->dest->index))
+ best = e;
+ if (!best || best->dest == loop->header)
+ break;
+ bb = best->dest;
+ }
+ BITMAP_FREE (visited);
+ return path;
+}