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: Support for full redundancy elimination and VN of virtualoperands in GVN-PRE


On Tue, 2004-06-29 at 23:26, Daniel Berlin wrote:

> You might also want to short circuit phi_translate at the top and just 
> return expr if is_gimple_min_invariant is true. There will never be a 
> phi for them, and it'll just create needless expressions.
>
OK, but I'm committing this fix first:

Bootstrapped and tested x86, x86-64 and ia64.


Diego.

	* tree-ssa-pre.c (phi_trans_add): Use is_gimple_min_invariant
	to check for constants.
	(set_remove): Likewise.
	(value_replace_in_set): Likewise.
	(find_leader): Likewise.
	* tree-vn.c (set_value_handle): Likewise.
	(vn_lookup): Likewise.
	(vn_lookup_or_add): Likewise.

Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-pre.c,v
retrieving revision 2.19
diff -d -c -p -d -u -p -r2.19 tree-ssa-pre.c
--- tree-ssa-pre.c	29 Jun 2004 01:53:03 -0000	2.19
+++ tree-ssa-pre.c	30 Jun 2004 02:59:32 -0000
@@ -393,20 +393,9 @@ phi_trans_add (tree e, tree v, basic_blo
 void
 add_to_value (tree v, tree e)
 {
-  /* For values representing non-CST nodes, but still function
-     invariant things we mark TREE_CONSTANT as true and set the tree
-     chain to the actual constant.  This is because unlike values
-     involving expressions, which are only available to use where the
-     expressions are live, a function invariant can be remade
-     anywhere, and thus, is available everywhere, just like a constant.  */
-  if (TREE_CODE_CLASS (TREE_CODE (v)) == 'c')
+  /* Constants have no expression sets.  */
+  if (is_gimple_min_invariant (v))
     return;
-  else if (is_gimple_min_invariant (v))
-    {
-      TREE_CONSTANT (v) = true;
-      TREE_CHAIN (v) = e;
-      return;
-    }
 
   if (VALUE_HANDLE_EXPR_SET (v) == NULL)
     VALUE_HANDLE_EXPR_SET (v) = set_new (false);
@@ -565,14 +554,8 @@ set_remove (value_set_t set, tree expr)
 static bool
 set_contains_value (value_set_t set, tree val)
 {
-  /* All true constants are in every set.  */
-  if (TREE_CODE_CLASS (TREE_CODE (val)) == 'c')
-    return true;
-  /* This is only referring to the flag above that we set on
-     values referring to invariants, because we know that we
-     are dealing with one of the value handles we created.  */
-
-  if (TREE_CONSTANT (val))
+  /* All constants are in every set.  */
+  if (is_gimple_min_invariant (val))
     return true;
   
   if (set->length == 0)
@@ -679,7 +662,7 @@ value_insert_into_set (value_set_t set, 
 
   /* Constant and invariant values exist everywhere, and thus,
      actually keeping them in the sets is pointless.  */
-  if (TREE_CONSTANT (val))
+  if (is_gimple_min_invariant (val))
     return;
 
   if (!set_contains_value (set, val))
@@ -880,15 +863,10 @@ find_leader (value_set_t set, tree val)
   if (val == NULL)
     return NULL;
 
-  /* True constants represent themselves.  */
-  if (TREE_CODE_CLASS (TREE_CODE (val)) == 'c')
+  /* Constants represent themselves.  */
+  if (is_gimple_min_invariant (val))
     return val;
 
-  /* Invariants are still represented by values, since they may be
-     more than a single _CST node.  */  
-  if (TREE_CONSTANT (val))
-    return TREE_CHAIN (val);
-
   if (set->length == 0)
     return NULL;
   
Index: tree-vn.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vn.c,v
retrieving revision 2.2
diff -d -c -p -d -u -p -r2.2 tree-vn.c
--- tree-vn.c	29 Jun 2004 01:53:03 -0000	2.2
+++ tree-vn.c	30 Jun 2004 02:59:32 -0000
@@ -168,7 +168,7 @@ set_value_handle (tree e, tree v)
     SSA_NAME_VALUE (e) = v;
   else if (EXPR_P (e) || DECL_P (e))
     get_tree_ann (e)->common.value_handle = v;
-  else if (TREE_CODE_CLASS (TREE_CODE (e)) == 'c')
+  else if (is_gimple_min_invariant (e))
     /* Do nothing.  Constants are their own value handles.  */
     ;
   else
@@ -214,8 +214,10 @@ vn_lookup (tree expr, vuse_optype vuses)
   void **slot;
   struct val_expr_pair_d vep = {NULL, NULL, NULL, 0};
 
-  if (TREE_CODE_CLASS (TREE_CODE (expr)) == 'c')
+  /* Constants are their own value.  */
+  if (is_gimple_min_invariant (expr))
     return expr;
+
   vep.e = expr;
   vep.vuses = vuses;
   vep.hashcode = vn_compute (expr, 0, vuses); 
@@ -261,20 +263,20 @@ vn_lookup_or_add (tree expr, vuse_optype
 
 /* Get the value handle of EXPR.  This is the only correct way to get
    the value handle for a "thing".  If EXPR does not have a value
-   handle associated, it generates and returns a new one.  */
+   handle associated, it returns NULL_TREE.  */
 
 tree
 get_value_handle (tree expr)
 {
   if (TREE_CODE (expr) == SSA_NAME)
     return SSA_NAME_VALUE (expr);
-  else if (TREE_CODE_CLASS (TREE_CODE (expr)) == 'c')
-    return expr;
   else if (EXPR_P (expr) || DECL_P (expr))
     {
       tree_ann_t ann = tree_ann (expr);
       return ((ann) ? ann->common.value_handle : NULL_TREE);
     }
+  else if (is_gimple_min_invariant (expr))
+    return expr;
 
   abort ();
 }



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