From patchwork Fri Aug 16 10:22:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 1973194 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=m3UwSX0n; 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 4WldQx3Zqkz20Bh for ; Fri, 16 Aug 2024 20:24:57 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 59E3C385DDFE for ; Fri, 16 Aug 2024 10:24:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-14.smtpout.orange.fr [80.12.242.14]) by sourceware.org (Postfix) with ESMTPS id 88D47385DDC4; Fri, 16 Aug 2024 10:22:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 88D47385DDC4 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 88D47385DDC4 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=80.12.242.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723803757; cv=none; b=Z7Z/5pqGD3i4EPReeg6/5x3IJhqxBXcA83a8PihXo2zcVrFoUqny76g07jMVVdJmiHzsmVQfZybGpdbyJnA6mUk0Ihe2LQB4FYr7D8qY0fSPTfzklxDilWgw4hR2+ayZehFJw46drVScv3hcM97Ti2eR2BamvdPKdlncmbpt6qY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1723803757; c=relaxed/simple; bh=Opkxnn84x3VQS1MVHOwzXhZJZhWWiFVWrB60ulwtqzQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=JxvnBGkNA9hrnpWO4yzvzJvh9dLyU94BtFFF/VANMgvUVKDAiObXK6HsWH+v01p0tf9OSmRi91SORSsNJm3LZtnxT0h6URG6NN8qt3pzHbry8kp2fy136nWfZdqVEfrzWdVzqzkKJP01jaMJ1lJtT3Q2Mgr66mPWDvN9iZA815o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id eu6FsXj565Qjaeu6Ls0CgL; 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=qTy4gMVA8P8ecXexAaz/ZlnMEB8uSmx5bOLzUSZHS0g=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=m3UwSX0nCp7JvmMm9ZfDS0vL/n03dlhtGCxonoidpPe9xCX3g6VyX0g9BOR0UTzPs olcJpmImqvJR+aNCl6TdELQyu44sBbALN0JLB7xI7NO/NeETPJYNaHJoSGRHusqc91 hkXqKxUu3ox+E49DfU8ftvEp1xX3MpfBfiFLltxGAFvZtxlv4ghT60D12uRP8B80xR Wb6RbCq/v0HRNECIJxgbTPgn/mFKLDrG/33mzS9x972uZfBUZ5aUigflrki24SwR0c LHSJ2uGHIBlS9xSJVDP9vETcozglYo4fSFebCeLQYqLitK3l7XUYE9NuG93Zb5ja+q 786vkyeHxhrrw== 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 04/10] fortran: Remove MINLOC/MAXLOC frontend optimization Date: Fri, 16 Aug 2024 12:22:21 +0200 Message-ID: <20240816102227.189290-5-morin-mikael@orange.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240816102227.189290-1-morin-mikael@orange.fr> References: <20240816102227.189290-1-morin-mikael@orange.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-10.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, 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 This patch is new in the V2 series. Regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- Remove the frontend pass rewriting calls of MINLOC/MAXLOC without DIM to calls with one-valued DIM enclosed in an array constructor. This transformation was circumventing the limitation of inline MINLOC/MAXLOC code generation to scalar cases only, allowing inline code to be generated if ARRAY had rank 1 and DIM was absent. As MINLOC/MAXLOC has gained support of inline code generation in that case, the limitation is no longer effective, and the transformation no longer necessary. gcc/fortran/ChangeLog: * frontend-passes.cc (optimize_minmaxloc): Remove. (optimize_expr): Remove dispatch to optimize_minmaxloc. --- gcc/fortran/frontend-passes.cc | 57 ---------------------------------- 1 file changed, 57 deletions(-) diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index 8e4c6310ba8..31d553e9844 100644 --- a/gcc/fortran/frontend-passes.cc +++ b/gcc/fortran/frontend-passes.cc @@ -36,7 +36,6 @@ static bool optimize_op (gfc_expr *); static bool optimize_comparison (gfc_expr *, gfc_intrinsic_op); static bool optimize_trim (gfc_expr *); static bool optimize_lexical_comparison (gfc_expr *); -static void optimize_minmaxloc (gfc_expr **); static bool is_empty_string (gfc_expr *e); static void doloop_warn (gfc_namespace *); static int do_intent (gfc_expr **); @@ -356,17 +355,6 @@ optimize_expr (gfc_expr **e, int *walk_subtrees ATTRIBUTE_UNUSED, if ((*e)->expr_type == EXPR_OP && optimize_op (*e)) gfc_simplify_expr (*e, 0); - if ((*e)->expr_type == EXPR_FUNCTION && (*e)->value.function.isym) - switch ((*e)->value.function.isym->id) - { - case GFC_ISYM_MINLOC: - case GFC_ISYM_MAXLOC: - optimize_minmaxloc (e); - break; - default: - break; - } - if (function_expr) count_arglist --; @@ -2262,51 +2250,6 @@ optimize_trim (gfc_expr *e) return true; } -/* Optimize minloc(b), where b is rank 1 array, into - (/ minloc(b, dim=1) /), and similarly for maxloc, - as the latter forms are expanded inline. */ - -static void -optimize_minmaxloc (gfc_expr **e) -{ - gfc_expr *fn = *e; - gfc_actual_arglist *a; - char *name, *p; - - if (fn->rank != 1 - || fn->value.function.actual == NULL - || fn->value.function.actual->expr == NULL - || fn->value.function.actual->expr->ts.type == BT_CHARACTER - || fn->value.function.actual->expr->rank != 1 - || gfc_inline_intrinsic_function_p (fn)) - return; - - *e = gfc_get_array_expr (fn->ts.type, fn->ts.kind, &fn->where); - (*e)->shape = fn->shape; - fn->rank = 0; - fn->shape = NULL; - gfc_constructor_append_expr (&(*e)->value.constructor, fn, &fn->where); - - name = XALLOCAVEC (char, strlen (fn->value.function.name) + 1); - strcpy (name, fn->value.function.name); - p = strstr (name, "loc0"); - p[3] = '1'; - fn->value.function.name = gfc_get_string ("%s", name); - if (fn->value.function.actual->next) - { - a = fn->value.function.actual->next; - gcc_assert (a->expr == NULL); - } - else - { - a = gfc_get_actual_arglist (); - fn->value.function.actual->next = a; - } - a->expr = gfc_get_constant_expr (BT_INTEGER, gfc_default_integer_kind, - &fn->where); - mpz_set_ui (a->expr->value.integer, 1); -} - /* Data package to hand down for DO loop checks in a contained procedure. */ typedef struct contained_info