Commit 2bc10537 by Andi Kleen Committed by Andi Kleen

Convert tree-ssa-dom to inchash

gcc/:

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

	* tree-ssa-dom.c (iterative_hash_exprs_commutative):
	Rename to inchash:add_expr_commutative. Convert to inchash.
	(iterative_hash_hashable_expr): Rename to
	inchash:add_hashable_expr. Convert to inchash.
	(avail_expr_hash): Dito.

From-SVN: r213398
parent d313d45f
2014-07-31 Andi Kleen <ak@linux.intel.com> 2014-07-31 Andi Kleen <ak@linux.intel.com>
* tree-ssa-dom.c (iterative_hash_exprs_commutative):
Rename to inchash:add_expr_commutative. Convert to inchash.
(iterative_hash_hashable_expr): Rename to
inchash:add_hashable_expr. Convert to inchash.
(avail_expr_hash): Dito.
2014-07-31 Andi Kleen <ak@linux.intel.com>
* ipa-devirt.c (polymorphic_call_target_hasher::hash): * ipa-devirt.c (polymorphic_call_target_hasher::hash):
Convert to inchash. Convert to inchash.
......
...@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see ...@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see
#include "params.h" #include "params.h"
#include "tree-ssa-threadedge.h" #include "tree-ssa-threadedge.h"
#include "tree-ssa-dom.h" #include "tree-ssa-dom.h"
#include "inchash.h"
/* This file implements optimizations on the dominator tree. */ /* This file implements optimizations on the dominator tree. */
...@@ -557,45 +558,42 @@ hashable_expr_equal_p (const struct hashable_expr *expr0, ...@@ -557,45 +558,42 @@ hashable_expr_equal_p (const struct hashable_expr *expr0,
} }
/* Generate a hash value for a pair of expressions. This can be used /* Generate a hash value for a pair of expressions. This can be used
iteratively by passing a previous result as the VAL argument. iteratively by passing a previous result in HSTATE.
The same hash value is always returned for a given pair of expressions, The same hash value is always returned for a given pair of expressions,
regardless of the order in which they are presented. This is useful in regardless of the order in which they are presented. This is useful in
hashing the operands of commutative functions. */ hashing the operands of commutative functions. */
static hashval_t namespace inchash
iterative_hash_exprs_commutative (const_tree t1,
const_tree t2, hashval_t val)
{ {
hashval_t one = iterative_hash_expr (t1, 0);
hashval_t two = iterative_hash_expr (t2, 0);
hashval_t t;
if (one > two) static void
t = one, one = two, two = t; add_expr_commutative (const_tree t1, const_tree t2, hash &hstate)
val = iterative_hash_hashval_t (one, val); {
val = iterative_hash_hashval_t (two, val); hash one, two;
return val; inchash::add_expr (t1, one);
inchash::add_expr (t2, two);
hstate.add_commutative (one, two);
} }
/* Compute a hash value for a hashable_expr value EXPR and a /* Compute a hash value for a hashable_expr value EXPR and a
previously accumulated hash value VAL. If two hashable_expr previously accumulated hash value VAL. If two hashable_expr
values compare equal with hashable_expr_equal_p, they must values compare equal with hashable_expr_equal_p, they must
hash to the same value, given an identical value of VAL. hash to the same value, given an identical value of VAL.
The logic is intended to follow iterative_hash_expr in tree.c. */ The logic is intended to follow inchash::add_expr in tree.c. */
static hashval_t static void
iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) add_hashable_expr (const struct hashable_expr *expr, hash &hstate)
{ {
switch (expr->kind) switch (expr->kind)
{ {
case EXPR_SINGLE: case EXPR_SINGLE:
val = iterative_hash_expr (expr->ops.single.rhs, val); inchash::add_expr (expr->ops.single.rhs, hstate);
break; break;
case EXPR_UNARY: case EXPR_UNARY:
val = iterative_hash_object (expr->ops.unary.op, val); hstate.add_object (expr->ops.unary.op);
/* Make sure to include signedness in the hash computation. /* Make sure to include signedness in the hash computation.
Don't hash the type, that can lead to having nodes which Don't hash the type, that can lead to having nodes which
...@@ -603,34 +601,34 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) ...@@ -603,34 +601,34 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val)
have different hash codes. */ have different hash codes. */
if (CONVERT_EXPR_CODE_P (expr->ops.unary.op) if (CONVERT_EXPR_CODE_P (expr->ops.unary.op)
|| expr->ops.unary.op == NON_LVALUE_EXPR) || expr->ops.unary.op == NON_LVALUE_EXPR)
val += TYPE_UNSIGNED (expr->type); hstate.add_int (TYPE_UNSIGNED (expr->type));
val = iterative_hash_expr (expr->ops.unary.opnd, val); inchash::add_expr (expr->ops.unary.opnd, hstate);
break; break;
case EXPR_BINARY: case EXPR_BINARY:
val = iterative_hash_object (expr->ops.binary.op, val); hstate.add_object (expr->ops.binary.op);
if (commutative_tree_code (expr->ops.binary.op)) if (commutative_tree_code (expr->ops.binary.op))
val = iterative_hash_exprs_commutative (expr->ops.binary.opnd0, inchash::add_expr_commutative (expr->ops.binary.opnd0,
expr->ops.binary.opnd1, val); expr->ops.binary.opnd1, hstate);
else else
{ {
val = iterative_hash_expr (expr->ops.binary.opnd0, val); inchash::add_expr (expr->ops.binary.opnd0, hstate);
val = iterative_hash_expr (expr->ops.binary.opnd1, val); inchash::add_expr (expr->ops.binary.opnd1, hstate);
} }
break; break;
case EXPR_TERNARY: case EXPR_TERNARY:
val = iterative_hash_object (expr->ops.ternary.op, val); hstate.add_object (expr->ops.ternary.op);
if (commutative_ternary_tree_code (expr->ops.ternary.op)) if (commutative_ternary_tree_code (expr->ops.ternary.op))
val = iterative_hash_exprs_commutative (expr->ops.ternary.opnd0, inchash::add_expr_commutative (expr->ops.ternary.opnd0,
expr->ops.ternary.opnd1, val); expr->ops.ternary.opnd1, hstate);
else else
{ {
val = iterative_hash_expr (expr->ops.ternary.opnd0, val); inchash::add_expr (expr->ops.ternary.opnd0, hstate);
val = iterative_hash_expr (expr->ops.ternary.opnd1, val); inchash::add_expr (expr->ops.ternary.opnd1, hstate);
} }
val = iterative_hash_expr (expr->ops.ternary.opnd2, val); inchash::add_expr (expr->ops.ternary.opnd2, hstate);
break; break;
case EXPR_CALL: case EXPR_CALL:
...@@ -639,15 +637,14 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) ...@@ -639,15 +637,14 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val)
enum tree_code code = CALL_EXPR; enum tree_code code = CALL_EXPR;
gimple fn_from; gimple fn_from;
val = iterative_hash_object (code, val); hstate.add_object (code);
fn_from = expr->ops.call.fn_from; fn_from = expr->ops.call.fn_from;
if (gimple_call_internal_p (fn_from)) if (gimple_call_internal_p (fn_from))
val = iterative_hash_hashval_t hstate.merge_hash ((hashval_t) gimple_call_internal_fn (fn_from));
((hashval_t) gimple_call_internal_fn (fn_from), val);
else else
val = iterative_hash_expr (gimple_call_fn (fn_from), val); inchash::add_expr (gimple_call_fn (fn_from), hstate);
for (i = 0; i < expr->ops.call.nargs; i++) for (i = 0; i < expr->ops.call.nargs; i++)
val = iterative_hash_expr (expr->ops.call.args[i], val); inchash::add_expr (expr->ops.call.args[i], hstate);
} }
break; break;
...@@ -656,15 +653,15 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) ...@@ -656,15 +653,15 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val)
size_t i; size_t i;
for (i = 0; i < expr->ops.phi.nargs; i++) for (i = 0; i < expr->ops.phi.nargs; i++)
val = iterative_hash_expr (expr->ops.phi.args[i], val); inchash::add_expr (expr->ops.phi.args[i], hstate);
} }
break; break;
default: default:
gcc_unreachable (); gcc_unreachable ();
} }
}
return val;
} }
/* Print a diagnostic dump of an expression hash table entry. */ /* Print a diagnostic dump of an expression hash table entry. */
...@@ -2599,24 +2596,24 @@ avail_expr_hash (const void *p) ...@@ -2599,24 +2596,24 @@ avail_expr_hash (const void *p)
gimple stmt = ((const struct expr_hash_elt *)p)->stmt; gimple stmt = ((const struct expr_hash_elt *)p)->stmt;
const struct hashable_expr *expr = &((const struct expr_hash_elt *)p)->expr; const struct hashable_expr *expr = &((const struct expr_hash_elt *)p)->expr;
tree vuse; tree vuse;
hashval_t val = 0; inchash::hash hstate;
val = iterative_hash_hashable_expr (expr, val); inchash::add_hashable_expr (expr, hstate);
/* If the hash table entry is not associated with a statement, then we /* If the hash table entry is not associated with a statement, then we
can just hash the expression and not worry about virtual operands can just hash the expression and not worry about virtual operands
and such. */ and such. */
if (!stmt) if (!stmt)
return val; return hstate.end ();
/* Add the SSA version numbers of the vuse operand. This is important /* Add the SSA version numbers of the vuse operand. This is important
because compound variables like arrays are not renamed in the because compound variables like arrays are not renamed in the
operands. Rather, the rename is done on the virtual variable operands. Rather, the rename is done on the virtual variable
representing all the elements of the array. */ representing all the elements of the array. */
if ((vuse = gimple_vuse (stmt))) if ((vuse = gimple_vuse (stmt)))
val = iterative_hash_expr (vuse, val); inchash::add_expr (vuse, hstate);
return val; return hstate.end ();
} }
/* PHI-ONLY copy and constant propagation. This pass is meant to clean /* PHI-ONLY copy and constant propagation. This pass is meant to clean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment