This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] CCP fixes for abnormal edges
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 31 Mar 2003 14:49:30 -0700
- Subject: [tree-ssa] CCP fixes for abnormal edges
- Reply-to: law at redhat dot com
While working on the C++ CFG bits, I stumbled upon a bug in our CCP
implementation. Namely we don't handle abnormal edges in any sane
way.
First if we have abnormal edges, they must be considered executable
as soon as the block containing those edges becomes executable.
Second, if we have a block with one normal edge and at least one
abnormal edge, then we need to make sure to add the normal edge
to the edge worklist when the block becomes executable.
Bootstrapped and regression tested.
* tree-ssa-ccp.c (simulate_block): Add abnormal edges out of a
block to the edge worklist after simulating a block for the
first time. If the block has a single outgoing normal edge,
add that edge to the worklist after simulating the block for
the first time.
Index: tree-ssa-ccp.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-ccp.c,v
retrieving revision 1.1.2.65
diff -c -3 -p -r1.1.2.65 tree-ssa-ccp.c
*** tree-ssa-ccp.c 24 Mar 2003 20:27:57 -0000 1.1.2.65
--- tree-ssa-ccp.c 31 Mar 2003 21:44:56 -0000
*************** simulate_block (block)
*** 227,232 ****
--- 227,234 ----
if (!TEST_BIT (executable_blocks, block->index))
{
block_stmt_iterator j;
+ unsigned int normal_edge_count;
+ edge e, normal_edge;
/* Note that we have simulated this block. */
SET_BIT (executable_blocks, block->index);
*************** simulate_block (block)
*** 234,243 ****
for (j = bsi_start (block); !bsi_end_p (j); bsi_next (&j))
visit_stmt (bsi_stmt (j));
! /* If the block has a single successor, it will always get executed.
! Add it to the worklist. */
! if (block->succ && block->succ->succ_next == NULL)
! add_control_edge (block->succ);
}
}
--- 236,265 ----
for (j = bsi_start (block); !bsi_end_p (j); bsi_next (&j))
visit_stmt (bsi_stmt (j));
! /* We can not predict when abnormal edges will be executed, so
! once a block is considered executable, we consider any
! outgoing abnormal edges as executable.
!
! At the same time, if this block has only one successor that is
! reached by non-abnormal edges, then add that successor to the
! worklist. */
! normal_edge_count = 0;
! normal_edge = NULL;
! for (e = block->succ; e; e = e->succ_next)
! {
! if (e->flags & EDGE_ABNORMAL)
! {
! add_control_edge (e);
! }
! else
! {
! normal_edge_count++;
! normal_edge = e;
! }
! }
!
! if (normal_edge_count == 1)
! add_control_edge (normal_edge);
}
}