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]

[PATCH] Remove some useless reference lookups from SCCVN


This removes the reference lookup from try_to_simplify, which is of
no value as we do not further simplify the result (which is also
available from the value-number of the lhs).  This cuts reference
lookups down to 2/3.

It also changes get_sccvn_value in PRE to do a simple lookup of
the value of an SSA_NAME instead of going through a reference
lookup with the stmts VOPs but the lhs of a load (which obviously
doesn't find any match, but then inserts into the expression
tables.  Ugh).  This cuts reference lookups down to somewhere
between 1/3 and 2/3.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to
mainline.

Richard.

2008-02-29  Richard Guenther  <rguenther@suse.de>

	* tree-ssa-pre.c (get_sccvn_value): Create missing VNs via
	vn_lookup_or_add.
	* tree-ssa-sccnv.c (visit_reference_op_store): Use the rhs
	value for comparing for a store match.
	(simplify_unary_expression): Do nothing for SSA_NAMEs.
	(try_to_simplify): Do not do a full-blown reference lookup.

Index: trunk/gcc/tree-ssa-pre.c
===================================================================
*** trunk.orig/gcc/tree-ssa-pre.c	2008-02-29 13:07:38.000000000 +0100
--- trunk/gcc/tree-ssa-pre.c	2008-02-29 13:09:32.000000000 +0100
*************** get_sccvn_value (tree name)
*** 3256,3262 ****
  		!ZERO_SSA_OPERANDS (defstmt2, SSA_OP_ALL_VIRTUALS))
  	      gcc_assert (defstmt);
  	  }
! 	  valvh = vn_lookup_or_add_with_stmt (val, defstmt);
  	}
  
        if (dump_file && (dump_flags & TDF_DETAILS))
--- 3256,3264 ----
  		!ZERO_SSA_OPERANDS (defstmt2, SSA_OP_ALL_VIRTUALS))
  	      gcc_assert (defstmt);
  	  }
! 	  /* We lookup with the LHS, so do not use vn_lookup_or_add_with_stmt
! 	     here, as that will result in useless reference lookups.  */
! 	  valvh = vn_lookup_or_add (val);
  	}
  
        if (dump_file && (dump_flags & TDF_DETAILS))
Index: trunk/gcc/tree-ssa-sccvn.c
===================================================================
*** trunk.orig/gcc/tree-ssa-sccvn.c	2008-02-29 13:07:38.000000000 +0100
--- trunk/gcc/tree-ssa-sccvn.c	2008-02-29 13:30:59.000000000 +0100
*************** visit_reference_op_store (tree lhs, tree
*** 1231,1236 ****
--- 1231,1238 ----
      {
        if (TREE_CODE (result) == SSA_NAME)
  	result = SSA_VAL (result);
+       if (TREE_CODE (op) == SSA_NAME)
+ 	op = SSA_VAL (op);
        resultsame = expressions_equal_p (result, op);
      }
  
*************** simplify_unary_expression (tree rhs)
*** 1527,1539 ****
  static tree
  try_to_simplify (tree stmt, tree rhs)
  {
    if (TREE_CODE (rhs) == SSA_NAME)
!     {
!       if (is_gimple_min_invariant (SSA_VAL (rhs)))
! 	return SSA_VAL (rhs);
!       else if (VN_INFO (rhs)->has_constants)
! 	return VN_INFO (rhs)->expr;
!     }
    else
      {
        switch (TREE_CODE_CLASS (TREE_CODE (rhs)))
--- 1529,1538 ----
  static tree
  try_to_simplify (tree stmt, tree rhs)
  {
+   /* For stores we can end up simplifying a SSA_NAME rhs.  Just return
+      in this case, there is no point in doing extra work.  */
    if (TREE_CODE (rhs) == SSA_NAME)
!     return rhs;
    else
      {
        switch (TREE_CODE_CLASS (TREE_CODE (rhs)))
*************** try_to_simplify (tree stmt, tree rhs)
*** 1550,1562 ****
  
  	    /* Fallthrough. */
  	case tcc_reference:
! 	  {
! 	    tree result = vn_reference_lookup (rhs,
! 					       shared_vuses_from_stmt (stmt));
! 	    if (result)
! 	      return result;
! 	  }
! 	  /* Fallthrough for some codes.  */
  	  if (!(TREE_CODE (rhs) == REALPART_EXPR
  	        || TREE_CODE (rhs) == IMAGPART_EXPR))
  	    break;
--- 1549,1559 ----
  
  	    /* Fallthrough. */
  	case tcc_reference:
! 	  /* Do not do full-blown reference lookup here.
! 	     ???  But like for tcc_declaration, we should simplify
! 		  from constant initializers.  */
! 
! 	  /* Fallthrough for some codes that can operate on registers.  */
  	  if (!(TREE_CODE (rhs) == REALPART_EXPR
  	        || TREE_CODE (rhs) == IMAGPART_EXPR))
  	    break;


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