builtins.c (fold_builtin): Don't generate NOP_EXPR that is going to be thrown away...
authorJan Hubicka <jh@suse.cz>
Fri, 27 Oct 2006 22:47:47 +0000 (00:47 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 27 Oct 2006 22:47:47 +0000 (22:47 +0000)
* builtins.c (fold_builtin): Don't generate NOP_EXPR that is going
to be thrown away soon when IGNORE is set.
* tree-ssa-ccp.c (convert_to_gimple_builtin): Add IGNORE argument
indicating when return value shall not be computed.
* gimplify.c (internal_get_tmp_var): Avoid random tree sharing.

From-SVN: r118091

gcc/ChangeLog
gcc/builtins.c
gcc/gimplify.c
gcc/tree-ssa-ccp.c

index 0ebad7c0bba138e66e71242a26101b8784dcfd1f..eee8ad3c6b2594ae1539285d561450d620c321d3 100644 (file)
@@ -1,3 +1,11 @@
+2006-10-27  Jan Hubicka  <jh@suse.cz>
+
+       * builtins.c (fold_builtin): Don't generate NOP_EXPR that is going
+       to be thrown away soon when IGNORE is set.
+       * tree-ssa-ccp.c (convert_to_gimple_builtin): Add IGNORE argument
+       indicating when return value shall not be computed.
+       * gimplify.c (internal_get_tmp_var): Avoid random tree sharing.
+
 2006-10-27  Vladimir Makarov  <vmakarov@redhat.com>
 
        * config/i386/i386.h (TARGET_GEODE):
index 694185d73ad7856b869ecba903b5dcb560935ff8..fec89cc225b2e779f375fbf7e268216ca5e33a3e 100644 (file)
@@ -9273,7 +9273,7 @@ tree
 fold_builtin (tree fndecl, tree arglist, bool ignore)
 {
   tree exp = fold_builtin_1 (fndecl, arglist, ignore);
-  if (exp)
+  if (exp && !ignore)
     {
       exp = build1 (NOP_EXPR, TREE_TYPE (exp), exp);
       TREE_NO_WARNING (exp) = 1;
index 41486f15067374bca2faadb817bbd06ebf4449bb..fedc2842229b5437475bbe01b47ed3fe545c6cf3 100644 (file)
@@ -609,7 +609,7 @@ internal_get_tmp_var (tree val, tree *pre_p, tree *post_p, bool is_formal)
   if (TREE_CODE (TREE_TYPE (t)) == COMPLEX_TYPE)
     DECL_COMPLEX_GIMPLE_REG_P (t) = 1;
 
-  mod = build2 (INIT_EXPR, TREE_TYPE (t), t, val);
+  mod = build2 (INIT_EXPR, TREE_TYPE (t), t, unshare_expr (val));
 
   if (EXPR_HAS_LOCATION (val))
     SET_EXPR_LOCUS (mod, EXPR_LOCUS (val));
index 8c31a861a8b88be1fa0293b120b59e7a9f653814..3be926d9ccea0fce5185cd14391b1fa75a0d4c51 100644 (file)
@@ -2465,17 +2465,24 @@ fold_stmt_inplace (tree stmt)
 \f
 /* Convert EXPR into a GIMPLE value suitable for substitution on the
    RHS of an assignment.  Insert the necessary statements before
-   iterator *SI_P.  */
+   iterator *SI_P. 
+   When IGNORE is set, don't worry about the return value.  */
 
 static tree
-convert_to_gimple_builtin (block_stmt_iterator *si_p, tree expr)
+convert_to_gimple_builtin (block_stmt_iterator *si_p, tree expr, bool ignore)
 {
   tree_stmt_iterator ti;
   tree stmt = bsi_stmt (*si_p);
   tree tmp, stmts = NULL;
 
   push_gimplify_context ();
-  tmp = get_initialized_tmp_var (expr, &stmts, NULL);
+  if (ignore)
+    {
+      tmp = build_empty_stmt ();
+      gimplify_and_add (expr, &stmts);
+    }
+  else
+    tmp = get_initialized_tmp_var (expr, &stmts, NULL);
   pop_gimplify_context (NULL);
 
   if (EXPR_HAS_LOCATION (stmt))
@@ -2551,7 +2558,9 @@ execute_fold_all_builtins (void)
 
          if (!set_rhs (stmtp, result))
            {
-             result = convert_to_gimple_builtin (&i, result);
+             result = convert_to_gimple_builtin (&i, result,
+                                                 TREE_CODE (old_stmt)
+                                                 != MODIFY_EXPR);
              if (result)
                {
                  bool ok = set_rhs (stmtp, result);