This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: don't generate dead bytecode
- To: Per Bothner <per at bothner dot com>
- Subject: Re: Patch: don't generate dead bytecode
- From: Per Bothner <per at bothner dot com>
- Date: Thu, 11 Oct 2001 16:36:13 -0700
- CC: tromey at redhat dot com, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Java Patch List <java-patches at gcc dot gnu dot org>, Alexandre Petit-Bianco <apbianco at cygnus dot com>
- References: <87elocq19k.fsf@creche.redhat.com> <3BC39195.6040803@bothner.com> <3BC3990B.3000000@bothner.com>
Per Bothner wrote:
I checked in this patch:
2001-10-11 Per Bothner <per@bothner.com>
* parse.y (patch_if_else_statement): If the condition is constant,
optimize away the test.
>------------------------------------------------------------------------
>
>Index: parse.y
>===================================================================
>RCS file: /cvs/gcc/gcc/gcc/java/parse.y,v
>retrieving revision 1.318
>diff -u -p -r1.318 parse.y
>--- parse.y 2001/10/09 05:40:35 1.318
>+++ parse.y 2001/10/10 00:02:47
>@@ -15008,6 +14993,9 @@ patch_if_else_statement (node)
> tree node;
> {
> tree expression = TREE_OPERAND (node, 0);
>+ int can_complete_normally
>+ = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
>+ | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2)));
>
> TREE_TYPE (node) = error_mark_node;
> EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
>@@ -15023,11 +15011,22 @@ patch_if_else_statement (node)
> return error_mark_node;
> }
>
>+ if (TREE_CODE (expression) == INTEGER_CST)
>+ {
>+ if (integer_zerop (expression))
>+ node = TREE_OPERAND (node, 2);
>+ else
>+ node = TREE_OPERAND (node, 1);
>+ if (CAN_COMPLETE_NORMALLY (node) != can_complete_normally)
>+ {
>+ node = build (COMPOUND_EXPR, void_type_node, node, empty_stmt_node);
>+ CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
>+ }
>+ return node;
>+ }
> TREE_TYPE (node) = void_type_node;
> TREE_SIDE_EFFECTS (node) = 1;
>- CAN_COMPLETE_NORMALLY (node)
>- = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
>- | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
>+ CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
> return node;
> }
>
>