From patchwork Wed Oct 5 05:58:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 678358 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 3splTL2F3tz9s1h for ; Wed, 5 Oct 2016 16:58:44 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=SfqoIzRJ; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=jTbxVWBit6RAEiwqR w1e3Vd7s3lMxsIpV/8Qftpa3cfH5qQpFvMamoOm6JXYrCW5HvRnovmOZtgW+Lmar 1E9Pbe5iWSH+KUGKyyIt+TunoAtIHl4W74TbMlemrsyN7qdsWJxSfGiLYZEL6XEZ Eh+SSXobYG5FL2hoPKaW57+mGw= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=RBYqZhKEuGUufaYIE8cKD1t Ilxs=; b=SfqoIzRJUpfMiGgFBsD980bsJQ3WywEj00z2cOq2+xzR4CYpxvtPRfS +p5/RoIsdpwrchyffaL39H2tO2JtC2CsYtk9c1IS6PCjz3wwGs9BI9l++cDv3y06 WkYCOkVwY8pc9ufDxd1t0kolIBUdLCjJ6q4CPTSu4rjQTISIcnBw= Received: (qmail 97356 invoked by alias); 5 Oct 2016 05:58:35 -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 97344 invoked by uid 89); 5 Oct 2016 05:58:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-10-05, IPA X-HELO: mail-pf0-f177.google.com Received: from mail-pf0-f177.google.com (HELO mail-pf0-f177.google.com) (209.85.192.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Oct 2016 05:58:24 +0000 Received: by mail-pf0-f177.google.com with SMTP id i85so32596003pfa.3 for ; Tue, 04 Oct 2016 22:58:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=4uU7hnMFOFAAikGwglrvBdEcyHo4Bc2FZn8myyJM/po=; b=MSz+FfaZaNtOVz1HlECD42X0DEaN0zk4iJfMS9ulCQu4+nd3mUQEeTFOFjsA/u2dZt 7Cxd0aRng7KD5Azk2hZC0imH3/R9EVvyhcOErmAY549YO4d0eQ6oXnj2vX/NqohrciwL dhTHbVsOHQ8595qTgpysmaEk3k3exE5OqGJWXelanxsUYFBWRvXIJ+jX4F4S05Jq9gZp Xkj8fFu2jzMm8zj6H9+spF8el7jZheAfkYsRaAxd3tARkhYSjBt8INpvgs/oL/uG5vwq qowapMeqhOxeq4WsihlUvuk4qGIvHjQTxDPzhnj2u6Q8bMz0iRSEPY86YaSYjkkWv5m8 09Kg== X-Gm-Message-State: AA6/9Rk1bgUkp4efBlt7bmwLQcxnwzdm4e1BcRlJ3cRvQO/PAfQJL6nBox9oznSFODHLTGzG X-Received: by 10.98.111.195 with SMTP id k186mr12757713pfc.148.1475647102571; Tue, 04 Oct 2016 22:58:22 -0700 (PDT) Received: from [10.1.1.7] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id e4sm10280407pas.21.2016.10.04.22.58.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Oct 2016 22:58:21 -0700 (PDT) Subject: Re: [EVRP] Fold stmts with vrp_fold_stmt To: Richard Biener References: Cc: "gcc-patches@gcc.gnu.org" From: kugan Message-ID: <1ceb9248-9146-ff56-d914-5abe6deea0fa@linaro.org> Date: Wed, 5 Oct 2016 16:58:18 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: X-IsSubscribed: yes Hi Richard, Thanks for the review. On 04/10/16 19:56, Richard Biener wrote: > On Tue, 4 Oct 2016, kugan wrote: > >> Hi, >> >> This patch improves Early VRP by folding stmts using vrp_fold_stmt as it is >> done in ssa_propagate for VRP. > > Why? I thought it would be good for early vrp to simplify stmts using ranges. If we simplify obvious cases early, wouldn't it be better for IPA/LTO? I'd like us to move away from the fold_stmt callback of > substitute-and-fold (I have actually started some work towards that). I must have missed it. But what is the general issue with substitute-and-fold. > >> I have also changed EVRP to handle POINTER_TYPE_P. I will send follow up >> patches to use this in IPA-VRP. > > For pointers all VRP does is track non-NULLness. Can you split out this > part? Attached patch does that. > I'm really worried about all the testsuite changes -- it means we are > losing test coverage for VRP :/ As you said earlier, unit testing with gimple FE should help. I am also wondering if we should organize these testcases such that it is run once without evrp and once with evrp to test both? Thanks, Kugan gcc/ChangeLog: 2016-10-05 Kugan Vivekanandarajah * tree-vrp.c (evrp_dom_walker::before_dom_children): Handle POINTER_TYPE_P. gcc/testsuite/ChangeLog: 2016-10-05 Kugan Vivekanandarajah * gcc.dg/tree-ssa/evrp4.c: New test. > > Richard. > >> Bootstrapped and regression testd on x86_64-linux-gnu with no new regressions. >> Is this OK for trunk? >> >> Thanks, >> Kugan >> >> gcc/testsuite/ChangeLog: >> >> 2016-10-03 Kugan Vivekanandarajah >> >> * gcc.dg/pr68217.c: Adjust testcase as more cases are now handled in >> evrp. >> * gcc.dg/predict-1.c: Likewise. >> * gcc.dg/predict-9.c: Likewise. >> * gcc.dg/tree-ssa/pr20318.c: Likewise. >> * gcc.dg/tree-ssa/pr21001.c: Likewise. >> * gcc.dg/tree-ssa/pr21090.c: Likewise. >> * gcc.dg/tree-ssa/pr21294.c: Likewise. >> * gcc.dg/tree-ssa/pr21559.c: Likewise. >> * gcc.dg/tree-ssa/pr21563.c: Likewise. >> * gcc.dg/tree-ssa/pr23744.c: Likewise. >> * gcc.dg/tree-ssa/pr25382.c: Likewise. >> * gcc.dg/tree-ssa/pr61839_1.c: Likewise. >> * gcc.dg/tree-ssa/pr68431.c: Likewise. >> * gcc.dg/tree-ssa/vrp03.c: Likewise. >> * gcc.dg/tree-ssa/vrp07.c: Likewise. >> * gcc.dg/tree-ssa/vrp09.c: Likewise. >> * gcc.dg/tree-ssa/vrp17.c: Likewise. >> * gcc.dg/tree-ssa/vrp18.c: Likewise. >> * gcc.dg/tree-ssa/vrp19.c: Likewise. >> * gcc.dg/tree-ssa/vrp20.c: Likewise. >> * gcc.dg/tree-ssa/vrp23.c: Likewise. >> * gcc.dg/tree-ssa/vrp24.c: Likewise. >> * gcc.dg/tree-ssa/vrp58.c: Likewise. >> * gcc.dg/tree-ssa/vrp92.c: Likewise. >> * gcc.dg/tree-ssa/vrp98.c: Likewise. >> * gcc.dg/vrp-min-max-1.c: Likewise. >> >> gcc/ChangeLog: >> >> 2016-10-03 Kugan Vivekanandarajah >> >> * tree-vrp.c (evrp_dom_walker::before_dom_children): Handle >> POINTER_TYPE_P. Also fold stmts with vrp_fold_stmt. >> > From c9badd0cee1433af67ba5e1a45a90b4b659a244f Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Mon, 3 Oct 2016 06:12:05 +1100 Subject: [PATCH 1/5] Handle pointer type in evrp --- gcc/testsuite/gcc.dg/tree-ssa/evrp4.c | 20 ++++++++++++++++++++ gcc/tree-vrp.c | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/evrp4.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c b/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c new file mode 100644 index 0000000..ebb87ed --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/evrp4.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-evrp" } */ + +int foo (int *p); + +struct st +{ + int a; + int b; +}; + +int bar (struct st *s) +{ + + if (!s) + return 0; + foo (&s->a); +} + +/* { dg-final { scan-tree-dump "\~\\\[0B, 0B\\\]" "evrp" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 7a08be7..46bbd82 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -10666,7 +10666,8 @@ evrp_dom_walker::before_dom_children (basic_block bb) && gimple_code (stmt) == GIMPLE_COND && (op0 = gimple_cond_lhs (stmt)) && TREE_CODE (op0) == SSA_NAME - && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))) + && (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt))) + || POINTER_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt))))) { /* Entering a new scope. Try to see if we can find a VR here. */ -- 2.7.4