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]

Re: [tree-ssa] More CFG improvements [patch]


On Tue, 04 Feb 2003, Jeff Law wrote:

> I thought this was going to allow us to enable 20001226-1.c, except that
> for some reason we're getting some spurious vuses on some statements,
> which in turn is causing certain variables to be nonlocal when they should
> local.  That in turn causes us to insert far too many PHI nodes and
> 20001226-1.c blows up.
> 
Fixed.


Diego.


	* tree-dfa.c (add_stmt_operand): Do not add a VUSE for a pointer
	when clobbering its associated INDIRECT_REF variable.

Index: tree-dfa.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-dfa.c,v
retrieving revision 1.1.4.71
diff -d -u -p -r1.1.4.71 tree-dfa.c
--- tree-dfa.c	4 Feb 2003 03:11:14 -0000	1.1.4.71
+++ tree-dfa.c	4 Feb 2003 18:07:52 -0000
@@ -516,6 +516,7 @@ add_stmt_operand (var_p, stmt, is_def, f
   bool is_scalar;
   tree var, deref;
   varray_type aliases;
+  size_t i;
 
   var = *var_p;
   STRIP_NOPS (var);
@@ -563,8 +564,6 @@ add_stmt_operand (var_p, stmt, is_def, f
   else
     {
       /* The variable is aliased.  Add its aliases to the virtual operands.  */
-      size_t i;
-
       if (is_def)
 	{
 	  for (i = 0; i < VARRAY_ACTIVE_SIZE (aliases); i++)
@@ -582,11 +581,17 @@ add_stmt_operand (var_p, stmt, is_def, f
      memory location.  */
   deref = indirect_ref (var);
   if (is_def
+      && deref != NULL_TREE
       && SSA_DECL_P (var)
-      && POINTER_TYPE_P (TREE_TYPE (var))
-      && deref != NULL_TREE)
+      && POINTER_TYPE_P (TREE_TYPE (var)))
     {
-      add_stmt_operand (&deref, stmt, true, true, prev_vops);
+      /* Add a VDEF for '*p' (or its aliases if it has any).  */
+      aliases = may_aliases (deref);
+      if (aliases == NULL)
+	add_vdef (deref, stmt, prev_vops);
+      else
+	for (i = 0; i < VARRAY_ACTIVE_SIZE (aliases); i++)
+	  add_vdef (VARRAY_TREE (aliases, i), stmt, prev_vops);
 
       /* If the relocation of 'p' is due to an expression that may
 	 point to global memory, then mark '*p' as an alias for
@@ -596,18 +601,20 @@ add_stmt_operand (var_p, stmt, is_def, f
 		  		    get_base_symbol (TREE_OPERAND (stmt, 1))))
 	set_may_alias_global_mem (deref);
     }
+  else
+    {
+      /* If VAR is a pointer dereference, we need to add a VUSE for its
+	 base pointer.  If needed, strip its SSA version, to access the
+	 base pointer.  Otherwise we won't recognize use of pointers after
+	 variables have been renamed. For instance, in (*p)_35, we need to
+	 add an operand for 'p', and for that we need to remove the SSA
+	 version number first.  */
+      if (TREE_CODE (var) == SSA_NAME)
+	var = SSA_NAME_VAR (var);
 
-
-  /* Pointer dereferences represent a VUSE of their base pointer.  If
-     needed, strip its SSA version, to access the base pointer.  Otherwise
-     we won't recognize use of pointers after variables have been renamed.
-     For instance, in (*p)_35, we need to add an operand for 'p', and for
-     that we need to remove the SSA version number first.  */
-  if (TREE_CODE (var) == SSA_NAME)
-    var = SSA_NAME_VAR (var);
-
-  if (TREE_CODE (var) == INDIRECT_REF)
-    add_stmt_operand (&TREE_OPERAND (var, 0), stmt, false, true, prev_vops);
+      if (TREE_CODE (var) == INDIRECT_REF)
+	add_stmt_operand (&TREE_OPERAND (var, 0), stmt, false, true, prev_vops);
+    }
 }
 
 


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