From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108711 invoked by alias); 31 Oct 2015 09:44:47 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 108699 invoked by uid 89); 31 Oct 2015 09:44:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 31 Oct 2015 09:44:45 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36520) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZsSiJ-0000Xj-D8 for gcc-patches@gnu.org; Sat, 31 Oct 2015 05:44:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZsSiD-0000or-Ma for gcc-patches@gnu.org; Sat, 31 Oct 2015 05:44:42 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:47662) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZsSiD-0000on-EM for gcc-patches@gnu.org; Sat, 31 Oct 2015 05:44:37 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZsSiB-0005nB-Ls from Tom_deVries@mentor.com ; Sat, 31 Oct 2015 02:44:35 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Sat, 31 Oct 2015 09:44:28 +0000 Subject: [committed] Tune pointer-plus folding To: Richard Biener References: <5631F735.2080604@mentor.com> <56333152.7040403@mentor.com> CC: Jakub Jelinek , "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <56348D75.4040006@mentor.com> Date: Sat, 31 Oct 2015 10:24:00 -0000 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: Content-Type: multipart/mixed; boundary="------------050603010305020007070906" X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 X-SW-Source: 2015-10/txt/msg03477.txt.bz2 --------------050603010305020007070906 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 778 [ was: Re: [PATCH] Allow more pointer-plus folding ] On 30/10/15 10:24, Richard Biener wrote: >>> I think the checks on TREE_OPERAND (arg0, 1) are bogus though >>> >>and either we should unconditionally sink the conversion or only >>> >>if a conversion on TREE_OPERAND (arg0, 0) vanishes (I prefer the >>> >>latter). >>> >> >> > >> >Like this? OK for trunk if bootstrap/reg-test succeeds? > Ok with using CONVERT_EXPR_P (TREE_OPERAND (arg0, 0)) instead of > an explicit NOP_EXPR check. Committed to trunk as attached, with: - fold-const.c comment updated, and - two test-cases updated (where we do less folding than before). And I've changed the title of the commit since although we do allow more folding in some cases, we allow less folding in other cases. Thanks, - Tom --------------050603010305020007070906 Content-Type: text/x-patch; name="0001-Tune-pointer-plus-folding.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="0001-Tune-pointer-plus-folding.patch" Content-length: 3526 Tune pointer-plus folding 2015-10-30 Tom de Vries * fold-const.c (fold_unary_loc): Tune POINTER_PLUS_EXPR folding. * gfortran.dg/assumed_type_2.f90: Update test. * gfortran.dg/no_arg_check_2.f90: Same. --- gcc/fold-const.c | 10 ++++------ gcc/testsuite/gfortran.dg/assumed_type_2.f90 | 2 +- gcc/testsuite/gfortran.dg/no_arg_check_2.f90 | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/gcc/fold-const.c b/gcc/fold-const.c index b9168f3..197ccfd 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -7755,14 +7755,12 @@ fold_unary_loc (location_t loc, enum tree_code code, tree type, tree op0) } } - /* Convert (T1)(X p+ Y) into ((T1)X p+ Y), for pointer type, - when one of the new casts will fold away. Conservatively we assume - that this happens when X or Y is NOP_EXPR or Y is INTEGER_CST. */ + /* Convert (T1)(X p+ Y) into ((T1)X p+ Y), for pointer type, when the new + cast (T1)X will fold away. We assume that this happens when X itself + is a cast. */ if (POINTER_TYPE_P (type) && TREE_CODE (arg0) == POINTER_PLUS_EXPR - && (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST - || TREE_CODE (TREE_OPERAND (arg0, 0)) == NOP_EXPR - || TREE_CODE (TREE_OPERAND (arg0, 1)) == NOP_EXPR)) + && CONVERT_EXPR_P (TREE_OPERAND (arg0, 0))) { tree arg00 = TREE_OPERAND (arg0, 0); tree arg01 = TREE_OPERAND (arg0, 1); diff --git a/gcc/testsuite/gfortran.dg/assumed_type_2.f90 b/gcc/testsuite/gfortran.dg/assumed_type_2.f90 index ec51b8b..f1a2074 100644 --- a/gcc/testsuite/gfortran.dg/assumed_type_2.f90 +++ b/gcc/testsuite/gfortran.dg/assumed_type_2.f90 @@ -155,7 +155,7 @@ end ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t2.0:. . restrict\\) array_t2_alloc.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t3.0:. .\\) array_t3_ptr.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_alloc._data.data" 1 "original" } } -! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_ptr._data.dat" 1 "original" } }a +! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) \\(array_class_t1_ptr._data.dat" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(D" 3 "original" } } ! { dg-final { scan-tree-dump-times " = _gfortran_internal_pack \\(&parm" 1 "original" } } diff --git a/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 b/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 index 3645ded..b3fb468 100644 --- a/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 +++ b/gcc/testsuite/gfortran.dg/no_arg_check_2.f90 @@ -137,7 +137,7 @@ end ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t2.0:. . restrict\\) array_t2_alloc.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .&\\(.\\(struct t3.0:. .\\) array_t3_ptr.data" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_alloc._data.data" 1 "original" } } -! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) array_class_t1_ptr._data.dat" 1 "original" } }a +! { dg-final { scan-tree-dump-times "sub_scalar .\\(struct t1 .\\) \\(array_class_t1_ptr._data.dat" 1 "original" } } ! { dg-final { scan-tree-dump-times "sub_array_assumed \\(D" 3 "original" } } ! { dg-final { scan-tree-dump-times " = _gfortran_internal_pack \\(&parm" 1 "original" } } -- 1.9.1 --------------050603010305020007070906--