From patchwork Wed Apr 20 22:45:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 612885 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 3qqxn605vjz9t3s for ; Thu, 21 Apr 2016 08:46:00 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=mOxCSud6; dkim-atps=neutral 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; q=dns; s=default; b=ZQcnwpwEj5L+ VIw+GmcbRGXMG9ELcMLQy8cC80kyuE2Kshz8T/p3UWZE+Uld9tiQlwGbayStCgmp Z5nEXfCD/f8dE93X91fz8pPdc+SIbMJe/VTVTaXfeujy5eDupTF5V9vtE61nlOD0 ewHXaWjg11R70n3TqOBO6ZTu/d9uddQ= 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; s=default; bh=ae/o9LhN853kSgn09y I3qbIihDk=; b=mOxCSud6NvdjPVWuYHX31lwl8JoCz8QUJndJsoZy5laeQJDKQq eE1GwYQ3oBgdwibZRRztxsYNfNTEigc0/i0e6K/Am4pnFq8jm4Vn1c/bT81zCx7u iKivk5p9KoPGwK4EDkint04++1O26p0IOPal6ob4y4p5DQrAOMpLdOEcI= Received: (qmail 83417 invoked by alias); 20 Apr 2016 22:45:52 -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 83402 invoked by uid 89); 20 Apr 2016 22:45:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=plus_expr, PLUS_EXPR, IN_RANGE, in_range X-HELO: mail-qg0-f47.google.com Received: from mail-qg0-f47.google.com (HELO mail-qg0-f47.google.com) (209.85.192.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 20 Apr 2016 22:45:41 +0000 Received: by mail-qg0-f47.google.com with SMTP id f74so34367730qge.2 for ; Wed, 20 Apr 2016 15:45:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ZAzK1eFwUf5DIzycN9lVqiKZmzdjWOMZp/bj0meARVc=; b=Ro1Jy3WXi96QRxnDpnjEUYR8Ser4iznlSRI0UMfDgKh19s5Z3j8r7E0QdHNduwfpDL iB5CRG8LulAhw6QMbOobfaoiJSK89Ft9BPtBr5RijYWN6+keagj7P0PnINo1xLXeI1xo V7bpeKBPQqe17cEVqi+kSpLvnG3fJ49u5qD19FdwOPnBKSFjlcai3Lghnv+p3QAPDOp/ aFjiiHEdvJU2ix87SVQjWM89c+MY9Y8o92o56Y5IyGVlim+k+p49j/pZwoV13ylx4EBz itXbg4NFbm5doGN63lLCy3PueR7sOHsQdDzqut62Gxw/oxohYVh0SFG/QTU5ICPsNq77 t9Sg== X-Gm-Message-State: AOPr4FU+Gh3KbkrsBY7HT+W3WNllq7BEcKINieuxm0R3YB8J/v71rOMfnWfEaQIwsxqRqQ== X-Received: by 10.140.42.74 with SMTP id b68mr14272173qga.60.1461192338933; Wed, 20 Apr 2016 15:45:38 -0700 (PDT) Received: from localhost.localdomain (ool-4353abbc.dyn.optonline.net. [67.83.171.188]) by smtp.gmail.com with ESMTPSA id l66sm21642275qhc.42.2016.04.20.15.45.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 20 Apr 2016 15:45:38 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: Patrick Palka Subject: [PATCH] vrp: remove rendundant has_single_use tests Date: Wed, 20 Apr 2016 18:45:28 -0400 Message-Id: <1461192328-25630-1-git-send-email-patrick@parcs.ath.cx> During assert-location discovery, if an SSA name is live according to live_on_edge() on some outgoing edge E, then the SSA name definitely has at least two uses: the use on the outgoing edge, and the use in some BB dominating E->src from which the SSA_NAME and the potential assertion was discovered. These two uses can't be the same because the liveness array is populated on-the-fly in reverse postorder so the latter use which dominates BB couldn't have yet contributed to the liveness bitmap. So AFAICT it's not necessary to check live_on_edge() as well as !has_single_use() since the former check will imply the latter. So this patch removes these redundant calls to has_single_use() (and alse replaces the use of has_single_use() in find_assert_locations_1 with a liveness bitmap test which should be cheaper and more accurate). I bootstrapped and regtested this change on x86_64-pc-linux-gnu. I also confirmed that the number of calls made to register_new_assert_for before and after the patch remains the same during compilation of libstdc++ and during compilation of gimple-match.c and when running the tree-ssa.exp testsuite. Does this look OK to commit? gcc/ChangeLog: * tree-vrp.c (register_edge_assert_for_2): Remove redundant has_single_use() tests. (register_edge_assert_for_1): Likewise. (find_assert_locations_1): Check the liveness bitmap instead of calling has_single_use(). --- gcc/tree-vrp.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index bbdf9ce..3cb470b 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -5145,8 +5145,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, /* Only register an ASSERT_EXPR if NAME was found in the sub-graph reachable from E. */ - if (live_on_edge (e, name) - && !has_single_use (name)) + if (live_on_edge (e, name)) register_new_assert_for (name, name, comp_code, val, NULL, e, bsi); /* In the case of NAME <= CST and NAME being defined as @@ -5188,8 +5187,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, && (cst2 == NULL_TREE || TREE_CODE (cst2) == INTEGER_CST) && INTEGRAL_TYPE_P (TREE_TYPE (name3)) - && live_on_edge (e, name3) - && !has_single_use (name3)) + && live_on_edge (e, name3)) { tree tmp; @@ -5215,8 +5213,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, && TREE_CODE (name2) == SSA_NAME && TREE_CODE (cst2) == INTEGER_CST && INTEGRAL_TYPE_P (TREE_TYPE (name2)) - && live_on_edge (e, name2) - && !has_single_use (name2)) + && live_on_edge (e, name2)) { tree tmp; @@ -5319,8 +5316,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, tree op1 = gimple_assign_rhs2 (def_stmt); if (TREE_CODE (op0) == SSA_NAME && TREE_CODE (op1) == INTEGER_CST - && live_on_edge (e, op0) - && !has_single_use (op0)) + && live_on_edge (e, op0)) { enum tree_code reverse_op = (rhs_code == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR); @@ -5346,8 +5342,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, && (comp_code == LE_EXPR || comp_code == GT_EXPR || !tree_int_cst_equal (val, TYPE_MIN_VALUE (TREE_TYPE (val)))) - && live_on_edge (e, name2) - && !has_single_use (name2)) + && live_on_edge (e, name2)) { tree tmp, cst; enum tree_code new_comp_code = comp_code; @@ -5392,8 +5387,7 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, && INTEGRAL_TYPE_P (TREE_TYPE (name2)) && IN_RANGE (tree_to_uhwi (cst2), 1, prec - 1) && prec == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (val))) - && live_on_edge (e, name2) - && !has_single_use (name2)) + && live_on_edge (e, name2)) { mask = wi::mask (tree_to_uhwi (cst2), false, prec); val2 = fold_binary (LSHIFT_EXPR, TREE_TYPE (val), val, cst2); @@ -5498,12 +5492,10 @@ register_edge_assert_for_2 (tree name, edge e, gimple_stmt_iterator bsi, || !INTEGRAL_TYPE_P (TREE_TYPE (names[1])) || (TYPE_PRECISION (TREE_TYPE (name2)) != TYPE_PRECISION (TREE_TYPE (names[1]))) - || !live_on_edge (e, names[1]) - || has_single_use (names[1])) + || !live_on_edge (e, names[1])) names[1] = NULL_TREE; } - if (live_on_edge (e, name2) - && !has_single_use (name2)) + if (live_on_edge (e, name2)) names[0] = name2; } } @@ -5724,8 +5716,7 @@ register_edge_assert_for_1 (tree op, enum tree_code code, /* We know that OP will have a zero or nonzero value. If OP is used more than once go ahead and register an assert for OP. */ - if (live_on_edge (e, op) - && !has_single_use (op)) + if (live_on_edge (e, op)) { val = build_int_cst (TREE_TYPE (op), 0); register_new_assert_for (op, op, code, val, NULL, e, bsi); @@ -6158,7 +6149,7 @@ find_assert_locations_1 (basic_block bb, sbitmap live) /* Note we want to register the assert for the operand of the NOP_EXPR after SI, not after the conversion. */ - if (! has_single_use (t)) + if (bitmap_bit_p (live, SSA_NAME_VERSION (t))) register_new_assert_for (t, t, comp_code, value, bb, NULL, si); }