public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: gcc-patches@gcc.gnu.org
Cc: Andi Kleen <ak@linux.intel.com>
Subject: [PATCH 5/6] Convert tree-ssa-sccvn to inchash
Date: Sun, 27 Jul 2014 19:45:00 -0000	[thread overview]
Message-ID: <1406489825-9561-6-git-send-email-andi@firstfloor.org> (raw)
In-Reply-To: <1406489825-9561-5-git-send-email-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

gcc/:

2014-07-25  Andi Kleen  <ak@linux.intel.com>

	* tree-ssa-sccvn.c (vn_reference_op_compute_hash):
	(vn_reference_compute_hash):
	(vn_nary_op_compute_hash):
	(vn_phi_compute_hash):
	* tree-ssa-sccvn.h (vn_hash_constant_with_type):
---
 gcc/tree-ssa-sccvn.c | 44 ++++++++++++++++++++++----------------------
 gcc/tree-ssa-sccvn.h |  6 ++++--
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 93314fc..160ca00 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -594,17 +594,16 @@ value_id_constant_p (unsigned int v)
 
 /* Compute the hash for a reference operand VRO1.  */
 
-static hashval_t
-vn_reference_op_compute_hash (const vn_reference_op_t vro1, hashval_t result)
+static void
+vn_reference_op_compute_hash (const vn_reference_op_t vro1, inchash &hstate)
 {
-  result = iterative_hash_hashval_t (vro1->opcode, result);
+  hstate.add_int (vro1->opcode);
   if (vro1->op0)
-    result = iterative_hash_expr (vro1->op0, result);
+    iterative_hstate_expr (vro1->op0, hstate);
   if (vro1->op1)
-    result = iterative_hash_expr (vro1->op1, result);
+    iterative_hstate_expr (vro1->op1, hstate);
   if (vro1->op2)
-    result = iterative_hash_expr (vro1->op2, result);
-  return result;
+    iterative_hstate_expr (vro1->op2, hstate);
 }
 
 /* Compute a hash for the reference operation VR1 and return it.  */
@@ -612,7 +611,8 @@ vn_reference_op_compute_hash (const vn_reference_op_t vro1, hashval_t result)
 hashval_t
 vn_reference_compute_hash (const vn_reference_t vr1)
 {
-  hashval_t result = 0;
+  inchash hstate;
+  hashval_t result;
   int i;
   vn_reference_op_t vro;
   HOST_WIDE_INT off = -1;
@@ -634,7 +634,7 @@ vn_reference_compute_hash (const vn_reference_t vr1)
 	{
 	  if (off != -1
 	      && off != 0)
-	    result = iterative_hash_hashval_t (off, result);
+	    hstate.add_int (off);
 	  off = -1;
 	  if (deref
 	      && vro->opcode == ADDR_EXPR)
@@ -642,14 +642,16 @@ vn_reference_compute_hash (const vn_reference_t vr1)
 	      if (vro->op0)
 		{
 		  tree op = TREE_OPERAND (vro->op0, 0);
-		  result = iterative_hash_hashval_t (TREE_CODE (op), result);
-		  result = iterative_hash_expr (op, result);
+		  hstate.add_int (TREE_CODE (op));
+		  iterative_hstate_expr (op, hstate);
 		}
 	    }
 	  else
-	    result = vn_reference_op_compute_hash (vro, result);
+	    vn_reference_op_compute_hash (vro, hstate);
 	}
     }
+  result = hstate.end ();
+  /* ??? We would ICE later if we hash instead of adding that in. */
   if (vr1->vuse)
     result += SSA_NAME_VERSION (vr1->vuse);
 
@@ -2236,7 +2238,7 @@ vn_reference_insert_pieces (tree vuse, alias_set_type set, tree type,
 hashval_t
 vn_nary_op_compute_hash (const vn_nary_op_t vno1)
 {
-  hashval_t hash;
+  inchash hstate;
   unsigned i;
 
   for (i = 0; i < vno1->length; ++i)
@@ -2252,11 +2254,11 @@ vn_nary_op_compute_hash (const vn_nary_op_t vno1)
       vno1->op[1] = temp;
     }
 
-  hash = iterative_hash_hashval_t (vno1->opcode, 0);
+  hstate.add_int (vno1->opcode);
   for (i = 0; i < vno1->length; ++i)
-    hash = iterative_hash_expr (vno1->op[i], hash);
+    iterative_hstate_expr (vno1->op[i], hstate);
 
-  return hash;
+  return hstate.end ();
 }
 
 /* Compare nary operations VNO1 and VNO2 and return true if they are
@@ -2536,26 +2538,24 @@ vn_nary_op_insert_stmt (gimple stmt, tree result)
 static inline hashval_t
 vn_phi_compute_hash (vn_phi_t vp1)
 {
-  hashval_t result;
+  inchash hstate (vp1->block->index);
   int i;
   tree phi1op;
   tree type;
 
-  result = vp1->block->index;
-
   /* If all PHI arguments are constants we need to distinguish
      the PHI node via its type.  */
   type = vp1->type;
-  result += vn_hash_type (type);
+  hstate.merge_hash (vn_hash_type (type));
 
   FOR_EACH_VEC_ELT (vp1->phiargs, i, phi1op)
     {
       if (phi1op == VN_TOP)
 	continue;
-      result = iterative_hash_expr (phi1op, result);
+      iterative_hstate_expr (phi1op, hstate);
     }
 
-  return result;
+  return hstate.end ();
 }
 
 /* Compare two phi entries for equality, ignoring VN_TOP arguments.  */
diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h
index f52783a..f420656 100644
--- a/gcc/tree-ssa-sccvn.h
+++ b/gcc/tree-ssa-sccvn.h
@@ -140,8 +140,10 @@ vn_hash_type (tree type)
 static inline hashval_t
 vn_hash_constant_with_type (tree constant)
 {
-  return (iterative_hash_expr (constant, 0)
-	  + vn_hash_type (TREE_TYPE (constant)));
+  inchash hstate;
+  iterative_hstate_expr (constant, hstate);
+  hstate.merge_hash (vn_hash_type (TREE_TYPE (constant)));
+  return hstate.end ();
 }
 
 /* Compare the constants C1 and C2 with distinguishing type incompatible
-- 
2.0.1

  reply	other threads:[~2014-07-27 19:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-27 19:37 Convert more incremental hash users " Andi Kleen
2014-07-27 19:38 ` [PATCH 1/6] RTL & dwarf2out changes Andi Kleen
2014-07-27 19:38   ` [PATCH 2/6] Convert asan.c to inchash Andi Kleen
2014-07-27 19:38     ` [PATCH 3/6] Convert ipa-devirt " Andi Kleen
2014-07-27 19:38       ` [PATCH 4/6] Convert tree-ssa-dom " Andi Kleen
2014-07-27 19:45         ` Andi Kleen [this message]
2014-07-27 19:38           ` [PATCH 6/6] Convert tree-ssa-tail-merge " Andi Kleen
2014-07-28  8:23     ` [PATCH 2/6] Convert asan.c " Richard Biener
2014-07-28 19:00   ` [PATCH 1/6] RTL & dwarf2out changes Cary Coutant
2014-07-28 19:42     ` Andi Kleen
2014-07-28 21:30       ` Cary Coutant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406489825-9561-6-git-send-email-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).