This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[tuples] Fix copyrename and forwprop


Hi!

GIMPLE_ASSIGN has 2 or 3 operands, never just 1.  While looking
at it I found a couple of other issues.  Fixes:
FAIL: gcc.dg/tree-ssa/asm-3.c scan-tree-dump-times optimized "bar [(]t[)]" 1
FAIL: gcc.dg/tree-ssa/loop-15.c scan-tree-dump-times optimized "n \\* n" 1
FAIL: g++.dg/tree-ssa/pr31146.C scan-tree-dump forwprop2 "i\\[j.*\\] = 1;"
Will commit after full bootstrap/regtest together with other fixes.

2008-07-16  Jakub Jelinek  <jakub@redhat.com>

	* tree-ssa-copyrename.c (rename_ssa_copies): Use
	gimple_assign_ssa_name_copy_p.

	* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Check
	gimple_assign_rhs_code, type of rhs is TREE_TYPE (lhs), update
	rhs_code.

--- gcc/tree-ssa-copyrename.c.jj	2008-06-13 14:30:50.000000000 +0200
+++ gcc/tree-ssa-copyrename.c	2008-07-16 10:44:07.000000000 +0200
@@ -321,13 +321,12 @@ rename_ssa_copies (void)
       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
 	{
 	  stmt = gsi_stmt (gsi);
-	  if (gimple_code (stmt) == GIMPLE_ASSIGN && gimple_num_ops (stmt) == 1)
+	  if (gimple_assign_ssa_name_copy_p (stmt))
 	    {
 	      tree lhs = gimple_assign_lhs (stmt);
 	      tree rhs = gimple_assign_rhs1 (stmt);
 
-              if (TREE_CODE (lhs) == SSA_NAME && TREE_CODE (rhs) == SSA_NAME)
-		updated |= copy_rename_partition_coalesce (map, lhs, rhs, debug);
+	      updated |= copy_rename_partition_coalesce (map, lhs, rhs, debug);
 	    }
 	}
     }
--- gcc/tree-ssa-forwprop.c.jj	2008-07-08 19:24:39.000000000 +0200
+++ gcc/tree-ssa-forwprop.c	2008-07-16 11:16:57.000000000 +0200
@@ -674,10 +674,12 @@ forward_propagate_addr_expr_1 (tree name
   tree lhs, rhs, rhs2, array_ref;
   tree *rhsp, *lhsp;
   gimple use_stmt = gsi_stmt (*use_stmt_gsi);
+  enum tree_code rhs_code;
 
   gcc_assert (TREE_CODE (def_rhs) == ADDR_EXPR);
 
   lhs = gimple_assign_lhs (use_stmt);
+  rhs_code = gimple_assign_rhs_code (use_stmt);
   rhs = gimple_assign_rhs1 (use_stmt);
 
   /* Trivial cases.  The use statement could be a trivial copy or a
@@ -686,15 +688,16 @@ forward_propagate_addr_expr_1 (tree name
      all useless conversions.  Treat the case of a single-use name and
      a conversion to def_rhs type separate, though.  */
   if (TREE_CODE (lhs) == SSA_NAME
-      && ((rhs == name && gimple_num_ops (use_stmt) == 1)
-	  || IS_CONVERT_EXPR_CODE_P (gimple_code (use_stmt)))
-      && useless_type_conversion_p (TREE_TYPE (rhs), TREE_TYPE (def_rhs)))
+      && ((rhs_code == SSA_NAME && rhs == name)
+	  || IS_CONVERT_EXPR_CODE_P (rhs_code))
+      && useless_type_conversion_p (TREE_TYPE (lhs), TREE_TYPE (def_rhs)))
     {
       /* Only recurse if we don't deal with a single use.  */
       if (!single_use_p)
 	return forward_propagate_addr_expr (lhs, def_rhs);
 
       gimple_assign_set_rhs1 (use_stmt, unshare_expr (def_rhs));
+      gimple_assign_set_rhs_code (use_stmt, TREE_CODE (def_rhs));
       return true;
     }
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]