diff options
| author | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-01-14 20:46:32 +0000 |
|---|---|---|
| committer | bothner <bothner@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-01-14 20:46:32 +0000 |
| commit | d62727db7f2af9df86c5eccd93eb66569f7cda88 (patch) | |
| tree | 9e4aef705f18edbdce9dd190a5e5106926a873cd | |
| parent | 35b0bfe2639704daf3b82bf70883f6e0b8a1bac8 (diff) | |
| download | ppe42-gcc-d62727db7f2af9df86c5eccd93eb66569f7cda88.tar.gz ppe42-gcc-d62727db7f2af9df86c5eccd93eb66569f7cda88.zip | |
* parse.y (java_complete_lhs case EXPR_WITH_FILE_LOCATION): If body is
constant, return body without wrapper. (Improves constant folding.)
* lex.c (build_wfl_node): Clear TREE_TYPE from returned node.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@39017 138bc75d-0d04-0410-961f-82ee72b054a4
| -rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
| -rw-r--r-- | gcc/java/lex.c | 5 | ||||
| -rw-r--r-- | gcc/java/parse.y | 4 |
3 files changed, 12 insertions, 3 deletions
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 0907e731642..1a00840a2d0 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -1,3 +1,9 @@ +2001-01-14 Per Bothner <per@bothner.com> + + * parse.y (java_complete_lhs case EXPR_WITH_FILE_LOCATION): If body is + constant, return body without wrapper. (Improves constant folding.) + * lex.c (build_wfl_node): Clear TREE_TYPE from returned node. + 2001-01-13 Per Bothner <per@bothner.com> * expr.c (expand_java_field_op): Assigning to a final field outside diff --git a/gcc/java/lex.c b/gcc/java/lex.c index dddb3cd4455..338f3d5991b 100644 --- a/gcc/java/lex.c +++ b/gcc/java/lex.c @@ -1642,7 +1642,10 @@ static tree build_wfl_node (node) tree node; { - return build_expr_wfl (node, ctxp->filename, ctxp->elc.line, ctxp->elc.col); + node = build_expr_wfl (node, ctxp->filename, ctxp->elc.line, ctxp->elc.col); + /* Prevent java_complete_lhs from short-circuiting node (if constant). */ + TREE_TYPE (node) = NULL_TREE; + return node; } #endif diff --git a/gcc/java/parse.y b/gcc/java/parse.y index 873de308287..74e17fe31d6 100644 --- a/gcc/java/parse.y +++ b/gcc/java/parse.y @@ -11485,9 +11485,9 @@ java_complete_lhs (node) EXPR_WFL_NODE (node) = body; TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body); CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body); - if (body == empty_stmt_node) + if (body == empty_stmt_node || TREE_CONSTANT (body)) { - /* Optimization; makes it easier to detect empty bodies. */ + /* Makes it easier to constant fold, detect empty bodies. */ return body; } if (body == error_mark_node) |

