From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 120226 invoked by alias); 8 Nov 2015 14:04:55 -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 120212 invoked by uid 89); 8 Nov 2015 14:04:55 -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,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; Sun, 08 Nov 2015 14:04:53 +0000 Received: from svr-orw-fem-06.mgc.mentorg.com ([147.34.97.120]) by relay1.mentorg.com with esmtp id 1ZvQaP-0005Sd-MU from Thomas_Schwinge@mentor.com ; Sun, 08 Nov 2015 06:04:49 -0800 Received: from tftp-cs (147.34.91.1) by SVR-ORW-FEM-06.mgc.mentorg.com (147.34.97.120) with Microsoft SMTP Server id 14.3.224.2; Sun, 8 Nov 2015 06:04:49 -0800 Received: by tftp-cs (Postfix, from userid 49978) id 687F4C216C; Sun, 8 Nov 2015 06:04:48 -0800 (PST) From: Thomas Schwinge To: Nathan Sidwell , GCC Patches , Tom de Vries CC: Bernd Schmidt , Richard Guenther Subject: Re: [OpenACC] internal fn folding In-Reply-To: <563B7A32.7010209@acm.org> References: <563116AC.3010108@acm.org> <56376B79.5010100@acm.org> <5639D79B.8040200@redhat.com> <563B7A32.7010209@acm.org> User-Agent: Notmuch/0.9-125-g4686d11 (http://notmuchmail.org) Emacs/24.5.1 (i586-pc-linux-gnu) Date: Sun, 08 Nov 2015 14:04:00 -0000 Message-ID: <87y4e8wpsp.fsf@kepler.schwinge.homeip.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-SW-Source: 2015-11/txt/msg00841.txt.bz2 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Content-length: 5286 Hi! On Thu, 5 Nov 2015 10:48:02 -0500, Nathan Sidwell wrote: > On 11/04/15 05:02, Bernd Schmidt wrote: > > On 11/02/2015 02:56 PM, Nathan Sidwell wrote: > >> On 10/28/15 14:40, Nathan Sidwell wrote: > >>> Richard, > >>> this patch adds folding for the new GOACC_DIM_POS and GOACC_DIM_SIZE > >>> internal > >>> functions. IIUC gimple_fold_call is the right place to add this. > >>> > >>> The size of a compute dimension is very often a compile-time > >>> constant. On the > >>> host, in particular it's 1, which means we can deduce the POS must be > >>> zero. > This is what I committed, using the helpers I recently added. (I realized= we can=20 > only get here for functions with the oacc attribute already set) > --- gimple-fold.c (revision 229809) > +++ gimple-fold.c (working copy) > +/* Transform IFN_GOACC_DIM_SIZE and IFN_GOACC_DIM_POS internal > + function calls to constants, where possible. */ > + > +static tree > +fold_internal_goacc_dim (const gimple *call) > +{ > + int axis =3D get_oacc_ifn_dim_arg (call); > + int size =3D get_oacc_fn_dim_size (current_function_decl, axis); > + bool is_pos =3D gimple_call_internal_fn (call) =3D=3D IFN_GOACC_DIM_PO= S; > + tree result =3D NULL_TREE; > + > + /* If the size is 1, or we only want the size and it is not dynamic, > + we know the answer. */ > + if (size =3D=3D 1 || (!is_pos && size)) > + { > + tree type =3D TREE_TYPE (gimple_call_lhs (call)); > + result =3D build_int_cst (type, size - is_pos); > + } > + > + return result; > +} > @@ -3106,6 +3129,10 @@ gimple_fold_call (gimple_stmt_iterator * > return true; > } > break; > + case IFN_GOACC_DIM_SIZE: > + case IFN_GOACC_DIM_POS: > + result =3D fold_internal_goacc_dim (stmt); > + break; Merging this into gomp-4_0-branch, we'd run into a lot of regressions (for OpenACC kernels construct), for example: [...]/source-gcc/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c: In = function 'main._omp_fn.0': [...]/source-gcc/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c:8:0:= internal compiler error: Segmentation fault 0xac387f crash_signal [...]/source-gcc/gcc/toplev.c:336 0x9b8399 tree_int_cst_elt_check [...]/source-gcc/gcc/tree.h:3129 0x9b8399 get_oacc_fn_dim_size(tree_node*, int) [...]/source-gcc/gcc/omp-low.c:12630 0x86c530 fold_internal_goacc_dim [...]/source-gcc/gcc/gimple-fold.c:2917 0x86c530 gimple_fold_call [...]/source-gcc/gcc/gimple-fold.c:3134 0x86dfe4 fold_stmt_1 [...]/source-gcc/gcc/gimple-fold.c:3702 0xbf9953 execute [...]/source-gcc/gcc/tree-ssa-forwprop.c:2310 The dims in gcc/omp-low.c:get_oacc_fn_dim_size don't have values set, so the "TREE_INT_CST_LOW (TREE_VALUE (dims))" fails. I have not analyzed what exactly is going wrong; I just figured out that it's related to the IFN_GOACC_DIM_POS without LHS usage that Tom introduced in gomp-4_0-branch r228735 for OpenACC kernels to "neuter gang-single code in gang-redundant mode", . So, in r229948 I merged Nathan's trunk r229816 into gomp-4_0-branch with an additional hack as indicated ("++" prefix) by the following three-way diff: commit b421a6415fc223866bc97f8248a1fbd0a524505e Merge: 7a6eb6b b0ccb4e Author: tschwinge Date: Sun Nov 8 13:49:46 2015 +0000 svn merge -r 229814:229816 svn+ssh://gcc.gnu.org/svn/gcc/trunk =20=20=20=20 =20=20=20=20 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@2299= 48 138bc75d-0d04-0410-961f-82ee72b054a4 gcc/ChangeLog | 6 ++++++ gcc/gimple-fold.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --cc gcc/gimple-fold.c index c9b9593,45840af..869c6c2 --- gcc/gimple-fold.c +++ gcc/gimple-fold.c @@@ -2906,6 -2907,28 +2907,34 @@@ gimple_fold_builtin (gimple_stmt_iterat return false; } =20=20 + /* Transform IFN_GOACC_DIM_SIZE and IFN_GOACC_DIM_POS internal + function calls to constants, where possible. */ +=20 + static tree + fold_internal_goacc_dim (const gimple *call) + { ++ /* TODO. There is something going wrong here, for the gang_single ++ IFN_GOACC_DIM_POS without LHS, generated in gcc/omp-low.c:lower_omp_= target ++ for is_oacc_kernels (see gomp-4_0-branch r228735). */ ++ if (gimple_call_lhs (call) =3D=3D NULL_TREE) ++ return NULL_TREE; ++ + int axis =3D get_oacc_ifn_dim_arg (call); + int size =3D get_oacc_fn_dim_size (current_function_decl, axis); + bool is_pos =3D gimple_call_internal_fn (call) =3D=3D IFN_GOACC_DIM_POS; + tree result =3D NULL_TREE; +=20 + /* If the size is 1, or we only want the size and it is not dynamic, + we know the answer. */ + if (size =3D=3D 1 || (!is_pos && size)) + { + tree type =3D TREE_TYPE (gimple_call_lhs (call)); + result =3D build_int_cst (type, size - is_pos); + } +=20 + return result; + } +=20 /* Return true if ARG0 CODE ARG1 in infinite signed precision operation doesn't fit into TYPE. The test for overflow should be regardless of -fwrapv, and even for unsigned types. */ Gr=C3=BC=C3=9Fe Thomas --=-=-= Content-Type: application/pgp-signature; name="signature.asc" Content-length: 472 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJWP1ZmAAoJEK3/DN1sMFFt0+QH/AlIkg49zDevly/Om+7Qt3c1 kvdDrQKUzofNdnpsIIggSHIeY+qS31xzaS9CIe2Je7+gw83utBc+nO3c3dzuZy51 WHuE72vv35d8qvwNgB0oy7rvCl/gvDisY3z8wlnsOmVcPRSjKdtQERxNQr9XNNvO T6A9B7H90tL6sTJaTStat04PVUiWbfjgD241X+4q8QpKoBeKT5aVZ4yMclh12QUZ rNUMI2AziREjY63tv6kLMp6yD4Ig8Ay5dg57nIeJrIrzwu6Q3223VKCVo8HFZ7Mx 7ylWl9h8DIO+sRMyatJkyNurZB4vXJD6NHn510K3UvEK+aiM8bTO2YiTR9QYjAk= =HeY2 -----END PGP SIGNATURE----- --=-=-=--