From patchwork Fri Aug 23 08:31:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 1975923 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=pJTRZvWT; 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 4WqtcZ6j1Rz1yNm for ; Fri, 23 Aug 2024 18:33:02 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1422388211C for ; Fri, 23 Aug 2024 08:33:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from msa.smtpout.orange.fr (out-68.smtpout.orange.fr [193.252.22.68]) by sourceware.org (Postfix) with ESMTPS id 7BE47386F82C; Fri, 23 Aug 2024 08:31:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7BE47386F82C 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 7BE47386F82C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=193.252.22.68 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724401919; cv=none; b=SR3L/c3dpjRPh85zSiB0A2Wzo6mCJJgRt+l0uq8SNmdim+FkzRa5onXMNKf0yk/wLowRK+fhpjsHolC5zVitnaCUv2r2U2sH1RIUavM7URdW2Ag4DG7udHk2qalu0n+GdIv3fGx2HbpFZlws3DGgZgXO8395XdVtZmXsTUYIqE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1724401919; c=relaxed/simple; bh=nxEIIjvuo7LGZiH4tbdy4kC+yx7wLCZ1LdcNVE3B+DI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=W30KZrjlvtGxIGibwmPepS0SMdpr6FTc7CuJGTxGRNguYy3QzDfVTpifttYnMIo4PSufO28ODQjvZ7fck06jbHfPulrGhz/QioEJZx70ClgPoEoIRRC5qt2kz5RStE+JzSfQdtO70L3oJ4bexg7NVyNGjW3bxvuW+LeF6Vt36PE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id hPi1srBoShYnYhPi8sjylr; Fri, 23 Aug 2024 10:31:56 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1724401916; bh=hkih2jMYnngVl+ERg+2VZKENHlvFyHHeHPbnpPC+HTg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=pJTRZvWTnpWQKrZzTBFQ153Dkx1fGolYULtsggGSTsbI0/OAFp3rR+0qbnv7LzMl9 GJmQxJh5qjlkv/pksVKJ1xPOVo+c7nVTxRfP0vDs2jdUSwyTaGxr4nOY5Q5Lxm2jdx 8Kun99K5La+xjg/vyF8Hqsm6nkmGFDLYptsgyppULQs6y1LOAysD05v3ohE7Cxo1wv iQVrOFnHVj6uKKfbXHrk/KaNfSY/IieVwuxCElX6HYIzLiCD5l8URj4h52s0GkHVqs 99guYyJvxEcIElgZc+kYVKBFE05l+vhyvWQCUyXLkTlx4sPALc6jT1zx6uZDDPTvHF E63E75IdXp/Xg== X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Fri, 23 Aug 2024 10:31:56 +0200 X-ME-IP: 86.215.161.51 From: Mikael Morin To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH v3 04/10] fortran: Remove MINLOC/MAXLOC frontend optimization Date: Fri, 23 Aug 2024 10:31:44 +0200 Message-ID: <20240823083150.149099-5-morin-mikael@orange.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240823083150.149099-1-morin-mikael@orange.fr> References: <20240823083150.149099-1-morin-mikael@orange.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-10.4 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 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 | 58 ---------------------------------- 1 file changed, 58 deletions(-) diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc index f7f49eea617..c7cb9d2a389 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 --; @@ -2266,52 +2254,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->corank = 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