From patchwork Fri Aug 23 08:31:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 1975919 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=hUKu4EKo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; 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 [IPv6:2620:52:3:1:0:246e:9693:128c]) (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 4Wqtbx6tRMz1yNm for ; Fri, 23 Aug 2024 18:32:29 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C9B3E38708C9 for ; Fri, 23 Aug 2024 08:32:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from msa.smtpout.orange.fr (smtp-70.smtpout.orange.fr [80.12.242.70]) by sourceware.org (Postfix) with ESMTPS id 096743875447; Fri, 23 Aug 2024 08:31:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 096743875447 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 096743875447 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=80.12.242.70 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724401919; cv=none; b=VrBl/gU8sy159mCcZ71Xa0a+dax8lQhdOB2nbU6/U++ymGs+C4O++wp+/khlZlS8vKQzjAUgHbxXHx92e2dMqCspQip3vfMDBNl1FMHhHvh4N3sfsm06Rmwr/oSK/JLkLanWqLWHQI4irZ/EdKOjTfUBj0WvJ6o3oEYGSutV6xo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724401919; c=relaxed/simple; bh=E7yp3poGl/lViSW4QFmVjfFcGZRbI1veA/mP8UqIhyM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=F0F5uUFvjZZrNobsdIozbyR6X5aPaATnif7fBmsl+toE70Z+QAjcMUvRDUABqwLgsPOtwfPL7Fv0p+dXsEkp3tp349x+m3zVNYEgpcuh1jSK6wFi1IBFQDYpMqOpdfbwSHjMRVvUJMkU6V9Qiw/Kn5kaENxqqTXNw5ofeJoWs1w= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id hPi1srBoShYnYhPi7sjylA; Fri, 23 Aug 2024 10:31:55 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1724401915; bh=PQLbbM5Vk/ygGr5YkD7vkao2klnrlu+hv7gHs4SjBGA=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=hUKu4EKoFjJsM0v1WZsOeg3x1TAX779CvPaJfX4NhO+pEmeBmipTZ9iAfe+5jDkVE FUOBKlOtiJlHssitX0PKxSQYQox0Yn4soqzgPuNYhhiORjxNzHGa9IZIjrKZgxXsvG 3VwkGqoVymC4OVfaEcYJHyaOgwwhN9Lq/ElD0JvoK9/5exRCtu3KGC4WOAIIpj71LX 1dsyNT/xyK3W8ZihL8rEn4RJQiy6oMVvC5l5XflD3jZNXwH+5FP1XdQn3Fy5RYMwaz sRo0LtTV9t1b8U5emFVVnw8v6HqItl8Rv8cm+MP5WU8bsGAmRDXA+Q9A3+VBbXkIzy 3lejgk48pXxBQ== X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 23 Aug 2024 10:31:55 +0200 X-ME-IP: 86.215.161.51 From: Mikael Morin To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH v3 00/10] fortran: Inline MINLOC/MAXLOC without DIM argument [PR90608] Date: Fri, 23 Aug 2024 10:31:40 +0200 Message-ID: <20240823083150.149099-1-morin-mikael@orange.fr> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 third version of the inline MINLOC/MAXLOC without DIM patchset whose second version was posted before at: https://gcc.gnu.org/pipermail/gcc-patches/2024-August/660599.html Compared to the previous version, it contains a change of wording of the documentation in patch 10. The rest is rebased on a recent master without any other change (as announced by Harald, there was a minor conflict for patch 4/10 as a result of Andre's corank patch). I need a ack for the newly added option in patch 10. 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. The last patch (10/10) adds a flag to control inlining from the command line. v2 -> v3 changes: - In patch 10/10, rework the documentation: Add a summary statement as first sentence of the new flag documentation. Reword the documentation of the flag limitations to omit the ambiguous "scalar" qualification of intrinsic function results. Incorporate the sentence suggested during review. v1 -> v2 changes: - 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 | 57 -- gcc/fortran/invoke.texi | 31 + 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, 2767 insertions(+), 347 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