gimplify.c (maybe_with_size_expr): If already have WITH_SIZE_EXPR, don't make another...
authorRichard Kenner <kenner@vlsi1.ultra.nyu.edu>
Wed, 28 Jul 2004 02:57:25 +0000 (02:57 +0000)
committerRichard Kenner <kenner@gcc.gnu.org>
Wed, 28 Jul 2004 02:57:25 +0000 (22:57 -0400)
* gimplify.c (maybe_with_size_expr): If already have WITH_SIZE_EXPR,
don't make another one.

From-SVN: r85249

gcc/ChangeLog
gcc/gimplify.c

index b1d01918c1e07c80466a8347913d1034e7fd4b11..60411fac08e6436d6a341a8e04bbc20e5ccc7859 100644 (file)
@@ -1,5 +1,8 @@
 2004-07-27  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>
 
+       * gimplify.c (maybe_with_size_expr): If already have WITH_SIZE_EXPR,
+       don't make another one.
+
        PR optimization/15077
        * function.h (struct function): Add field saved_static_chain_decl.
        Fix comment for static_chain_decl.
index fc260c8ce4deef8614a8c26448ca2fed4c3e2c6f..304a20b108259c4aac8fb939d61f875cff6b8edd 100644 (file)
@@ -1746,20 +1746,25 @@ gimplify_self_mod_expr (tree *expr_p, tree *pre_p, tree *post_p,
 static void
 maybe_with_size_expr (tree *expr_p)
 {
-  tree expr, type, size;
+  tree expr = *expr_p;
+  tree type = TREE_TYPE (expr);
+  tree size;
 
-  expr = *expr_p;
-  type = TREE_TYPE (expr);
-  if (type == error_mark_node)
+  /* If we've already wrapped this or the type is error_mark_node, we can't do
+     anything.  */
+  if (TREE_CODE (expr) == WITH_SIZE_EXPR
+      || type == error_mark_node)
     return;
 
+  /* If the size isn't known or is a constant, we have nothing to do.  */
   size = TYPE_SIZE_UNIT (type);
-  if (size && TREE_CODE (size) != INTEGER_CST)
-    {
-      size = unshare_expr (size);
-      size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, expr);
-      *expr_p = build2 (WITH_SIZE_EXPR, type, expr, size);
-    }
+  if (!size || TREE_CODE (size) == INTEGER_CST)
+    return;
+
+  /* Otherwise, make a WITH_SIZE_EXPR.  */
+  size = unshare_expr (size);
+  size = SUBSTITUTE_PLACEHOLDER_IN_EXPR (size, expr);
+  *expr_p = build2 (WITH_SIZE_EXPR, type, expr, size);
 }
 
 /* Subroutine of gimplify_call_expr:  Gimplify a single argument.  */