From patchwork Mon Oct 14 15:08:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikael Morin X-Patchwork-Id: 1997023 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=kHVpNV6y; 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 4XS0z14HzPz1xvK for ; Tue, 15 Oct 2024 02:10:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C3EC7385AE49 for ; Mon, 14 Oct 2024 15:10:19 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by sourceware.org (Postfix) with ESMTPS id 82FD3385AC3C; Mon, 14 Oct 2024 15:08:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 82FD3385AC3C 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 82FD3385AC3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=80.12.242.18 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728918521; cv=none; b=gp7d4eAp/HWZnblIg+kYdPy/Xn5F+RQuZle6XUHpEwN9aq//utoAD3IJiEnNhzCWlKrnwpbDGyVBy0Or3op7qz2ckryy8UR57AZ7IomqBXuJzve3+YemLrCMJMEqtdHsGZ/C5wtg7taAiEfFpAffm9i0WAdvOLcqlnLSJs8BB+o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728918521; c=relaxed/simple; bh=NubofL/RQwzhuY0zrfcB1kwv+pNnyn+v8Eh3g26ox2k=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jekuZI4vQBfVT+JlacC8+ZTn8pXQmJVq9E6AVHbhIAP3H3hDc4K33OO81oVaaI9uBmrhNEsiFNL/XbSFe12aoyCTNhn+YMmHGDLZ8snyfdRjTkPSvApxpcA9aInE+PZ6A1YfTNnt0PJsJeaphp8wNjMJFr0bzjNJl3RV2IVfxVs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from cyrano.home ([86.215.161.51]) by smtp.orange.fr with ESMTPA id 0MgBtHlyUIPG80MgPtVhKr; Mon, 14 Oct 2024 17:08:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=orange.fr; s=t20230301; t=1728918509; bh=w6ioXazkxgseMi4DEzDbSQCWGoG2dZznm+oIhInJG5o=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=kHVpNV6yKmpLQwQKbYTxL98QRDf6NjQjTnCf52v4BxZ+aInxLltJY3wZ6klH90SFG FPNnwHS3NesvOE4E/tcgTjc7XCB9UcVgU/LSyEMl75010s0P088lGzwgKTcIg7rvwe tIiN7ny/P+eClt3FYDuFk5B8JJ0ApjJwtWVXJc5ZXu8gKd+gqJWwD6AeqkWust0OAC VOs7dCha5v5yxlUcqBUTNTwoPVD6DEgsJArtTvmS8j12tamD8+S/wF6I9z4F10atVM AF9XqO8XAeoce94OlpV7Kx/1DBH+z9+HLYI/c5XqHiHjMPZXW/CAdw4KvQO8s+AmT2 oqmU362tIrCiQ== X-ME-Helo: cyrano.home X-ME-Auth: bW9yaW4tbWlrYWVsQG9yYW5nZS5mcg== X-ME-Date: Mon, 14 Oct 2024 17:08:29 +0200 X-ME-IP: 86.215.161.51 From: Mikael Morin To: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org Subject: [PATCH 4/7] fortran: Check MASK directly instead of its scalarization chain Date: Mon, 14 Oct 2024 17:08:13 +0200 Message-ID: <20241014150816.315478-5-morin-mikael@orange.fr> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241014150816.315478-1-morin-mikael@orange.fr> References: <20241014150816.315478-1-morin-mikael@orange.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP 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 Bootstrapped and regression-tested on x86_64-pc-linux-gnu. OK for master? -- >8 -- Update the conditions used by the inline MINLOC/MAXLOC code generation function to check directly the properties of MASK instead of the variable holding its scalarization chain. The inline implementation of MINLOC/MAXLOC in gfc_conv_intrinsic_minmaxloc uses several conditions checking the presence of a scalarization chain for MASK, which means that the argument is present and non-scalar. The next patch will allow inlining MINLOC/MAXLOC with DIM and MASK, and in that case the scalarization chain for MASK is initialized elsewhere, so the variable usually holding it in the function is not used, and the conditions won't work in that case. This change updates the conditions to check directly the properties of MASK so that they work even if the scalarization chain variable is not used. gcc/fortran/ChangeLog: * trans-intrinsic.cc (gfc_conv_intrinsic_minmaxloc): Use conditionals based on the MASK expression rather than on its scalarization chains. --- gcc/fortran/trans-intrinsic.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gcc/fortran/trans-intrinsic.cc b/gcc/fortran/trans-intrinsic.cc index 29f17f334a3..0ac3d7fe3a1 100644 --- a/gcc/fortran/trans-intrinsic.cc +++ b/gcc/fortran/trans-intrinsic.cc @@ -5746,7 +5746,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gcc_assert (reduction_dimensions == ploop->dimen); - if (nonempty == NULL && maskss == NULL) + if (nonempty == NULL && !(maskexpr && maskexpr->rank > 0)) { nonempty = logical_true_node; @@ -5816,7 +5816,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_start_scalarized_body (ploop, &body); /* If we have a mask, only check this element if the mask is set. */ - if (maskss) + if (maskexpr && maskexpr->rank > 0) { gcc_assert (!nested_loop); gfc_init_se (&maskse, NULL); @@ -5921,7 +5921,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) } gfc_add_expr_to_block (&block, ifbody); - if (maskss) + if (maskexpr && maskexpr->rank > 0) { /* We enclose the above in if (mask) {...}. If the mask is an optional argument, generate IF (.NOT. PRESENT(MASK) @@ -5972,7 +5972,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_add_expr_to_block (outer_block, build1_v (LABEL_EXPR, lab1)); /* If we have a mask, only check this element if the mask is set. */ - if (maskss) + if (maskexpr && maskexpr->rank > 0) { gfc_init_se (&maskse, NULL); gfc_copy_loopinfo_to_se (&maskse, &loop); @@ -6038,7 +6038,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_add_expr_to_block (&block, tmp); - if (maskss) + if (maskexpr && maskexpr->rank > 0) { /* We enclose the above in if (mask) {...}. If the mask is an optional argument, generate IF (.NOT. PRESENT(MASK) @@ -6063,7 +6063,7 @@ gfc_conv_intrinsic_minmaxloc (gfc_se * se, gfc_expr * expr, enum tree_code op) gfc_add_expr_to_block (&loop.pre, build1_v (LABEL_EXPR, lab2)); /* For a scalar mask, enclose the loop in an if statement. */ - if (maskexpr && maskss == NULL) + if (maskexpr && maskexpr->rank == 0) { tree ifmask;