This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[tree-ssa] Splitting abnormal edges
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Andrew MacLeod <amacleod at redhat dot com>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Jun 2003 00:41:55 -0400 (EDT)
- Subject: [tree-ssa] Splitting abnormal edges
On 13 Jun 2003, Andrew MacLeod wrote:
> * tree-cfg.c (bsi_commit_first_edge_insert): Only consider non-abnormal
> edges when determining whether an edge needs to be split.
I think I can explain why this didn't help my Java tests.
We ignore abnormal outgoing edges for consideration in edge splitting,
which is fine:
> ! for (e2 = src->succ; e2; e2 = e2->succ_next)
> ! if (!(e2->flags & EDGE_ABNORMAL))
> ! num_exit++;
though we later fall back on edge splitting for control-altering blocks:
if (!is_ctrl_stmt (last) && !is_ctrl_altering_stmt (last))
{
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
return bsi;
}
The trouble being that is_ctrl_altering_stmt often returns 1 for
statements we don't care about, i.e. certain CALL_EXPR and MODIFY_EXPR
nodes that merely introduce an abnormal edge.
For instance, the block in question has:
BLOCK 12
PRED: 11
SUCC: 16 13 (ab)
PARENT: 7
LOOP DEPTH: 0
NEXT BLOCK: 13
PREV BLOCK: 11
18 T.12 = T.11
18 parseInt.13 = (int (*<UPFNde00>) (struct java.lang.String *))parseInt
18 T.14 = parseInt.13 (T.12)
The quick patch below fixes this case but isn't quite right, since it
doesn't consider functions that longjmp or don't return.
Perhaps it would be cleaner if is_ctrl_altering_stmt() were split into two
functions, with something like stmt_may_throw_p(). Or have it
consider EDGE_FALLTHRU cases only. Andrew, what do you think?
* tree-cfg.c (bsi_commit_first_edge_insert): Don't use
is_ctrl_altering_stmt when deciding not to split an edge.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.108
diff -u -p -r1.1.4.108 tree-cfg.c
--- tree-cfg.c 14 Jun 2003 20:56:00 -0000 1.1.4.108
+++ tree-cfg.c 16 Jun 2003 04:34:07 -0000
@@ -3862,7 +3862,8 @@ bsi_commit_first_edge_insert (edge e, tr
append this stmt to the basic block. This should mean the edge
is
a fallthrough edge. */
- if (!is_ctrl_stmt (last) && !is_ctrl_altering_stmt (last))
+ if (!is_ctrl_stmt (last) && TREE_CODE (last) != GOTO_EXPR
+ && TREE_CODE (last) != RETURN_EXPR)
{
bsi_insert_after (&bsi, stmt, BSI_NEW_STMT);
return bsi;