re PR middle-end/42749 (-O2 and verify_stmts failed again)
authorRichard Guenther <rguenther@suse.de>
Mon, 22 Feb 2010 14:09:26 +0000 (14:09 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 22 Feb 2010 14:09:26 +0000 (14:09 +0000)
2010-02-22  Richard Guenther  <rguenther@suse.de>

PR tree-optimization/42749
* tree-tailcall.c (adjust_return_value_with_ops): Drop update
parameter.  Do arithmetic in the original type.
(update_accumulator_with_ops): Likewise.
(adjust_accumulator_values): Adjust.

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

From-SVN: r156960

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr42749.c [new file with mode: 0644]
gcc/tree-tailcall.c

index d77f4b0852a2547db209e1e5055694cc30a9644f..01abadcf8e63c95b676c08abecc555a364ecf7e8 100644 (file)
@@ -1,3 +1,11 @@
+2010-02-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/42749
+       * tree-tailcall.c (adjust_return_value_with_ops): Drop update
+       parameter.  Do arithmetic in the original type.
+       (update_accumulator_with_ops): Likewise.
+       (adjust_accumulator_values): Adjust.
+
 2010-02-22  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
 
        * config/s390/s390.md ("movqi"): Re-add the mem->mem alternative.
index 466b065bd8181a4b32db06a37737fcb891e3fe25..3f89fd36f7f74035aa47194d9e187eb3c7c99e7e 100644 (file)
@@ -1,3 +1,8 @@
+2010-02-22  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/42749
+       * gcc.c-torture/compile/pr42749.c: New testcase.
+
 2010-02-22  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/43072
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr42749.c b/gcc/testsuite/gcc.c-torture/compile/pr42749.c
new file mode 100644 (file)
index 0000000..508c087
--- /dev/null
@@ -0,0 +1,5 @@
+struct pdf_object { int val; };
+int pdf_count_size_object (struct pdf_object * p_obj)
+{
+    return pdf_count_size_object(p_obj) + 2 * sizeof(struct pdf_object);
+}
index de2a45e949c955a02eb304c036ac55a8f6978ed7..bf8ebb85f7140e68fb39535c0f503b877bf2ad15 100644 (file)
@@ -570,23 +570,37 @@ add_successor_phi_arg (edge e, tree var, tree phi_arg)
 
 static tree
 adjust_return_value_with_ops (enum tree_code code, const char *label,
-                             tree op0, tree op1, gimple_stmt_iterator gsi,
-                             enum gsi_iterator_update update)
+                             tree acc, tree op1, gimple_stmt_iterator gsi)
 {
 
   tree ret_type = TREE_TYPE (DECL_RESULT (current_function_decl));
   tree tmp = create_tmp_var (ret_type, label);
-  gimple stmt = gimple_build_assign_with_ops (code, tmp, op0, op1);
+  gimple stmt;
   tree result;
 
   if (TREE_CODE (ret_type) == COMPLEX_TYPE
       || TREE_CODE (ret_type) == VECTOR_TYPE)
     DECL_GIMPLE_REG_P (tmp) = 1;
   add_referenced_var (tmp);
+
+  if (types_compatible_p (TREE_TYPE (acc), TREE_TYPE (op1)))
+    stmt = gimple_build_assign_with_ops (code, tmp, acc, op1);
+  else
+    {
+      tree rhs = fold_convert (TREE_TYPE (acc),
+                              fold_build2 (code,
+                                           TREE_TYPE (op1),
+                                           fold_convert (TREE_TYPE (op1), acc),
+                                           op1));
+      rhs = force_gimple_operand_gsi (&gsi, rhs,
+                                     false, NULL, true, GSI_CONTINUE_LINKING);
+      stmt = gimple_build_assign (NULL_TREE, rhs);
+    }
+
   result = make_ssa_name (tmp, stmt);
   gimple_assign_set_lhs (stmt, result);
   update_stmt (stmt);
-  gsi_insert_before (&gsi, stmt, update);
+  gsi_insert_before (&gsi, stmt, GSI_NEW_STMT);
   return result;
 }
 
@@ -599,9 +613,22 @@ static tree
 update_accumulator_with_ops (enum tree_code code, tree acc, tree op1,
                             gimple_stmt_iterator gsi)
 {
-  gimple stmt = gimple_build_assign_with_ops (code, SSA_NAME_VAR (acc), acc,
-                                             op1);
-  tree var = make_ssa_name (SSA_NAME_VAR (acc), stmt);
+  gimple stmt;
+  tree var;
+  if (types_compatible_p (TREE_TYPE (acc), TREE_TYPE (op1)))
+    stmt = gimple_build_assign_with_ops (code, SSA_NAME_VAR (acc), acc, op1);
+  else
+    {
+      tree rhs = fold_convert (TREE_TYPE (acc),
+                              fold_build2 (code,
+                                           TREE_TYPE (op1),
+                                           fold_convert (TREE_TYPE (op1), acc),
+                                           op1));
+      rhs = force_gimple_operand_gsi (&gsi, rhs,
+                                     false, NULL, false, GSI_CONTINUE_LINKING);
+      stmt = gimple_build_assign (NULL_TREE, rhs);
+    }
+  var = make_ssa_name (SSA_NAME_VAR (acc), stmt);
   gimple_assign_set_lhs (stmt, var);
   update_stmt (stmt);
   gsi_insert_after (&gsi, stmt, GSI_NEW_STMT);
@@ -631,7 +658,7 @@ adjust_accumulator_values (gimple_stmt_iterator gsi, tree m, tree a, edge back)
            var = m_acc;
          else
            var = adjust_return_value_with_ops (MULT_EXPR, "acc_tmp", m_acc,
-                                               a, gsi, GSI_NEW_STMT);
+                                               a, gsi);
        }
       else
        var = a;
@@ -667,10 +694,10 @@ adjust_return_value (basic_block bb, tree m, tree a)
 
   if (m)
     retval = adjust_return_value_with_ops (MULT_EXPR, "mul_tmp", m_acc, retval,
-                                          gsi, GSI_SAME_STMT);
+                                          gsi);
   if (a)
     retval = adjust_return_value_with_ops (PLUS_EXPR, "acc_tmp", a_acc, retval,
-                                          gsi, GSI_SAME_STMT);
+                                          gsi);
   gimple_return_set_retval (ret_stmt, retval);
   update_stmt (ret_stmt);
 }