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][patch] Fixing a bug in tree-complex.c


Hi,

This patch fixes a bug in tree_lower_complex - after it was converted
to tuples, GIMPLE_CALLs that have a lhs(so used to be
GIMPLE_MODIFY_STATEMENTs in treeland) were not taken into account when
running the pass.
Also removes gimple_get_tmp_for, because of lack of users and sets a
gimple_register bit on new COMLEX temporaries, created to hold the
result of a call.
Tested, no regressions on i686-linux.

Oleg

2008-03-20  Oleg Ryjkov <olegr@google.com>

        * tree-complex.c (init_dont_simulate_again, complex_visit_stmt,
        update_complex_components, expand_complex_operations_1): Consider
        GIMPLE_CALLs with a lhs, not only GIMPLE_ASSIGNs.
        * gimplify.c (get_tmp_var_for): Removed.
        (gimplify_call_expr): Remove call to get_tmp_var_for, set
        gimple_register on a new lhs in some cases.
Index: tree-complex.c
===================================================================
--- tree-complex.c	(revision 133392)
+++ tree-complex.c	(working copy)
@@ -213,6 +213,11 @@ init_dont_simulate_again (void)
 
 	  switch (gimple_code (stmt))
 	    {
+	    case GIMPLE_CALL:
+	      if (gimple_call_lhs (stmt))
+	        sim_again_p = is_complex_reg (gimple_call_lhs (stmt));
+	      break;
+
 	    case GIMPLE_ASSIGN:
 	      sim_again_p = is_complex_reg (gimple_assign_lhs (stmt));
 	      op0 = gimple_assign_rhs1 (stmt);
@@ -286,11 +291,11 @@ complex_visit_stmt (gimple stmt, edge *t
   unsigned int ver;
   tree lhs;
 
-  if (gimple_code (stmt) != GIMPLE_ASSIGN)
+  lhs = gimple_get_lhs (stmt);
+  /* Skip anything but GIMPLE_ASSIGN and GIMPLE_CALL with a lhs.  */
+  if (!lhs)
     return SSA_PROP_VARYING;
 
-  lhs = gimple_assign_lhs (stmt);
-
   /* These conditions should be satisfied due to the initial filter
      set up in init_dont_simulate_again.  */
   gcc_assert (TREE_CODE (lhs) == SSA_NAME);
@@ -618,12 +623,7 @@ update_complex_components (gimple_stmt_i
   tree lhs;
   gimple_seq list;
 
-  if (gimple_code (stmt) == GIMPLE_ASSIGN)
-    lhs = gimple_assign_lhs (stmt);
-  else if (gimple_code (stmt) == GIMPLE_CALL)
-    lhs = gimple_call_lhs (stmt);
-  else
-    gcc_unreachable ();
+  lhs = gimple_get_lhs (stmt);
 
   list = set_component_ssa_name (lhs, false, r);
   if (list)
@@ -1395,13 +1395,13 @@ static void
 expand_complex_operations_1 (gimple_stmt_iterator *gsi)
 {
   gimple stmt = gsi_stmt (*gsi);
-  tree type, inner_type;
+  tree type, inner_type, lhs;
   tree ac, ar, ai, bc, br, bi;
   complex_lattice_t al, bl;
   enum tree_code code;
 
-  if (gimple_code (stmt) != GIMPLE_ASSIGN
-      && gimple_code (stmt) != GIMPLE_COND)
+  lhs = gimple_get_lhs (stmt);
+  if (!lhs && gimple_code (stmt) != GIMPLE_COND)
     return;
 
   type = TREE_TYPE (gimple_op (stmt, 0));
@@ -1436,20 +1436,19 @@ expand_complex_operations_1 (gimple_stmt
 
     default:
       {
-	tree lhs, rhs;
+	tree rhs;
 
 	/* GIMPLE_COND may also fallthru here, but we do not need to
 	   do anything with it.  */
-	if (gimple_code (stmt) != GIMPLE_ASSIGN)
+	if (gimple_code (stmt) == GIMPLE_COND)
 	  return;
 
-	lhs = gimple_assign_lhs (stmt);
-
 	if (TREE_CODE (type) == COMPLEX_TYPE)
 	  expand_complex_move (gsi, type);
+        /* Only GIMLE_ASSIGN will have gimple_subcode set.  */
 	else if ((gimple_subcode (stmt) == REALPART_EXPR
 		  || gimple_subcode (stmt) == IMAGPART_EXPR)
-		 && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME)
+		 && TREE_CODE (lhs) == SSA_NAME)
 	  {
 	    rhs = gimple_assign_rhs1 (stmt);
 	    rhs = extract_component (gsi, TREE_OPERAND (rhs, 0),
@@ -1469,6 +1468,7 @@ expand_complex_operations_1 (gimple_stmt
       ac = gimple_assign_rhs1 (stmt);
       bc = (gimple_num_ops (stmt) > 2) ? gimple_assign_rhs2 (stmt) : NULL;
     }
+  /* GIMPLE_CALL can not get here.  */
   else
     {
       ac = gimple_cond_lhs (stmt);
Index: gimplify.c
===================================================================
--- gimplify.c	(revision 133392)
+++ gimplify.c	(working copy)
@@ -686,28 +686,6 @@ get_initialized_tmp_var (tree val, gimpl
   return internal_get_tmp_var (val, pre_p, post_p, false);
 }
 
-/* Create a temporary variable to be used as the LHS of the given GIMPLE
-   statement STMT. STMT must be GIMPLE_ASSIGN or GIMPLE_CALL.  */
-
-static tree
-get_tmp_var_for (gimple stmt)
-{
-  tree lhs;
-  enum gimple_code code = gimple_code (stmt);
-
-  /* FIXME tuples, add support for formal temporaries (worth it?)  */
-  if (code == GIMPLE_ASSIGN)
-    lhs = create_tmp_from_val (gimple_op (stmt, 1));
-  else if (code == GIMPLE_CALL)
-    lhs = create_tmp_var (gimple_call_return_type (stmt),
-			   get_name (gimple_call_fn (stmt)));
-  else
-    gcc_unreachable ();
-
-  return lhs;
-}
-
-
 /* Declares all the variables in VARS in SCOPE.  If DEBUG_INFO is
    true, generate debug info for them; otherwise don't.  */
 
@@ -2385,8 +2363,15 @@ gimplify_call_expr (tree *expr_p, gimple
   gimplify_seq_add_stmt (pre_p, call);
   if (want_value)
     {
-      tree lhs = get_tmp_var_for (call);
+      /* FIXME tuples: we want to use internal_get_tmp_var.  */
+      tree lhs = create_tmp_var (gimple_call_return_type (call),
+                                 get_name (gimple_call_fn (call)));
       gimple_call_set_lhs (call, lhs);
+
+      if (TREE_CODE (gimple_call_return_type (call)) == COMPLEX_TYPE
+          || TREE_CODE (gimple_call_return_type (call)) == VECTOR_TYPE)
+        DECL_GIMPLE_REG_P (lhs) = 1;
+
       *expr_p = lhs;
     }
   else

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