parse.y (java_complete_lhs case EXPR_WITH_FILE_LOCATION): If body is constant, return...
authorPer Bothner <per@bothner.com>
Sun, 14 Jan 2001 20:46:32 +0000 (12:46 -0800)
committerPer Bothner <bothner@gcc.gnu.org>
Sun, 14 Jan 2001 20:46:32 +0000 (12:46 -0800)
* 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.

From-SVN: r39017

gcc/java/ChangeLog
gcc/java/lex.c
gcc/java/parse.y

index 0907e731642e162cfa5e670b8bb7f7a4e4d7d7d0..1a00840a2d02025e21501566e91b65556de176bd 100644 (file)
@@ -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
index dddb3cd44557086311dfbdc0b0881403f206a17b..338f3d5991b970438e9179ec9edb7e4857f02344 100644 (file)
@@ -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
 
index 873de308287add7e49c98e2c4e3c074ea0363142..74e17fe31d6af5557a8fb9d11b4443d76297592e 100644 (file)
@@ -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)