Commit 89f8f30f by Zdenek Dvorak Committed by Zdenek Dvorak

loop.texi: Document possibility not to perform disambiguation of loops with multiple latches.

	* doc/loop.texi: Document possibility not to perform disambiguation
	of loops with multiple latches.
	* cfgloopmanip.c (alp_enum_p): Removed.
	(add_loop): Handle subloops.  Use get_loop_body_with_size.
	(create_preheader): Do not allow ENTRY_BLOCK_PTR to be preheader.
	* cfghooks.c (redirect_edge_and_branch_force): Set dominator for
	the new forwarder block.
	(make_forwarder_block): Only call new_bb_cbk if it is not NULL.
	Handle the case latch is NULL.
	* tree-ssa-dom.c (tree_ssa_dominator_optimize): Avoid cfg modifications
	when marking loop exits.
	* ifcvt.c (if_convert): Ditto.  Mark loop exits even if cfg cannot
	be modified.
	* loop-init.c (loop_optimizer_init): Do not modify cfg.  Call
	disambiguate_loops_with_multiple_latches.
	* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Calculate dominators
	before fix_loop_structure.
	* cfgloop.c: Include pointer-set.h and output.h.
	(canonicalize_loop_headers, HEADER_BLOCK, LATCH_EDGE,
	update_latch_info, mfb_keep_just, mfb_keep_nonlatch): Removed.
	(get_loop_latch_edges, find_subloop_latch_edge_by_profile,
	find_subloop_latch_edge_by_ivs, find_subloop_latch_edge,
	mfb_redirect_edges_in_set, form_subloop, merge_latch_edges,
	disambiguate_multiple_latches, get_loop_body_with_size,
	disambiguate_loops_with_multiple_latches): New functions.
	(flow_loop_dump): Dump multiple latch edges.
	(flow_loop_nodes_find): Handle loops with multiple latches.
	(flow_loops_find): Ditto. Do not call canonicalize_loop_headers.
	(glb_enum_p): Modified.
	(get_loop_body): Use get_loop_body_with_size.
	* cfgloop.h (LOOPS_HAVE_RECORDED_EXITS): New flag.
	(AVOID_CFG_MODIFICATIONS): New constant.
	(disambiguate_loops_with_multiple_latches, add_loop,
	get_loop_body_with_size): Declare.
	* Makefile.in (cfgloop.o): Add pointer-set.h and output.h.

	* gcc.dg/tree-ssa/loop-25.c: New test.

From-SVN: r121670
parent ca20820e
2007-02-06 Zdenek Dvorak <dvorakz@suse.cz>
* doc/loop.texi: Document possibility not to perform disambiguation
of loops with multiple latches.
* cfgloopmanip.c (alp_enum_p): Removed.
(add_loop): Handle subloops. Use get_loop_body_with_size.
(create_preheader): Do not allow ENTRY_BLOCK_PTR to be preheader.
* cfghooks.c (redirect_edge_and_branch_force): Set dominator for
the new forwarder block.
(make_forwarder_block): Only call new_bb_cbk if it is not NULL.
Handle the case latch is NULL.
* tree-ssa-dom.c (tree_ssa_dominator_optimize): Avoid cfg modifications
when marking loop exits.
* ifcvt.c (if_convert): Ditto. Mark loop exits even if cfg cannot
be modified.
* loop-init.c (loop_optimizer_init): Do not modify cfg. Call
disambiguate_loops_with_multiple_latches.
* tree-cfgcleanup.c (cleanup_tree_cfg_loop): Calculate dominators
before fix_loop_structure.
* cfgloop.c: Include pointer-set.h and output.h.
(canonicalize_loop_headers, HEADER_BLOCK, LATCH_EDGE,
update_latch_info, mfb_keep_just, mfb_keep_nonlatch): Removed.
(get_loop_latch_edges, find_subloop_latch_edge_by_profile,
find_subloop_latch_edge_by_ivs, find_subloop_latch_edge,
mfb_redirect_edges_in_set, form_subloop, merge_latch_edges,
disambiguate_multiple_latches, get_loop_body_with_size,
disambiguate_loops_with_multiple_latches): New functions.
(flow_loop_dump): Dump multiple latch edges.
(flow_loop_nodes_find): Handle loops with multiple latches.
(flow_loops_find): Ditto. Do not call canonicalize_loop_headers.
(glb_enum_p): Modified.
(get_loop_body): Use get_loop_body_with_size.
* cfgloop.h (LOOPS_HAVE_RECORDED_EXITS): New flag.
(AVOID_CFG_MODIFICATIONS): New constant.
(disambiguate_loops_with_multiple_latches, add_loop,
get_loop_body_with_size): Declare.
* Makefile.in (cfgloop.o): Add pointer-set.h and output.h.
2007-02-06 Seongbae Park <seongbae.park@gmail.com> 2007-02-06 Seongbae Park <seongbae.park@gmail.com>
PR inline-asm/28686 PR inline-asm/28686
......
...@@ -2585,7 +2585,7 @@ cfgcleanup.o : cfgcleanup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \ ...@@ -2585,7 +2585,7 @@ cfgcleanup.o : cfgcleanup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(REGS_H) $(EMIT_RTL_H) $(CFGLAYOUT_H) tree-pass.h $(CFGLOOP_H) $(EXPR_H) $(REGS_H) $(EMIT_RTL_H) $(CFGLAYOUT_H) tree-pass.h $(CFGLOOP_H) $(EXPR_H)
cfgloop.o : cfgloop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) coretypes.h $(TM_H) \ cfgloop.o : cfgloop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) coretypes.h $(TM_H) \
$(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(FLAGS_H) $(FUNCTION_H) \ $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(FLAGS_H) $(FUNCTION_H) \
$(OBSTACK_H) toplev.h $(TREE_FLOW_H) $(TREE_H) $(OBSTACK_H) toplev.h $(TREE_FLOW_H) $(TREE_H) pointer-set.h output.h
cfgloopanal.o : cfgloopanal.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) \ cfgloopanal.o : cfgloopanal.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) \
$(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(EXPR_H) coretypes.h $(TM_H) \ $(BASIC_BLOCK_H) hard-reg-set.h $(CFGLOOP_H) $(EXPR_H) coretypes.h $(TM_H) \
$(OBSTACK_H) output.h $(OBSTACK_H) output.h
......
...@@ -378,6 +378,10 @@ redirect_edge_and_branch_force (edge e, basic_block dest) ...@@ -378,6 +378,10 @@ redirect_edge_and_branch_force (edge e, basic_block dest)
rescan_loop_exit (e, false, true); rescan_loop_exit (e, false, true);
ret = cfg_hooks->redirect_edge_and_branch_force (e, dest); ret = cfg_hooks->redirect_edge_and_branch_force (e, dest);
if (ret != NULL
&& dom_info_available_p (CDI_DOMINATORS))
set_immediate_dominator (CDI_DOMINATORS, ret, src);
if (current_loops != NULL) if (current_loops != NULL)
{ {
if (ret != NULL) if (ret != NULL)
...@@ -724,7 +728,8 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge), ...@@ -724,7 +728,8 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
fallthru->count = 0; fallthru->count = 0;
jump = redirect_edge_and_branch_force (e, bb); jump = redirect_edge_and_branch_force (e, bb);
if (jump) if (jump != NULL
&& new_bb_cbk != NULL)
new_bb_cbk (jump); new_bb_cbk (jump);
} }
...@@ -742,9 +747,12 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge), ...@@ -742,9 +747,12 @@ make_forwarder_block (basic_block bb, bool (*redirect_edge_p) (edge),
/* If we do not split a loop header, then both blocks belong to the /* If we do not split a loop header, then both blocks belong to the
same loop. In case we split loop header and do not redirect the same loop. In case we split loop header and do not redirect the
latch edge to DUMMY, then DUMMY belongs to the outer loop, and latch edge to DUMMY, then DUMMY belongs to the outer loop, and
BB becomes the new header. */ BB becomes the new header. If latch is not recorded for the loop,
we leave this updating on the caller (this may only happen during
loop analysis). */
loop = dummy->loop_father; loop = dummy->loop_father;
if (loop->header == dummy if (loop->header == dummy
&& loop->latch != NULL
&& find_edge (loop->latch, dummy) == NULL) && find_edge (loop->latch, dummy) == NULL)
{ {
remove_bb_from_loops (dummy); remove_bb_from_loops (dummy);
......
...@@ -168,11 +168,13 @@ enum ...@@ -168,11 +168,13 @@ enum
LOOPS_HAVE_PREHEADERS = 1, LOOPS_HAVE_PREHEADERS = 1,
LOOPS_HAVE_SIMPLE_LATCHES = 2, LOOPS_HAVE_SIMPLE_LATCHES = 2,
LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS = 4, LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS = 4,
LOOPS_HAVE_RECORDED_EXITS = 8 LOOPS_HAVE_RECORDED_EXITS = 8,
LOOPS_MAY_HAVE_MULTIPLE_LATCHES = 16
}; };
#define LOOPS_NORMAL (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES \ #define LOOPS_NORMAL (LOOPS_HAVE_PREHEADERS | LOOPS_HAVE_SIMPLE_LATCHES \
| LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS) | LOOPS_HAVE_MARKED_IRREDUCIBLE_REGIONS)
#define AVOID_CFG_MODIFICATIONS (LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
typedef struct loop *loop_p; typedef struct loop *loop_p;
DEF_VEC_P (loop_p); DEF_VEC_P (loop_p);
...@@ -198,6 +200,7 @@ struct loops ...@@ -198,6 +200,7 @@ struct loops
/* Loop recognition. */ /* Loop recognition. */
extern int flow_loops_find (struct loops *); extern int flow_loops_find (struct loops *);
extern void disambiguate_loops_with_multiple_latches (void);
extern void flow_loops_free (struct loops *); extern void flow_loops_free (struct loops *);
extern void flow_loops_dump (FILE *, extern void flow_loops_dump (FILE *,
void (*)(const struct loop *, FILE *, int), int); void (*)(const struct loop *, FILE *, int), int);
...@@ -215,6 +218,7 @@ void rescan_loop_exit (edge, bool, bool); ...@@ -215,6 +218,7 @@ void rescan_loop_exit (edge, bool, bool);
/* Loop data structure manipulation/querying. */ /* Loop data structure manipulation/querying. */
extern void flow_loop_tree_node_add (struct loop *, struct loop *); extern void flow_loop_tree_node_add (struct loop *, struct loop *);
extern void flow_loop_tree_node_remove (struct loop *); extern void flow_loop_tree_node_remove (struct loop *);
extern void add_loop (struct loop *, struct loop *);
extern bool flow_loop_nested_p (const struct loop *, const struct loop *); extern bool flow_loop_nested_p (const struct loop *, const struct loop *);
extern bool flow_bb_inside_loop_p (const struct loop *, const basic_block); extern bool flow_bb_inside_loop_p (const struct loop *, const basic_block);
extern struct loop * find_common_loop (struct loop *, struct loop *); extern struct loop * find_common_loop (struct loop *, struct loop *);
...@@ -229,6 +233,8 @@ extern void mark_loop_exit_edges (void); ...@@ -229,6 +233,8 @@ extern void mark_loop_exit_edges (void);
/* Loops & cfg manipulation. */ /* Loops & cfg manipulation. */
extern basic_block *get_loop_body (const struct loop *); extern basic_block *get_loop_body (const struct loop *);
extern unsigned get_loop_body_with_size (const struct loop *, basic_block *,
unsigned);
extern basic_block *get_loop_body_in_dom_order (const struct loop *); extern basic_block *get_loop_body_in_dom_order (const struct loop *);
extern basic_block *get_loop_body_in_bfs_order (const struct loop *); extern basic_block *get_loop_body_in_bfs_order (const struct loop *);
extern VEC (edge, heap) *get_loop_exit_edges (const struct loop *); extern VEC (edge, heap) *get_loop_exit_edges (const struct loop *);
......
...@@ -38,11 +38,9 @@ static void loop_redirect_edge (edge, basic_block); ...@@ -38,11 +38,9 @@ static void loop_redirect_edge (edge, basic_block);
static void remove_bbs (basic_block *, int); static void remove_bbs (basic_block *, int);
static bool rpe_enum_p (basic_block, void *); static bool rpe_enum_p (basic_block, void *);
static int find_path (edge, basic_block **); static int find_path (edge, basic_block **);
static bool alp_enum_p (basic_block, void *);
static void fix_loop_placements (struct loop *, bool *); static void fix_loop_placements (struct loop *, bool *);
static bool fix_bb_placement (basic_block); static bool fix_bb_placement (basic_block);
static void fix_bb_placements (basic_block, bool *); static void fix_bb_placements (basic_block, bool *);
static void place_new_loop (struct loop *);
static basic_block create_preheader (struct loop *, int); static basic_block create_preheader (struct loop *, int);
static void unloop (struct loop *, bool *); static void unloop (struct loop *, bool *);
...@@ -395,39 +393,54 @@ remove_path (edge e) ...@@ -395,39 +393,54 @@ remove_path (edge e)
return true; return true;
} }
/* Predicate for enumeration in add_loop. */ /* Creates place for a new LOOP in loops structure. */
static bool
alp_enum_p (basic_block bb, void *alp_header) static void
place_new_loop (struct loop *loop)
{ {
return bb != (basic_block) alp_header; loop->num = number_of_loops ();
VEC_safe_push (loop_p, heap, current_loops->larray, loop);
} }
/* Given LOOP structure with filled header and latch, find the body of the /* Given LOOP structure with filled header and latch, find the body of the
corresponding loop and add it to loops tree. Insert the LOOP as a son of corresponding loop and add it to loops tree. Insert the LOOP as a son of
outer. */ outer. */
static void void
add_loop (struct loop *loop, struct loop *outer) add_loop (struct loop *loop, struct loop *outer)
{ {
basic_block *bbs; basic_block *bbs;
int i, n; int i, n;
struct loop *subloop;
/* Add it to loop structure. */ /* Add it to loop structure. */
place_new_loop (loop); place_new_loop (loop);
flow_loop_tree_node_add (outer, loop); flow_loop_tree_node_add (outer, loop);
/* Find its nodes. */ /* Find its nodes. */
bbs = XCNEWVEC (basic_block, n_basic_blocks); bbs = XNEWVEC (basic_block, n_basic_blocks);
n = dfs_enumerate_from (loop->latch, 1, alp_enum_p, n = get_loop_body_with_size (loop, bbs, n_basic_blocks);
bbs, n_basic_blocks, loop->header);
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
remove_bb_from_loops (bbs[i]); if (bbs[i]->loop_father == outer)
add_bb_to_loop (bbs[i], loop); {
remove_bb_from_loops (bbs[i]);
add_bb_to_loop (bbs[i], loop);
continue;
}
loop->num_nodes++;
/* If we find a direct subloop of OUTER, move it to LOOP. */
subloop = bbs[i]->loop_father;
if (subloop->outer == outer
&& subloop->header == bbs[i])
{
flow_loop_tree_node_remove (subloop);
flow_loop_tree_node_add (loop, subloop);
}
} }
remove_bb_from_loops (loop->header);
add_bb_to_loop (loop->header, loop);
free (bbs); free (bbs);
} }
...@@ -631,14 +644,6 @@ fix_loop_placements (struct loop *loop, bool *irred_invalidated) ...@@ -631,14 +644,6 @@ fix_loop_placements (struct loop *loop, bool *irred_invalidated)
} }
} }
/* Creates place for a new LOOP in loops structure. */
static void
place_new_loop (struct loop *loop)
{
loop->num = number_of_loops ();
VEC_safe_push (loop_p, heap, current_loops->larray, loop);
}
/* Copies copy of LOOP as subloop of TARGET loop, placing newly /* Copies copy of LOOP as subloop of TARGET loop, placing newly
created loop into loops structure. */ created loop into loops structure. */
struct loop * struct loop *
...@@ -1115,12 +1120,15 @@ create_preheader (struct loop *loop, int flags) ...@@ -1115,12 +1120,15 @@ create_preheader (struct loop *loop, int flags)
gcc_assert (nentry); gcc_assert (nentry);
if (nentry == 1) if (nentry == 1)
{ {
/* Get an edge that is different from the one from loop->latch e = loop_preheader_edge (loop);
to loop->header. */
e = EDGE_PRED (loop->header, if (/* We do not allow entry block to be the loop preheader, since we
EDGE_PRED (loop->header, 0)->src == loop->latch); cannot emit code there. */
e->src != ENTRY_BLOCK_PTR
if (!(flags & CP_SIMPLE_PREHEADERS) || single_succ_p (e->src)) /* If we want simple preheaders, also force the preheader to have
just a single successor. */
&& !((flags & CP_SIMPLE_PREHEADERS)
&& !single_succ_p (e->src)))
return NULL; return NULL;
} }
......
...@@ -48,11 +48,17 @@ a single header, or if there is a branching in the middle of the loop. ...@@ -48,11 +48,17 @@ a single header, or if there is a branching in the middle of the loop.
The representation of loops in GCC however allows only loops with a The representation of loops in GCC however allows only loops with a
single latch. During loop analysis, headers of such loops are split and single latch. During loop analysis, headers of such loops are split and
forwarder blocks are created in order to disambiguate their structures. forwarder blocks are created in order to disambiguate their structures.
A heuristic based on profile information is used to determine whether Heuristic based on profile information and structure of the induction
the latches correspond to sub-loops or to control flow in a single loop. variables in the loops is used to determine whether the latches
This means that the analysis sometimes changes the CFG, and if you run correspond to sub-loops or to control flow in a single loop. This means
it in the middle of an optimization pass, you must be able to deal with that the analysis sometimes changes the CFG, and if you run it in the
the new blocks. middle of an optimization pass, you must be able to deal with the new
blocks. You may avoid CFG changes by passing
@code{LOOPS_MAY_HAVE_MULTIPLE_LATCHES} flag to the loop discovery,
note however that most other loop manipulation functions will not work
correctly for loops with multiple latch edges (the functions that only
query membership of blocks to loops and subloop relationships, or
enumerate and test loop exits, can be expected to work).
Body of the loop is the set of blocks that are dominated by its header, Body of the loop is the set of blocks that are dominated by its header,
and reachable from its latch against the direction of edges in CFG. The and reachable from its latch against the direction of edges in CFG. The
...@@ -96,6 +102,13 @@ bitmask. These flags specify what other properties of the loop ...@@ -96,6 +102,13 @@ bitmask. These flags specify what other properties of the loop
structures should be calculated/enforced and preserved later: structures should be calculated/enforced and preserved later:
@itemize @itemize
@item @code{LOOPS_MAY_HAVE_MULTIPLE_LATCHES}: If this flag is set, no
changes to CFG will be performed in the loop analysis, in particular,
loops with multiple latch edges will not be disambiguated. If a loop
has multiple latches, its latch block is set to NULL. Most of
the loop manipulation functions will not work for loops in this shape.
No other flags that require CFG changes can be passed to
loop_optimizer_init.
@item @code{LOOPS_HAVE_PREHEADERS}: Forwarder blocks are created in such @item @code{LOOPS_HAVE_PREHEADERS}: Forwarder blocks are created in such
a way that each loop has only one entry edge, and additionally, the a way that each loop has only one entry edge, and additionally, the
source block of this entry edge has only one successor. This creates a source block of this entry edge has only one successor. This creates a
......
...@@ -3908,18 +3908,13 @@ if_convert (int x_life_data_ok) ...@@ -3908,18 +3908,13 @@ if_convert (int x_life_data_ok)
num_true_changes = 0; num_true_changes = 0;
life_data_ok = (x_life_data_ok != 0); life_data_ok = (x_life_data_ok != 0);
if ((! targetm.cannot_modify_jumps_p ()) loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
&& (!flag_reorder_blocks_and_partition || !no_new_pseudos if (current_loops)
|| !targetm.have_named_sections))
{ {
loop_optimizer_init (0); mark_loop_exit_edges ();
if (current_loops) loop_optimizer_finalize ();
{
mark_loop_exit_edges ();
loop_optimizer_finalize ();
}
free_dominance_info (CDI_DOMINATORS);
} }
free_dominance_info (CDI_DOMINATORS);
/* Compute postdominators if we think we'll use them. */ /* Compute postdominators if we think we'll use them. */
if (HAVE_conditional_execution || life_data_ok) if (HAVE_conditional_execution || life_data_ok)
......
...@@ -40,22 +40,11 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA ...@@ -40,22 +40,11 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
void void
loop_optimizer_init (unsigned flags) loop_optimizer_init (unsigned flags)
{ {
edge e;
edge_iterator ei;
struct loops *loops; struct loops *loops;
gcc_assert (!current_loops); gcc_assert (!current_loops);
loops = XCNEW (struct loops); loops = XCNEW (struct loops);
/* Avoid annoying special cases of edges going to exit
block. */
for (ei = ei_start (EXIT_BLOCK_PTR->preds); (e = ei_safe_edge (ei)); )
if ((e->flags & EDGE_FALLTHRU) && !single_succ_p (e->src))
split_edge (e);
else
ei_next (&ei);
/* Find the loops. */ /* Find the loops. */
flow_loops_find (loops); flow_loops_find (loops);
...@@ -69,6 +58,19 @@ loop_optimizer_init (unsigned flags) ...@@ -69,6 +58,19 @@ loop_optimizer_init (unsigned flags)
return; return;
} }
if (flags & LOOPS_MAY_HAVE_MULTIPLE_LATCHES)
{
/* If the loops may have multiple latches, we cannot canonicalize
them further (and most of the loop manipulation functions will
not work). However, we avoid modifying cfg, which some
passes may want. */
gcc_assert ((flags & ~(LOOPS_MAY_HAVE_MULTIPLE_LATCHES
| LOOPS_HAVE_RECORDED_EXITS)) == 0);
current_loops->state = LOOPS_MAY_HAVE_MULTIPLE_LATCHES;
}
else
disambiguate_loops_with_multiple_latches ();
/* Create pre-headers. */ /* Create pre-headers. */
if (flags & LOOPS_HAVE_PREHEADERS) if (flags & LOOPS_HAVE_PREHEADERS)
create_preheaders (CP_SIMPLE_PREHEADERS); create_preheaders (CP_SIMPLE_PREHEADERS);
......
2007-02-06 Zdenek Dvorak <dvorakz@suse.cz>
* gcc.dg/tree-ssa/loop-25.c: New test.
2007-02-06 Richard Henderson <rth@redhat.com> 2007-02-06 Richard Henderson <rth@redhat.com>
* gcc.target/i386/cvt-1.c: Don't expect xmm registers. * gcc.target/i386/cvt-1.c: Don't expect xmm registers.
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1" } */
int foo(void);
void bla(void);
void bar(void);
void test1 (void)
{
unsigned i;
/* Only one loop should be found here. */
i = 0;
while (1)
{
i++;
if (i == 100)
break;
if (foo ())
bla ();
else
bar ();
}
}
void test2 (void)
{
unsigned i, j;
/* Two loops should be found, in this case. */
i = j = 0;
while (1)
{
j++;
foo ();
if (j < 100)
continue;
i++;
j = 0;
if (i == 100)
break;
}
}
void test3 (void)
{
unsigned i, j, k;
/* Three loops. */
i = j = k = 0;
while (1)
{
j++;
foo ();
if (j < 100)
continue;
j = 0;
k++;
if (k < 100)
continue;
k = 0;
i++;
if (i == 100)
break;
}
}
void test4 (void)
{
unsigned i, j, k;
/* Two loops with a nested subloop. */
i = j = 0;
while (1)
{
j++;
foo ();
for (k = 0; k < 100; k++)
foo ();
if (j < 100)
continue;
i++;
j = 0;
if (i == 100)
break;
}
}
void test5 (void)
{
unsigned i, j;
/* Both subloop and non-subloop back edges. */
i = j = 0;
while (1)
{
j++;
foo ();
if (j < 100)
continue;
j = 0;
i++;
if (i == 100)
break;
if (foo ())
bla ();
else
bar ();
}
}
/* { dg-final { scan-tree-dump-times "Disambiguating loop" 5 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "Found latch edge" 5 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "Merged latch edges" 2 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "4 loops found" 2 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "3 loops found" 2 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "2 loops found" 1 "vrp1" } } */
/* { dg-final { cleanup-tree-dump "vrp1" } } */
...@@ -582,8 +582,8 @@ cleanup_tree_cfg_loop (void) ...@@ -582,8 +582,8 @@ cleanup_tree_cfg_loop (void)
if (changed) if (changed)
{ {
bitmap changed_bbs = BITMAP_ALLOC (NULL); bitmap changed_bbs = BITMAP_ALLOC (NULL);
fix_loop_structure (changed_bbs);
calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_DOMINATORS);
fix_loop_structure (changed_bbs);
/* This usually does nothing. But sometimes parts of cfg that originally /* This usually does nothing. But sometimes parts of cfg that originally
were inside a loop get out of it due to edge removal (since they were inside a loop get out of it due to edge removal (since they
......
...@@ -279,7 +279,7 @@ tree_ssa_dominator_optimize (void) ...@@ -279,7 +279,7 @@ tree_ssa_dominator_optimize (void)
/* We need to know which edges exit loops so that we can /* We need to know which edges exit loops so that we can
aggressively thread through loop headers to an exit aggressively thread through loop headers to an exit
edge. */ edge. */
loop_optimizer_init (0); loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
if (current_loops) if (current_loops)
{ {
mark_loop_exit_edges (); mark_loop_exit_edges ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment