tree-ssa-ccp.c (ccp_fold_stmt): Unshare values we substitute.
authorRichard Guenther <rguenther@suse.de>
Fri, 29 Jan 2010 12:19:36 +0000 (12:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 29 Jan 2010 12:19:36 +0000 (12:19 +0000)
2010-01-29  Richard Guenther  <rguenther@suse.de>

* tree-ssa-ccp.c (ccp_fold_stmt): Unshare values we substitute.
Assert we successfully updated the call.

From-SVN: r156346

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

index 5856b0ce06d6668703af775d244712753b882f9a..b3483cbc91d892fe87476d223bd63c21c4d5de02 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-29  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-ccp.c (ccp_fold_stmt): Unshare values we substitute.
+       Assert we successfully updated the call.
+
 2010-01-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/42889
index f6380ebdbe7bcc905e930a5574b494b18d630502..238361166b9c0bec70815c8437776ff42a4a2432 100644 (file)
@@ -1518,11 +1518,13 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
            && (val = get_value (lhs))
            && val->lattice_val == CONSTANT)
          {
-           tree new_rhs = val->value;
+           tree new_rhs = unshare_expr (val->value);
+           bool res;
            if (!useless_type_conversion_p (TREE_TYPE (lhs),
                                            TREE_TYPE (new_rhs)))
              new_rhs = fold_convert (TREE_TYPE (lhs), new_rhs);
-           update_call_from_tree (gsi, new_rhs);
+           res = update_call_from_tree (gsi, new_rhs);
+           gcc_assert (res);
            return true;
          }
 
@@ -1542,7 +1544,7 @@ ccp_fold_stmt (gimple_stmt_iterator *gsi)
                     (TYPE_MAIN_VARIANT (TREE_VALUE (argt)),
                      TYPE_MAIN_VARIANT (TREE_TYPE (val->value))))
              {
-               gimple_call_set_arg (stmt, i, val->value);
+               gimple_call_set_arg (stmt, i, unshare_expr (val->value));
                changed = true;
              }
          }