OSDN Git Service

2009-04-29 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 29 Apr 2009 15:05:22 +0000 (15:05 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 29 Apr 2009 15:05:22 +0000 (15:05 +0000)
PR middle-end/39937
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Do not
loose type conversions.
(forward_propagate_addr_expr): Fix tuplification bug.  Remove
stmts only if there are no uses of its definition.

* gcc.c-torture/compile/pr39937.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@146973 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr39937.c [new file with mode: 0644]
gcc/tree-ssa-forwprop.c

index 7d36429..3c18dfc 100644 (file)
@@ -1,3 +1,11 @@
+2009-04-29  Richard Guenther  <rguenther@suse.de>
+
+       PR middle-end/39937
+       * tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Do not
+       loose type conversions.
+       (forward_propagate_addr_expr): Fix tuplification bug.  Remove
+       stmts only if there are no uses of its definition.
+
 2009-04-29  Bernd Schmidt  <bernd.schmidt@analog.com>
 
        * config/bfin/bfin.h (splitting_loops): Declare.
index 4533e4b..beb916f 100644 (file)
@@ -1,5 +1,10 @@
 2009-04-29  Richard Guenther  <rguenther@suse.de>
 
+       PR middle-end/39937
+       * gcc.c-torture/compile/pr39937.c: New testcase.
+
+2009-04-29  Richard Guenther  <rguenther@suse.de>
+
        PR tree-optimization/39941
        * gcc.c-torture/compile/pr39941.c: New testcase.
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr39937.c b/gcc/testsuite/gcc.c-torture/compile/pr39937.c
new file mode 100644 (file)
index 0000000..d023105
--- /dev/null
@@ -0,0 +1,12 @@
+int foo (__const char *__restrict __s);
+static void 
+read_anisou(char line[])
+{
+  foo (line+1);
+}
+void
+read_pdbfile(void)
+{
+  char line[4096];
+  read_anisou (line);
+}
index c596e8b..65b02af 100644 (file)
@@ -862,12 +862,21 @@ forward_propagate_addr_expr_1 (tree name, tree def_rhs,
      of the elements in X into &x[C1 + C2/element size].  */
   if (TREE_CODE (rhs2) == INTEGER_CST)
     {
-      tree new_rhs = maybe_fold_stmt_addition (gimple_expr_type (use_stmt),
+      tree new_rhs = maybe_fold_stmt_addition (TREE_TYPE (def_rhs),
                                               def_rhs, rhs2);
       if (new_rhs)
        {
-         gimple_assign_set_rhs_from_tree (use_stmt_gsi,
-                                          unshare_expr (new_rhs));
+         tree type = TREE_TYPE (gimple_assign_lhs (use_stmt));
+         new_rhs = unshare_expr (new_rhs);
+         if (!useless_type_conversion_p (type, TREE_TYPE (new_rhs)))
+           {
+             if (!is_gimple_min_invariant (new_rhs))
+               new_rhs = force_gimple_operand_gsi (use_stmt_gsi, new_rhs,
+                                                   true, NULL_TREE,
+                                                   true, GSI_SAME_STMT);
+             new_rhs = fold_convert (type, new_rhs);
+           }
+         gimple_assign_set_rhs_from_tree (use_stmt_gsi, new_rhs);
          use_stmt = gsi_stmt (*use_stmt_gsi);
          update_stmt (use_stmt);
          tidy_after_forward_propagate_addr (use_stmt);
@@ -950,9 +959,8 @@ forward_propagate_addr_expr (tree name, tree rhs)
       use_rhs = gimple_assign_rhs1 (use_stmt);
       if (result
          && TREE_CODE (gimple_assign_lhs (use_stmt)) == SSA_NAME
-         && (TREE_CODE (use_rhs) == SSA_NAME
-             || (CONVERT_EXPR_P (use_rhs)
-                 && TREE_CODE (TREE_OPERAND (use_rhs, 0)) == SSA_NAME)))
+         && TREE_CODE (use_rhs) == SSA_NAME
+         && has_zero_uses (gimple_assign_lhs (use_stmt)))
        {
          gimple_stmt_iterator gsi = gsi_for_stmt (use_stmt);
          release_defs (use_stmt);