From 9708c51db0388b5b7efb3b73a2bf0b50c09d45a1 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Mon, 4 Jan 2010 17:01:34 +0000 Subject: [PATCH] tree-ssa-sccvn.c (vn_reference_op_compute_hash): Use iterative_hash_* as intended. 2010-01-04 Richard Guenther * tree-ssa-sccvn.c (vn_reference_op_compute_hash): Use iterative_hash_* as intended. (vn_reference_compute_hash): Likewise. Simplify hashing SSA names. (vn_reference_lookup_2): Likewise. (vn_nary_op_compute_hash): Likewise. (vn_phi_compute_hash): Likewise. (expressions_equal_p): Remove strange code. * tree-ssa-pre.c (pre_expr_eq): Use gcc_unreachable (). (pre_expr_hash): Likewise. Simplify hashing SSA names. (bitmap_insert_into_set_1): Take value-id as parameter. (add_to_value): Pass it. (bitmap_insert_into_set): Likewise. (bitmap_value_insert_into_set): Likewise. Remove redundant check. From-SVN: r155624 --- gcc/ChangeLog | 17 +++++++++++++++ gcc/tree-ssa-pre.c | 21 ++++++++----------- gcc/tree-ssa-sccvn.c | 49 ++++++++++++++++---------------------------- 3 files changed, 44 insertions(+), 43 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 30e07cf1306..8617693f9ef 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,20 @@ +2010-01-04 Richard Guenther + + * tree-ssa-sccvn.c (vn_reference_op_compute_hash): Use + iterative_hash_* as intended. + (vn_reference_compute_hash): Likewise. Simplify hashing + SSA names. + (vn_reference_lookup_2): Likewise. + (vn_nary_op_compute_hash): Likewise. + (vn_phi_compute_hash): Likewise. + (expressions_equal_p): Remove strange code. + * tree-ssa-pre.c (pre_expr_eq): Use gcc_unreachable (). + (pre_expr_hash): Likewise. Simplify hashing SSA names. + (bitmap_insert_into_set_1): Take value-id as parameter. + (add_to_value): Pass it. + (bitmap_insert_into_set): Likewise. + (bitmap_value_insert_into_set): Likewise. Remove redundant check. + 2010-01-04 Jakub Jelinek PR driver/42442 diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 7d9b9bf32d0..3087fe38ae9 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -204,7 +204,7 @@ pre_expr_eq (const void *p1, const void *p2) return vn_reference_eq (PRE_EXPR_REFERENCE (e1), PRE_EXPR_REFERENCE (e2)); default: - abort(); + gcc_unreachable (); } } @@ -217,13 +217,13 @@ pre_expr_hash (const void *p1) case CONSTANT: return vn_hash_constant_with_type (PRE_EXPR_CONSTANT (e)); case NAME: - return iterative_hash_hashval_t (SSA_NAME_VERSION (PRE_EXPR_NAME (e)), 0); + return SSA_NAME_VERSION (PRE_EXPR_NAME (e)); case NARY: return PRE_EXPR_NARY (e)->hashcode; case REFERENCE: return PRE_EXPR_REFERENCE (e)->hashcode; default: - abort (); + gcc_unreachable (); } } @@ -436,7 +436,8 @@ static void bitmap_value_replace_in_set (bitmap_set_t, pre_expr); static void bitmap_set_copy (bitmap_set_t, bitmap_set_t); static bool bitmap_set_contains_value (bitmap_set_t, unsigned int); static void bitmap_insert_into_set (bitmap_set_t, pre_expr); -static void bitmap_insert_into_set_1 (bitmap_set_t, pre_expr, bool); +static void bitmap_insert_into_set_1 (bitmap_set_t, pre_expr, + unsigned int, bool); static bitmap_set_t bitmap_set_new (void); static tree create_expression_by_pieces (basic_block, pre_expr, gimple_seq *, gimple, tree); @@ -580,7 +581,7 @@ add_to_value (unsigned int v, pre_expr e) VEC_replace (bitmap_set_t, value_expressions, v, set); } - bitmap_insert_into_set_1 (set, e, true); + bitmap_insert_into_set_1 (set, e, v, true); } /* Create a new bitmap set and return it. */ @@ -638,9 +639,8 @@ bitmap_remove_from_set (bitmap_set_t set, pre_expr expr) static void bitmap_insert_into_set_1 (bitmap_set_t set, pre_expr expr, - bool allow_constants) + unsigned int val, bool allow_constants) { - unsigned int val = get_expr_value_id (expr); if (allow_constants || !value_id_constant_p (val)) { /* We specifically expect this and only this function to be able to @@ -655,7 +655,7 @@ bitmap_insert_into_set_1 (bitmap_set_t set, pre_expr expr, static void bitmap_insert_into_set (bitmap_set_t set, pre_expr expr) { - bitmap_insert_into_set_1 (set, expr, false); + bitmap_insert_into_set_1 (set, expr, get_expr_value_id (expr), false); } /* Copy a bitmapped set ORIG, into bitmapped set DEST. */ @@ -863,11 +863,8 @@ bitmap_value_insert_into_set (bitmap_set_t set, pre_expr expr) { unsigned int val = get_expr_value_id (expr); - if (value_id_constant_p (val)) - return; - if (!bitmap_set_contains_value (set, val)) - bitmap_insert_into_set (set, expr); + bitmap_insert_into_set_1 (set, expr, val, false); } /* Print out EXPR to outfile. */ diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index e91408775bb..2994bffd76e 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -401,15 +401,15 @@ vn_reference_op_eq (const void *p1, const void *p2) /* Compute the hash for a reference operand VRO1. */ static hashval_t -vn_reference_op_compute_hash (const vn_reference_op_t vro1) +vn_reference_op_compute_hash (const vn_reference_op_t vro1, hashval_t result) { - hashval_t result = 0; + result = iterative_hash_hashval_t (vro1->opcode, result); if (vro1->op0) - result += iterative_hash_expr (vro1->op0, vro1->opcode); + result = iterative_hash_expr (vro1->op0, result); if (vro1->op1) - result += iterative_hash_expr (vro1->op1, vro1->opcode); + result = iterative_hash_expr (vro1->op1, result); if (vro1->op2) - result += iterative_hash_expr (vro1->op2, vro1->opcode); + result = iterative_hash_expr (vro1->op2, result); return result; } @@ -427,13 +427,14 @@ vn_reference_hash (const void *p1) hashval_t vn_reference_compute_hash (const vn_reference_t vr1) { - hashval_t result; + hashval_t result = 0; int i; vn_reference_op_t vro; - result = iterative_hash_expr (vr1->vuse, 0); for (i = 0; VEC_iterate (vn_reference_op_s, vr1->operands, i, vro); i++) - result += vn_reference_op_compute_hash (vro); + result = vn_reference_op_compute_hash (vro, result); + if (vr1->vuse) + result += SSA_NAME_VERSION (vr1->vuse); return result; } @@ -1000,9 +1001,11 @@ vn_reference_lookup_2 (ao_ref *op ATTRIBUTE_UNUSED, tree vuse, void *vr_) *last_vuse_ptr = vuse; /* Fixup vuse and hash. */ - vr->hashcode = vr->hashcode - iterative_hash_expr (vr->vuse, 0); + if (vr->vuse) + vr->hashcode = vr->hashcode - SSA_NAME_VERSION (vr->vuse); vr->vuse = SSA_VAL (vuse); - vr->hashcode = vr->hashcode + iterative_hash_expr (vr->vuse, 0); + if (vr->vuse) + vr->hashcode = vr->hashcode + SSA_NAME_VERSION (vr->vuse); hash = vr->hashcode; slot = htab_find_slot_with_hash (current_info->references, vr, @@ -1360,7 +1363,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 = 0; + hashval_t hash; unsigned i; for (i = 0; i < vno1->length; ++i) @@ -1376,8 +1379,9 @@ vn_nary_op_compute_hash (const vn_nary_op_t vno1) vno1->op[1] = temp; } + hash = iterative_hash_hashval_t (vno1->opcode, 0); for (i = 0; i < vno1->length; ++i) - hash += iterative_hash_expr (vno1->op[i], vno1->opcode); + hash = iterative_hash_expr (vno1->op[i], hash); return hash; } @@ -1629,7 +1633,7 @@ vn_nary_op_insert_stmt (gimple stmt, tree result) static inline hashval_t vn_phi_compute_hash (vn_phi_t vp1) { - hashval_t result = 0; + hashval_t result; int i; tree phi1op; tree type; @@ -1647,7 +1651,7 @@ vn_phi_compute_hash (vn_phi_t vp1) { if (phi1op == VN_TOP) continue; - result += iterative_hash_expr (phi1op, result); + result = iterative_hash_expr (phi1op, result); } return result; @@ -3310,23 +3314,6 @@ expressions_equal_p (tree e1, tree e2) if (!e1 || !e2) return false; - /* Recurse on elements of lists. */ - if (TREE_CODE (e1) == TREE_LIST && TREE_CODE (e2) == TREE_LIST) - { - tree lop1 = e1; - tree lop2 = e2; - for (lop1 = e1, lop2 = e2; - lop1 || lop2; - lop1 = TREE_CHAIN (lop1), lop2 = TREE_CHAIN (lop2)) - { - if (!lop1 || !lop2) - return false; - if (!expressions_equal_p (TREE_VALUE (lop1), TREE_VALUE (lop2))) - return false; - } - return true; - } - /* Now perform the actual comparison. */ if (TREE_CODE (e1) == TREE_CODE (e2) && operand_equal_p (e1, e2, OEP_PURE_SAME)) -- 2.30.2