From patchwork Thu Oct 13 04:38:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 77607 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp49729qge; Wed, 12 Oct 2016 21:38:34 -0700 (PDT) X-Received: by 10.98.223.145 with SMTP id d17mr7071284pfl.82.1476333514803; Wed, 12 Oct 2016 21:38:34 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id fo6si10447106pab.184.2016.10.12.21.38.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Oct 2016 21:38:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-438455-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-438455-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-438455-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org 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=RzNCWB/eMENUEPBZj ev0WPLjTbwzwePndjRQyilsxmkkShilDDehkrD3vtOlSXRj27QsTAZMx54fI1Fua kbn+LomHmEud7eC4H6ff86KpgXRbFXpNdvW4fqiNJC9FFhwY0ADMGnciz3Um4Oy3 cviq9IdcBlSuEjpqGnXw/XsL/8= 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=0hdHBYQmLS4u3cFAdoZ8KXq 5XOU=; b=iXAcPcgBG2NWFR2yhbg6jH4UxEO6HSTCp5qqL5P97C9RlvA1JM+4HF0 qfFu4+5Npoquoa0nfiN6YUJVcroZgF2idbln3V7lBpJ0EO+XplUz63kGIgAYzz5g EkitxBfQamLvx8oii6PrBXtrCYhXmIn+nIeqQuGsJseKZp0sNH34= Received: (qmail 112959 invoked by alias); 13 Oct 2016 04:38:21 -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 112940 invoked by uid 89); 13 Oct 2016 04:38:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=TREE-VRP, IPAVRP, Hx-languages-length:2707, IPA-VRP X-HELO: mail-pa0-f54.google.com Received: from mail-pa0-f54.google.com (HELO mail-pa0-f54.google.com) (209.85.220.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Oct 2016 04:38:10 +0000 Received: by mail-pa0-f54.google.com with SMTP id vu5so34934483pab.0 for ; Wed, 12 Oct 2016 21:38:10 -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=ri9ip93MFaAIYTBblkgdul+JaH1y0GNgk0UApCUi66Y=; b=YhvTVMrb18SLkkBgPdYRBSbF5DaR2H2M9HFqH4IjCM3Ua5VKg9iR0Q33HagZv4gX8r 89r8xZbk0WbT3EOFdFcpb78ts2ldjOd564s5AqDXwrnFvjkMVWezOP9FCHXuDJ8cmS86 hCT8pDu+t7tREuHkNjWPwPa7ZZpJAUUGcQc9QDBpbNlnfk2AzuamaeRqh7TU6osRlMpj JvDxCM8aiXer2Bw87whFtZQAFTe0G/tqD/io8J2Qs32cmgZXk1xgGp0V9+m8MI0OosyH oeGGCAoWTdM130fSZY6bslDTtTL3VAdp18vWFMDaMjP9PWPHu7Z0+9W99AvVBgNnrs1d K4GQ== X-Gm-Message-State: AA6/9RmYSCjyav6hGD4kBtM2uwk/5SO/KhBUMpaLlIQaYvi6Ia0dojrhxASERtTCDsEtS98/ X-Received: by 10.66.63.40 with SMTP id d8mr6050959pas.103.1476333488890; Wed, 12 Oct 2016 21:38:08 -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 d5sm15395987pao.48.2016.10.12.21.38.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Oct 2016 21:38:08 -0700 (PDT) Subject: Re: [vrp] use get_ptr_nonnull in tree-vrp To: Richard Biener References: <717fb095-f0a9-6980-ddbd-e755a4fd6457@linaro.org> <2cfe50b8-1841-2b1a-9baa-1464cebd953b@linaro.org> <69200442-0d37-2750-9fe9-4fc3583a0094@linaro.org> Cc: "gcc-patches@gcc.gnu.org" , Jeff Law From: kugan Message-ID: <5162069f-bb7a-c3f3-cd6d-183d5bbf32c9@linaro.org> Date: Thu, 13 Oct 2016 15:38:03 +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: <69200442-0d37-2750-9fe9-4fc3583a0094@linaro.org> X-IsSubscribed: yes Hi Richard, On 13/10/16 05:53, kugan wrote: > Hi Richard, > > On 12/10/16 23:24, Richard Biener wrote: >> On Wed, Oct 12, 2016 at 8:56 AM, kugan >> wrote: >>> Hi, >>> >>> This patch uses get_ptr_nonnull in tree-vrp. >>> >>> Bootstrapped and regression tested this with other patched without any >>> new regressions on x86_64-linux-gnu. >>> >>> Is this OK for trunk? >> >> Um. Doesn't make much sense given nothing provides this info before EVRP? >> And if it makes sense then it makes sense not only for PARM_DECL SSA names. > Not before EVRP. But when in TREE-VRP, EVRP + IPA-VRP should provide this. My primary intention was to pass it for PARM_DECL SSA names which comes from ipa-vrp. I have changed this now. Thanks, Kugan > I am not sure if this is the question? > > Thanks, > Kugan >> >> Richard. >> >>> Thanks, >>> Kugan >>> >>> gcc/testsuite/ChangeLog: >>> >>> 2016-10-12 Kugan Vivekanandarajah >>> >>> * gcc.dg/ipa/vrp4.c: Adjust testcase. >>> >>> gcc/ChangeLog: >>> >>> 2016-10-12 Kugan Vivekanandarajah >>> >>> * tree-vrp.c (get_value_range): Check get_ptr_nonnull. >From c033af7161bcf54f50262688854cb32e3e8eeb54 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Wed, 12 Oct 2016 13:54:58 +1100 Subject: [PATCH 3/3] Teach-vrp-to-use-ptr-nonnull --- gcc/testsuite/gcc.dg/ipa/vrp4.c | 3 ++- gcc/tree-vrp.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/ipa/vrp4.c b/gcc/testsuite/gcc.dg/ipa/vrp4.c index d7e1f26..941f80e 100644 --- a/gcc/testsuite/gcc.dg/ipa/vrp4.c +++ b/gcc/testsuite/gcc.dg/ipa/vrp4.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -fdump-ipa-cp-details" } */ +/* { dg-options "-O2 -fdump-ipa-cp-details -fdump-tree-vrp1" } */ static __attribute__((noinline, noclone)) int foo (int *p) @@ -25,3 +25,4 @@ int bar (struct st *s) } /* { dg-final { scan-ipa-dump "Setting nonnull for 0" "cp" } } */ +/* { dg-final { scan-tree-dump-times "if" 1 "vrp1" } } */ diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 7e4f947..bc53d07 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -679,7 +679,10 @@ get_value_range (const_tree var) if (SSA_NAME_IS_DEFAULT_DEF (var)) { sym = SSA_NAME_VAR (var); - if (TREE_CODE (sym) == PARM_DECL) + if (POINTER_TYPE_P (TREE_TYPE (sym)) + && get_ptr_nonnull (var)) + set_value_range_to_nonnull (vr, TREE_TYPE (sym)); + else if (TREE_CODE (sym) == PARM_DECL) { /* Try to use the "nonnull" attribute to create ~[0, 0] anti-ranges for pointers. Note that this is only valid with -- 2.7.4