From 1cc521f1a824b5913aeda06ebe296de98f2d9453 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Thu, 7 Dec 2017 14:49:54 +0000 Subject: Add unroll and jam pass * gimple-loop-jam.c: New file. * Makefile.in (OBJS): Add gimple-loop-jam.o. * common.opt (funroll-and-jam): New option. * opts.c (default_options_table): Add unroll-and-jam at -O3. * params.def (PARAM_UNROLL_JAM_MIN_PERCENT): New param. (PARAM_UNROLL_JAM_MAX_UNROLL): Ditto. * passes.def: Add pass_loop_jam. * timevar.def (TV_LOOP_JAM): Add. * tree-pass.h (make_pass_loop_jam): Declare. * cfgloop.c (flow_loop_tree_node_add): Add AFTER argument. * cfgloop.h (flow_loop_tree_node_add): Adjust declaration. * cfgloopmanip.c (duplicate_loop): Add AFTER argument, adjust call to flow_loop_tree_node_add. (duplicate_subloops, copy_loops_to): Append to sibling list. * cfgloopmanip.h: (duplicate_loop): Adjust declaration. * doc/invoke.texi (-funroll-and-jam): Document new option. (unroll-jam-min-percent, unroll-jam-max-unroll): Document new params. testsuite/ * gcc.dg/unroll-and-jam.c: New test. From-SVN: r255467 --- gcc/cfgloop.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'gcc/cfgloop.c') diff --git a/gcc/cfgloop.c b/gcc/cfgloop.c index d82da97..0d8cf1e 100644 --- a/gcc/cfgloop.c +++ b/gcc/cfgloop.c @@ -296,13 +296,25 @@ establish_preds (struct loop *loop, struct loop *father) /* Add LOOP to the loop hierarchy tree where FATHER is father of the added loop. If LOOP has some children, take care of that their - pred field will be initialized correctly. */ + pred field will be initialized correctly. If AFTER is non-null + then it's expected it's a pointer into FATHERs inner sibling + list and LOOP is added behind AFTER, otherwise it's added in front + of FATHERs siblings. */ void -flow_loop_tree_node_add (struct loop *father, struct loop *loop) +flow_loop_tree_node_add (struct loop *father, struct loop *loop, + struct loop *after) { - loop->next = father->inner; - father->inner = loop; + if (after) + { + loop->next = after->next; + after->next = loop; + } + else + { + loop->next = father->inner; + father->inner = loop; + } establish_preds (loop, father); } -- cgit v1.1