This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[CFG] Minor loop fixes
- From: Zdenek Dvorak <rakdver at atrey dot karlin dot mff dot cuni dot cz>
- To: gcc-pdo at atrey dot karlin dot mff dot cuni dot cz, gcc-patches at gcc dot gnu dot org
- Date: Fri, 31 May 2002 01:51:51 +0200
- Subject: [CFG] Minor loop fixes
Hello.
Some minor fixes.
Zdenek
* basic_block.h (struct loops): Comment fix.
* cfgloop.c (flow_loop_exit_edges_find): Comment fix.
(canonicalize_loop_headers): Use split_edge.
(flow_bb_inside_loop_p, verify_loop_structure, loop_latch_edge,
loop_preheader_edge): Formating fix.
Index: basic-block.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/basic-block.h,v
retrieving revision 1.127.2.28
diff -c -3 -p -r1.127.2.28 basic-block.h
*** basic-block.h 24 May 2002 20:52:59 -0000 1.127.2.28
--- basic-block.h 30 May 2002 23:43:37 -0000
*************** struct loops
*** 484,490 ****
will find the inner loops before their enclosing outer loops). */
struct loop *array;
! /* In new loop.c, we store only pointers here. */
struct loop **parray;
/* Pointer to root of loop heirachy tree. */
--- 484,492 ----
will find the inner loops before their enclosing outer loops). */
struct loop *array;
! /* The above array is unused in new loop infrastructure and is kept only for
! purposes of the old loop optimizer. Instead we store just pointers to
! loops here. */
struct loop **parray;
/* Pointer to root of loop heirachy tree. */
Index: cfgloop.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgloop.c,v
retrieving revision 1.2.2.19
diff -c -3 -p -r1.2.2.19 cfgloop.c
*** cfgloop.c 24 May 2002 20:53:15 -0000 1.2.2.19
--- cfgloop.c 30 May 2002 23:43:37 -0000
*************** flow_loop_exit_edges_find (loop)
*** 284,291 ****
/* Check all nodes within the loop to see if there are any
successors not in the loop. Note that a node may have multiple
! exiting edges ????? A node can have one jumping edge and one fallthru
! edge so only one of these can exit the loop. */
num_exits = 0;
bbs = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
--- 284,290 ----
/* Check all nodes within the loop to see if there are any
successors not in the loop. Note that a node may have multiple
! exiting edges. */
num_exits = 0;
bbs = get_loop_body (loop);
for (i = 0; i < loop->num_nodes; i++)
*************** canonicalize_loop_headers ()
*** 692,726 ****
if (HEADER_BLOCK (ENTRY_BLOCK_PTR->succ->dest))
{
- rtx insn;
- edge fallthru, next_e;
basic_block bb;
/* We could not redirect edges freely here. On the other hand,
we know that no abnormal edge enters this block, so we can simply
! split it into two... */
! bb = ENTRY_BLOCK_PTR->succ->dest;
! insn = PREV_INSN (first_insn_after_basic_block_note (bb));
! fallthru = split_block (bb, insn);
! /* And redirect all edges to second part. */
! for (e = fallthru->src->pred; e; e = next_e)
! {
! next_e = e->pred_next;
! if (e->src == ENTRY_BLOCK_PTR)
! continue;
! fallthru->src->frequency -= EDGE_FREQUENCY (e);
! fallthru->src->count -= e->count;
! if (fallthru->src->frequency < 0)
! fallthru->src->frequency = 0;
! if (fallthru->src->count < 0)
! fallthru->src->count = 1;
! redirect_edge_with_latch_update (e, fallthru->dest);
! }
! alloc_aux_for_edge (fallthru, sizeof (int));
! LATCH_EDGE (fallthru) = 0;
! alloc_aux_for_block (fallthru->dest, sizeof (int));
! HEADER_BLOCK (fallthru->dest) = HEADER_BLOCK (fallthru->src);
! HEADER_BLOCK (fallthru->src) = 0;
}
for (b = 0; b < n_basic_blocks; )
--- 691,707 ----
if (HEADER_BLOCK (ENTRY_BLOCK_PTR->succ->dest))
{
basic_block bb;
+
/* We could not redirect edges freely here. On the other hand,
we know that no abnormal edge enters this block, so we can simply
! split the edge from entry block. */
! bb = split_edge (ENTRY_BLOCK_PTR->succ);
! alloc_aux_for_edge (bb->succ, sizeof (int));
! LATCH_EDGE (bb->succ) = 0;
! alloc_aux_for_block (bb, sizeof (int));
! HEADER_BLOCK (bb) = 0;
}
for (b = 0; b < n_basic_blocks; )
*************** flow_bb_inside_loop_p (loop, bb)
*** 1000,1006 ****
const basic_block bb;
{
struct loop *source_loop;
! if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR) return 0;
source_loop = bb->loop_father;
return loop == source_loop || flow_loop_nested_p (loop, source_loop);
}
--- 981,990 ----
const basic_block bb;
{
struct loop *source_loop;
!
! if (bb == ENTRY_BLOCK_PTR || bb == EXIT_BLOCK_PTR)
! return 0;
!
source_loop = bb->loop_father;
return loop == source_loop || flow_loop_nested_p (loop, source_loop);
}
*************** find_common_loop (loop_s, loop_d)
*** 1149,1155 ****
-- loop header have just single entry edge and single latch edge
-- loop latches have only single successor that is header of their loop
-- sanity of frequencies */
! void verify_loop_structure (loops, flags)
struct loops *loops;
int flags;
{
--- 1133,1140 ----
-- loop header have just single entry edge and single latch edge
-- loop latches have only single successor that is header of their loop
-- sanity of frequencies */
! void
! verify_loop_structure (loops, flags)
struct loops *loops;
int flags;
{
*************** loop_latch_edge (loop)
*** 1307,1313 ****
{
edge e;
! for (e = loop->header->pred; e->src != loop->latch; e = e->pred_next);
return e;
}
--- 1292,1300 ----
{
edge e;
! for (e = loop->header->pred; e->src != loop->latch; e = e->pred_next)
! continue;
!
return e;
}
*************** loop_preheader_edge (loop)
*** 1317,1323 ****
{
edge e;
! for (e = loop->header->pred; e->src == loop->latch; e = e->pred_next);
return e;
}
--- 1304,1312 ----
{
edge e;
! for (e = loop->header->pred; e->src == loop->latch; e = e->pred_next)
! continue;
!
return e;
}