From patchwork Wed Jul 30 14:23:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Kleen X-Patchwork-Id: 374922 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5766714012D for ; Thu, 31 Jul 2014 00:25:24 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=L5BHW30vosSI9cK2s5/S6kRgoGo8xrZ9zcnUaEA9Udc6eyA7BALl9 02srbFCIcMJloeZDlKTVREbHfbhmGstGENUrDRzm/TIToVatV0q/W16qQRxalrT6 fNud2RuQGIkIOlNVz08GPYAWfkyjY8NYYzJ4vkG5vEgCwW5DcK8n3A= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=xbKafbR+7yJnjp/YrzIGnz6h/V0=; b=qFxPugjSuoKrtiyy4q47 giBI+M4QTCfxqqs6DJ7+IDFBWs+sRzFInjPx5/JXkHN1mhYohd03EGYTj1vNrJSK eIGB+FnPsogS3r5P8uOpHTJwod56WssBMX6Eomqzt+0R+5xKwc2H7zk/F48+poOu 7f98lilFw8EENLIFX90L4N8= Received: (qmail 12204 invoked by alias); 30 Jul 2014 14:24:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 12109 invoked by uid 89); 30 Jul 2014 14:24:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: one.firstfloor.org Received: from one.firstfloor.org (HELO one.firstfloor.org) (193.170.194.197) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 30 Jul 2014 14:24:21 +0000 Received: from basil.firstfloor.org (184-100-237-164.ptld.qwest.net [184.100.237.164]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by one.firstfloor.org (Postfix) with ESMTPSA id 0E9973F769; Wed, 30 Jul 2014 16:24:14 +0200 (CEST) Received: by basil.firstfloor.org (Postfix, from userid 1000) id 2CA2FA2989; Wed, 30 Jul 2014 07:23:50 -0700 (PDT) From: Andi Kleen To: gcc-patches@gcc.gnu.org Cc: Andi Kleen Subject: [PATCH 5/7] Convert tree-ssa-dom to inchash Date: Wed, 30 Jul 2014 07:23:43 -0700 Message-Id: <1406730225-25896-6-git-send-email-andi@firstfloor.org> In-Reply-To: <1406730225-25896-5-git-send-email-andi@firstfloor.org> References: <1406730225-25896-1-git-send-email-andi@firstfloor.org> <1406730225-25896-2-git-send-email-andi@firstfloor.org> <1406730225-25896-3-git-send-email-andi@firstfloor.org> <1406730225-25896-4-git-send-email-andi@firstfloor.org> <1406730225-25896-5-git-send-email-andi@firstfloor.org> From: Andi Kleen gcc/: 2014-07-29 Andi Kleen * 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. --- gcc/tree-ssa-dom.c | 81 ++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 42 deletions(-) diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c index 08fd2fa..fec386e 100644 --- a/gcc/tree-ssa-dom.c +++ b/gcc/tree-ssa-dom.c @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see #include "params.h" #include "tree-ssa-threadedge.h" #include "tree-ssa-dom.h" +#include "inchash.h" /* This file implements optimizations on the dominator tree. */ @@ -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 - 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, regardless of the order in which they are presented. This is useful in hashing the operands of commutative functions. */ -static hashval_t -iterative_hash_exprs_commutative (const_tree t1, - const_tree t2, hashval_t val) +namespace inchash { - hashval_t one = iterative_hash_expr (t1, 0); - hashval_t two = iterative_hash_expr (t2, 0); - hashval_t t; - if (one > two) - t = one, one = two, two = t; - val = iterative_hash_hashval_t (one, val); - val = iterative_hash_hashval_t (two, val); +static void +add_expr_commutative (const_tree t1, const_tree t2, hash &hstate) +{ + 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 previously accumulated hash value VAL. If two hashable_expr values compare equal with hashable_expr_equal_p, they must 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 -iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) +static void +add_hashable_expr (const struct hashable_expr *expr, hash &hstate) { switch (expr->kind) { case EXPR_SINGLE: - val = iterative_hash_expr (expr->ops.single.rhs, val); + inchash::add_expr (expr->ops.single.rhs, hstate); break; 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. 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) have different hash codes. */ if (CONVERT_EXPR_CODE_P (expr->ops.unary.op) || 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; 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)) - val = iterative_hash_exprs_commutative (expr->ops.binary.opnd0, - expr->ops.binary.opnd1, val); + inchash::add_expr_commutative (expr->ops.binary.opnd0, + expr->ops.binary.opnd1, hstate); else { - val = iterative_hash_expr (expr->ops.binary.opnd0, val); - val = iterative_hash_expr (expr->ops.binary.opnd1, val); + inchash::add_expr (expr->ops.binary.opnd0, hstate); + inchash::add_expr (expr->ops.binary.opnd1, hstate); } break; 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)) - val = iterative_hash_exprs_commutative (expr->ops.ternary.opnd0, - expr->ops.ternary.opnd1, val); + inchash::add_expr_commutative (expr->ops.ternary.opnd0, + expr->ops.ternary.opnd1, hstate); else { - val = iterative_hash_expr (expr->ops.ternary.opnd0, val); - val = iterative_hash_expr (expr->ops.ternary.opnd1, val); + inchash::add_expr (expr->ops.ternary.opnd0, hstate); + 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; case EXPR_CALL: @@ -639,15 +637,14 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) enum tree_code code = CALL_EXPR; gimple fn_from; - val = iterative_hash_object (code, val); + hstate.add_object (code); fn_from = expr->ops.call.fn_from; if (gimple_call_internal_p (fn_from)) - val = iterative_hash_hashval_t - ((hashval_t) gimple_call_internal_fn (fn_from), val); + hstate.merge_hash ((hashval_t) gimple_call_internal_fn (fn_from)); 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++) - val = iterative_hash_expr (expr->ops.call.args[i], val); + inchash::add_expr (expr->ops.call.args[i], hstate); } break; @@ -656,15 +653,15 @@ iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val) size_t 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; default: gcc_unreachable (); } +} - return val; } /* Print a diagnostic dump of an expression hash table entry. */ @@ -2599,24 +2596,24 @@ avail_expr_hash (const void *p) gimple stmt = ((const struct expr_hash_elt *)p)->stmt; const struct hashable_expr *expr = &((const struct expr_hash_elt *)p)->expr; 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 can just hash the expression and not worry about virtual operands and such. */ if (!stmt) - return val; + return hstate.end (); /* Add the SSA version numbers of the vuse operand. This is important because compound variables like arrays are not renamed in the operands. Rather, the rename is done on the virtual variable representing all the elements of the array. */ 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