This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[ tree-ssa] Useless jumps
- From: law at redhat dot com
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 06 May 2003 11:55:35 -0600
- Subject: [ tree-ssa] Useless jumps
- Reply-to: law at redhat dot com
tree-ssa can create numerous useless GOTO_EXPRs, especially when inlining.
While these will be cleaned up at the RTL level, it's better to zap them
and avoid expanding them to begin with.
This patch eliminates GOTO_EXPRs which jump to the next tree statement.
There's still going to be lots of useless GOTO_EXPRs that occur from
jumping out of a control statement. But zapping those is, errr, more
difficult.
* tree-cfg.c (remove_useless_stmts_and_vars): Remove GOTO_EXPRs
to the immediately following tree node.
Index: tree-cfg.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-cfg.c,v
retrieving revision 1.1.4.81
diff -c -3 -p -r1.1.4.81 tree-cfg.c
*** tree-cfg.c 6 May 2003 15:31:41 -0000 1.1.4.81
--- tree-cfg.c 6 May 2003 16:13:24 -0000
*************** remove_useless_stmts_and_vars (first_p)
*** 1462,1467 ****
--- 1462,1487 ----
if (IS_EMPTY_STMT (*stmt_p))
repeat = 1;
}
+ else if (code == GOTO_EXPR)
+ {
+ tree_stmt_iterator tsi = i;
+
+ /* We can remove a GOTO_EXPR if the next tree statement is
+ the destination of the GOTO_EXPR. */
+ tsi_next (&tsi);
+ if (! tsi_end_p (tsi))
+ {
+ tree label;
+
+ label = tsi_stmt (tsi);
+ if (TREE_CODE (label) == LABEL_EXPR
+ && LABEL_EXPR_LABEL (label) == GOTO_DESTINATION (*stmt_p))
+ {
+ repeat = 1;
+ *stmt_p = build_empty_stmt ();
+ }
+ }
+ }
/* We need to keep the tree in gimple form, so we may have to
re-rationalize COMPOUND_EXPRs. */