From patchwork Fri Aug 16 10:22:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 1973196 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=orange.fr header.i=@orange.fr header.a=rsa-sha256 header.s=t20230301 header.b=j8KUnObB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WldSN1Rt0z1yYl for ; Fri, 16 Aug 2024 20:26:12 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 67569385DDC8 for ; Fri, 16 Aug 2024 10:26:10 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from msa.smtpout.orange.fr (msa-210.smtpout.orange.fr [193.252.23.210]) by sourceware.org (Postfix) with ESMTPS id 4BAFD385C6E1; Fri, 16 Aug 2024 10:22:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4BAFD385C6E1 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=orange.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=orange.fr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4BAFD385C6E1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=193.252.23.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723803758; cv=none; b=FoJMSQp9mXwF/8QTp1IgoTfu+ojS46Duii5yV00lAX244JNUlAJ6sLf3hLL7ftv0wpcIctL6wSPRBxVEHS/BAOh8s5l5m2FE8y6gdp6g6J6emSDdkZdaLgM9hD3F12q+8Ar37T1W3rN5stqatzkcx27MuuwauoN6vflR7dS/8gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723803758; c=relaxed/simple; bh=4IndyQHe6AaOYI54RvtfxlDjRMATCSrAZDN7zlYlun8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=tE8qhgZQYuiOIpfVBtBHXpY+FHR1xBMVMijKpvGXtbTe7yldmYN5lZq1Fhe4RCly9mPiBFxbps508sYfKBA8NDCfF/xo+dPQwIFnguNgvOpnNJyqXfiA9jRJwHVzo7R3gLRUIl5TAZaE7d2FqecSD+d6M/5a5C2biNPF3j1vgiI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id eu6FsXj565Qjaeu6Ks0CgA; Fri, 16 Aug 2024 12:22:33 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1723803753; bh=zmlQTt16TnmBqr8vlTeZmZSXvrZIxcBqlSer033gUaw=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=j8KUnObBeN2Uf0LSsVz13I9Lk2Hziwtz7SFGLfAgU9s6llGV6NIr6Dsyb3B9VdmUq YZMSxFQlhI7T0/jQDNYa7JNvtkpAEhkbGHaOO9mdUCYojQdokcMErUuQc/ltAuCE+l 7KIIrvufnnxkYz5NifSey8p8hEHADymXbu3e6XWLni6yqBVTWkD2gFf2h3FRc7q1P7 IVVeOXkyhw2b9HLh/lRm9HxGPJk0a30wVTy+F87lTe3pHNYF9h/QRAF62WNdwQ1oT+ Nbqg8UKSFXcZ2y2UyHkNLbxULoBj2032k1YSj5dpJBe/vFIuQMjJ6H1IbOF++L1/ZO ezZYLntLNSpRA== X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 16 Aug 2024 12:22:33 +0200 X-ME-IP: 86.215.161.51 From: Mikael Morin To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH v2 00/10] fortran: Inline MINLOC/MAXLOC without DIM argument [PR90608] Date: Fri, 16 Aug 2024 12:22:17 +0200 Message-ID: <20240816102227.189290-1-morin-mikael@orange.fr> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: Mikael Morin Hello, this is the second version of the inline MINLOC/MAXLOC without DIM patchset whose first version was posted before at: https://gcc.gnu.org/pipermail/gcc-patches/2024-July/658909.html Appart from the NAN skipping conditional likeliness which is left unchanged, it takes into account the review comments I got so far, including the still controversial -finline-intrinsics flag. Regarding the conditional likeliness, I looked at its effect on the generated assembly for minmaxloc_18, and I really can't tell which is better just from the look of it. I prefer to not touch that part. Patches 4 (minmaxloc frontend pass removal) and 10 (-finline-intrinsics flag) are new, and patch 1 (tests) has been modified to move the NAN tests to a separate file and use the ieee_arithmetic intrinsic module. The rest of the patches are rebased versions of the previously posted patches. Details below and in the patches themselves. This series of patches enable the generation of inline code for the MINLOC and MAXLOC intrinsics, when the DIM argument is not present. The generated code is based on the inline implementation already generated in the scalar case, that is when ARRAY has rank 1 and DIM is present. The code is extended by using several variables (one for each dimension) where the scalar code used just one, and collecting the variables to an array before returning. The patches are split in a way that allows inlining in more and more cases as controlled by the gfc_inline_intrinsic_p predicate which evolves with the patches. Changes from V1: - In patch 1/10, use intrinsic ieee_arithmetic module to get NAN values in tests. This required to split the tests using ieee_arithmetic to a separate file in the ieee/ subdirectory. - Add patch 4/10 removing the frontend minmaxloc pass. - Add patch 10/10 adding -finline-intrinsics flag to control MINLOC/MAXLOC inlining from the command line. Mikael Morin (10): fortran: Add tests covering inline MINLOC/MAXLOC without DIM [PR90608] fortran: Disable frontend passes for inlinable MINLOC/MAXLOC [PR90608] fortran: Inline MINLOC/MAXLOC with no DIM and ARRAY of rank 1 [PR90608] fortran: Remove MINLOC/MAXLOC frontend optimization fortran: Outline array bound check generation code fortran: Inline integral MINLOC/MAXLOC with no DIM and no MASK [PR90608] fortran: Inline integral MINLOC/MAXLOC with no DIM and scalar MASK [PR90608] fortran: Inline non-character MINLOC/MAXLOC with no DIM [PR90608] fortran: Continue MINLOC/MAXLOC second loop where the first stopped [PR90608] fortran: Add -finline-intrinsics flag for MINLOC/MAXLOC [PR90608] gcc/flag-types.h | 30 + gcc/fortran/frontend-passes.cc | 56 -- gcc/fortran/invoke.texi | 24 + gcc/fortran/lang.opt | 27 + gcc/fortran/options.cc | 21 +- gcc/fortran/trans-array.cc | 382 +++++---- gcc/fortran/trans-intrinsic.cc | 489 ++++++++--- .../gfortran.dg/ieee/maxloc_nan_1.f90 | 44 + .../gfortran.dg/ieee/minloc_nan_1.f90 | 44 + gcc/testsuite/gfortran.dg/maxloc_7.f90 | 208 +++++ gcc/testsuite/gfortran.dg/maxloc_bounds_4.f90 | 4 +- gcc/testsuite/gfortran.dg/maxloc_bounds_5.f90 | 4 +- gcc/testsuite/gfortran.dg/maxloc_bounds_6.f90 | 4 +- gcc/testsuite/gfortran.dg/maxloc_bounds_7.f90 | 4 +- .../gfortran.dg/maxloc_with_mask_1.f90 | 373 +++++++++ gcc/testsuite/gfortran.dg/minloc_8.f90 | 208 +++++ .../gfortran.dg/minloc_with_mask_1.f90 | 372 +++++++++ gcc/testsuite/gfortran.dg/minmaxloc_18.f90 | 772 ++++++++++++++++++ gcc/testsuite/gfortran.dg/minmaxloc_18a.f90 | 10 + gcc/testsuite/gfortran.dg/minmaxloc_18b.f90 | 10 + gcc/testsuite/gfortran.dg/minmaxloc_18c.f90 | 10 + gcc/testsuite/gfortran.dg/minmaxloc_18d.f90 | 10 + 22 files changed, 2760 insertions(+), 346 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/ieee/maxloc_nan_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/ieee/minloc_nan_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_7.f90 create mode 100644 gcc/testsuite/gfortran.dg/maxloc_with_mask_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/minloc_8.f90 create mode 100644 gcc/testsuite/gfortran.dg/minloc_with_mask_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18.f90 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18a.f90 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18b.f90 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18c.f90 create mode 100644 gcc/testsuite/gfortran.dg/minmaxloc_18d.f90