From patchwork Mon Oct 26 16:26:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 536106 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 6A395141310 for ; Tue, 27 Oct 2015 03:27:13 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=t35mRxoS; 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=XfE4xyaKdSGUtgpA8 9yIXaNUJdvsKGnmpsYeZ3YpN65RxQAI2kKVR1bJI//WjCEBwMTBiTjpA875rk3Mj m4RqP/NL6TM2fTDYz84DjZS0WLaM0/oQC6k2WswC67SKlddXW1nEBjsqVeZIBItZ eWh5nz6nTbPSvV8kyPipQRUUOM= 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=MTfIUskI1uCS3uAIUk1KoPe vwTE=; b=t35mRxoSA5eyRCo8qip5+wOS21ml/RgewC+rQBnjs00NxB7c1xulsMj Q13uF3d8596ZA0pW9dyW5PJ6zoaF4vZTnFXCpbegh4e10e/n+Axf81s3G5uOQtIK ltb5uT/AdJwKpCjr2p4d+IECnwpaQEeVOTJNY4ZZRDCzGlfoSmsE= Received: (qmail 2295 invoked by alias); 26 Oct 2015 16:27:00 -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 2230 invoked by uid 89); 26 Oct 2015 16:27:00 -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, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 26 Oct 2015 16:26:57 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-04.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zqkbl-0004qa-NC from Tom_deVries@mentor.com ; Mon, 26 Oct 2015 09:26:54 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-04.mgc.mentorg.com (137.202.0.110) with Microsoft SMTP Server id 14.3.224.2; Mon, 26 Oct 2015 16:26:52 +0000 Subject: Re: [PATCH, 2/2] Handle recursive restrict pointer in create_variable_info_for_1 To: References: <562E0D16.3010400@mentor.com> CC: Richard Biener From: Tom de Vries Message-ID: <562E543D.8050700@mentor.com> Date: Mon, 26 Oct 2015 17:26:37 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <562E0D16.3010400@mentor.com> On 26/10/15 12:23, Tom de Vries wrote: > Hi, > > this patch enables recursive restrict handling in > create_variable_info_for_1. > > This allows us to interpret all restricts in a function parameter > "int *restrict *restrict *restrict a". > > This patch is the first step towards implementing a generic fix for > PR67742. > > Bootstrapped and reg-tested on x86_64. > Reposting with restrict_pointed_var as a hash_map rather than a field. > OK for trunk? > Thanks, - Tom Handle recursive restrict pointer in create_variable_info_for_1 2015-10-26 Tom de Vries * tree-ssa-structalias.c (create_variable_info_for_1): Enable recursive handling of restrict pointers. (make_restrict_var_constraints): Handle restrict vars recursively. * gcc.dg/tree-ssa/restrict-7.c: New test. --- gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c | 12 ++++++++++++ gcc/tree-ssa-structalias.c | 13 +++++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c diff --git a/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c b/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c new file mode 100644 index 0000000..f7a68c7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/restrict-7.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-fre1" } */ + +int +f (int *__restrict__ *__restrict__ *__restrict__ a, int *b) +{ + *b = 1; + ***a = 2; + return *b; +} + +/* { dg-final { scan-tree-dump-times "return 1" 1 "fre1" } } */ diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index f1325e0..79e9773 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -5726,7 +5726,7 @@ create_variable_info_for_1 (tree decl, const char *name, bool handle_param) varinfo_t rvi; tree heapvar = build_fake_var_decl (TREE_TYPE (decl_type)); DECL_EXTERNAL (heapvar) = 1; - rvi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", false); + rvi = create_variable_info_for_1 (heapvar, "PARM_NOALIAS", true); rvi->is_restrict_var = 1; insert_vi_for_tree (heapvar, rvi); insert_restrict_pointed_var (vi, rvi); @@ -5897,7 +5897,16 @@ make_restrict_var_constraints (varinfo_t vi) if (vi->may_have_pointers) { if (vi->only_restrict_pointers) - make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT"); + { + varinfo_t rvi = lookup_restrict_pointed_var (vi); + if (rvi != NULL) + { + make_constraint_from (vi, rvi->id); + make_restrict_var_constraints (rvi); + } + else + make_constraint_from_global_restrict (vi, "GLOBAL_RESTRICT"); + } else make_copy_constraint (vi, nonlocal_id); } -- 1.9.1