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]

[pretty-ipa, PATCH 1/3] Make new intra-SRA and IPA-SRA work after a-i merge


Note that IPA-SRA is still disabled for benchmarking purposes.  But
this patch makes it bootstrap and test ok if uncommented.


2009-04-06  Martin Jambor  <mjambor@suse.cz>

	* tree-ssa-alias.c (refs_may_alias_p_1): Check for
	is_gimple_min_invariant rather than CONSTANT_CLASS_P so that invariant
	ADDR_EXPRS are include too.

	* ipa-sra.c (update_all_vops): Removed.
	(scan_function): Set delete when a statement is deleted and not when it
	is not.
	(convert_call): Update SSA and free dominance info.
	(ipa_early_sra): Exclude virtual methods.
	(sort_and_splice_var_accesses): Remove writing to dump_file.
	(build_access_tree_result): Removed.
	(build_access_tree_1): Return bool, find about children coverage from
	their flags.
	(build_access_tree): Check whether build_access_tree_1 returnedf true.
	(generate_subtree_copies): Do not call update_all_vops.
	(load_assign_lhs_subreplacements): Likewise.
	(sra_intra_modify_constructor_assign): Call unlink_stmt_vdef.
	(sra_intra_modify_assign): Do not call push_stmt_changes and
	pop_stmt_changes, call unlink_stmt_vdef.



Index: isra/gcc/ipa-sra.c
===================================================================
--- isra.orig/gcc/ipa-sra.c
+++ isra/gcc/ipa-sra.c
@@ -460,22 +460,6 @@ get_var_base_offset_size_access (tree ba
   return find_access_in_subtree (access, offset, size);
 }
 
-/* Mark all virtual operands of a statement STMT for renaming.  */
-
-static void
-update_all_vops (gimple stmt)
-{
-  ssa_op_iter iter;
-  tree sym;
-
-  FOR_EACH_SSA_TREE_OPERAND (sym, stmt, iter, SSA_OP_ALL_VIRTUALS)
-    {
-      if (TREE_CODE (sym) == SSA_NAME)
-	sym = SSA_NAME_VAR (sym);
-      mark_sym_for_renaming (sym);
-    }
-}
-
 /* Mark all representatives (pointed to by REPRESENTATIVES and those accessible
    from them by next_grp linked list) as potentially modified unless it can be
    proved some of them may be not.  Hopefully the declaration DECL and TYPE
@@ -1499,11 +1483,12 @@ scan_function (bool (*scan_expr) (tree *
 		    remove_stmt_from_eh_region (stmt);
 		}
 	    }
-	  if (!deleted)
+	  if (deleted)
+	    bb_changed = true;
+	  else
 	    {
 	      gsi_next (&gsi);
 	      ret = true;
-	      bb_changed = true;
 	    }
 	}
       stmt_no = -1;
@@ -1511,7 +1496,6 @@ scan_function (bool (*scan_expr) (tree *
 	gimple_purge_dead_eh_edges (bb);
     }
 
-
   return ret;
 }
 
@@ -2600,6 +2584,9 @@ convert_call (struct cgraph_edge *cs, gi
   if (cs)
     cgraph_set_call_stmt (cs, new_stmt);
 
+  update_ssa (TODO_update_ssa);
+  free_dominance_info (CDI_DOMINATORS);
+
   return true;
 }
 
@@ -2711,6 +2698,13 @@ ipa_early_sra (void)
       return 0;
     }
 
+  if (DECL_VIRTUAL_P (current_function_decl))
+    {
+      if (dump_file)
+	fprintf (dump_file, "Function is a virtual method.\n");
+      return 0;
+    }
+
   if ((DECL_COMDAT (node->decl) || DECL_EXTERNAL (node->decl))
       && node->global.size >= MAX_INLINE_INSNS_AUTO)
     {
@@ -2876,14 +2870,7 @@ sort_and_splice_var_accesses (tree var)
 	  high = access->offset + access->size;
 	}
       else if (access->offset > low && access->offset + access->size > high)
-	{
-	  if (dump_file)
-	    {
-	      fprintf (dump_file, "Inhibitingly overlapping access: ");
-	      dump_access (access, false);
-	    }
-	  return NULL;
-	}
+	return NULL;
       else
 	gcc_assert (access->offset >= low
 		    && access->offset + access->size <= high);
@@ -2996,15 +2983,6 @@ get_access_replacement (struct access *a
   return access->replacement_decl;
 }
 
-enum build_access_tree_result
-  {
-    SRA_BAT_NONE,                 /* nothing scalarized */
-    SRA_BAT_SCALAR_COMPONENTS,	  /* there are scalarized subcomponents but the
-				     subtree is not fully covered with them  */
-    SRA_BAT_SCALAR_COVERADGE	  /* the whole subtree covered by scalar
-				     replacements  */
-  };
-
 /* Build a subtree of accesses rooted in *ACCESS, and move the pointer in the
    linked list along the way together with deciding whether a scalar
    replacements should be created for *ACCESS.  Stop when *ACCESS is NULL or
@@ -3013,7 +2991,7 @@ enum build_access_tree_result
    MARK_READ is true, mark all of them as grp_write if MARK_WRITE is true.
    Return true iff any replacements are to be created.  */
 
-static enum build_access_tree_result
+static bool
 build_access_tree_1 (struct access **access, bool allow_replacements,
 		     bool mark_read, bool mark_write)
 {
@@ -3039,7 +3017,7 @@ build_access_tree_1 (struct access **acc
   *access = (*access)->next_grp;
   while  (*access && (*access)->offset + (*access)->size <= limit)
     {
-      enum build_access_tree_result subres;
+      bool subres;
 
       if (!hole && (*access)->offset < covered_to)
 	hole = true;
@@ -3054,12 +3032,11 @@ build_access_tree_1 (struct access **acc
 
       subres = build_access_tree_1 (access, allow_replacements && !scalar,
 				    mark_read, mark_write);
-      if (subres != SRA_BAT_NONE)
+      if (subres)
 	sth_created = true;
-      if (subres != SRA_BAT_SCALAR_COVERADGE)
-	hole = true;
 
       root->grp_unscalarized_data |= last_child->grp_unscalarized_data;
+      hole |= !last_child->grp_covered;
     }
 
   if (allow_replacements && scalar && !root->first_child)
@@ -3083,13 +3060,13 @@ build_access_tree_1 (struct access **acc
   if (sth_created && !hole)
     {
       root->grp_covered = 1;
-      return SRA_BAT_SCALAR_COVERADGE;
+      return true;
     }
   if (root->grp_write || TREE_CODE (root->base) == PARM_DECL)
-    root->grp_unscalarized_data = 1; /* uncovered and written to */
+    root->grp_unscalarized_data = 1; /* not covered and written to */
   if (sth_created)
-    return SRA_BAT_SCALAR_COMPONENTS;
-  return SRA_BAT_NONE;
+    return true;
+  return false;
 }
 
 /* Build a tree of access representatives, ACCESS is the pointer to the first
@@ -3105,8 +3082,7 @@ build_access_tree (struct access *access
     {
       struct access *root = access;
 
-      ret |= (build_access_tree_1 (&access, true, false,
-				   false) != SRA_BAT_NONE);
+      ret |= (build_access_tree_1 (&access, true, false, false));
       root->next_grp = access;
     }
 
@@ -3259,8 +3235,6 @@ generate_subtree_copies (struct access *
 	    gsi_insert_after (gsi, stmt, GSI_NEW_STMT);
 	  else
 	    gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
-
-	  update_all_vops (stmt);
 	}
 
       if (access->first_child)
@@ -3539,7 +3513,6 @@ load_assign_lhs_subreplacements (struct
 
 	      stmt = gimple_build_assign (get_access_replacement (lacc), expr);
 	      gsi_insert_before (gsi, stmt, GSI_SAME_STMT);
-	      update_all_vops (stmt);
 	    }
 	}
       else if (lacc->grp_read && !lacc->grp_covered && !*refreshed)
@@ -3587,6 +3560,7 @@ sra_intra_modify_constructor_assign (gim
   if (!acc->grp_read || acc->grp_covered)
     {
       init_subtree_with_zero (acc, gsi, false);
+      unlink_stmt_vdef (*stmt);
       gsi_remove (gsi, true);
       return SRA_SA_REMOVED;
     }
@@ -3750,8 +3724,6 @@ sra_intra_modify_assign (gimple *stmt, g
 
   modify_this_stmt = ((lacc && lacc->to_be_replaced)
 		      || (racc && racc->to_be_replaced));
-  if (modify_this_stmt)
-    push_stmt_changes (stmt);
 
   if (lacc && lacc->to_be_replaced)
     {
@@ -3776,8 +3748,6 @@ sra_intra_modify_assign (gimple *stmt, g
      but hopefully make some sense.  */
   if (modify_this_stmt)
     {
-      pop_stmt_changes (stmt);
-
       if (!useless_type_conversion_p (ltype, rtype))
 	fix_modified_assign_compatibility (gsi, stmt, lacc, racc,
 					   lhs, &rhs, ltype, rtype);
@@ -3812,6 +3782,7 @@ sra_intra_modify_assign (gimple *stmt, g
 	  if (!refreshed || !racc->grp_unscalarized_data)
 	    {
 	      gcc_assert (*stmt == gsi_stmt (*gsi));
+	      unlink_stmt_vdef (*stmt);
 	      gsi_remove (gsi, true);
 	      return SRA_SA_REMOVED;
 	    }
@@ -3827,6 +3798,7 @@ sra_intra_modify_assign (gimple *stmt, g
 					   racc->offset, 0, 0, gsi,
 					   false, false);
 		  gcc_assert (*stmt == gsi_stmt (*gsi));
+		  unlink_stmt_vdef (*stmt);
 		  gsi_remove (gsi, true);
 		  return SRA_SA_REMOVED;
 		}
Index: isra/gcc/passes.c
===================================================================
--- isra.orig/gcc/passes.c
+++ isra/gcc/passes.c
@@ -555,7 +555,7 @@ init_optimization_passes (void)
 	  NEXT_PASS (pass_ccp);
 	  NEXT_PASS (pass_forwprop);
 	  NEXT_PASS (pass_update_address_taken);
-#if 1   /* !!!!!!!!!!!!! */
+#if 0   /* !!!!!!!!!!!!! */
 	  NEXT_PASS (pass_sra_early);
 #else
 	  NEXT_PASS (pass_early_new_sra);
@@ -629,7 +629,7 @@ init_optimization_passes (void)
       NEXT_PASS (pass_ch);
       NEXT_PASS (pass_stdarg);
       NEXT_PASS (pass_lower_complex);
-#if 1   /* !!!!!!!!!!!!! */
+#if 0   /* !!!!!!!!!!!!! */
       NEXT_PASS (pass_sra);
 #else
       NEXT_PASS (pass_new_sra);
Index: isra/gcc/tree-ssa-alias.c
===================================================================
--- isra.orig/gcc/tree-ssa-alias.c
+++ isra/gcc/tree-ssa-alias.c
@@ -688,9 +688,9 @@ refs_may_alias_p_1 (tree ref1, tree ref2
      *D.1663_44 = VIEW_CONVERT_EXPR<struct DB_LSN>(__tmp$B0F64_59);
      which is seen as a struct copy.  */
   if (TREE_CODE (base1) == SSA_NAME
-      || CONSTANT_CLASS_P (base1)
       || TREE_CODE (base2) == SSA_NAME
-      || CONSTANT_CLASS_P (base2))
+      || is_gimple_min_invariant (base1)
+      || is_gimple_min_invariant (base2))
     return false;
 
   var1_p = SSA_VAR_P (base1);


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