From patchwork Fri Jul 7 18:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harald Anlauf X-Patchwork-Id: 117241 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp3463324vqx; Fri, 7 Jul 2023 11:33:07 -0700 (PDT) X-Google-Smtp-Source: APBJJlGhJaJ8EYRNeqJ/sDWKOKzFQY5rkNmv6LArWNPgqlNaH4PmdhnKa+XvLotsuFlFryt981jo X-Received: by 2002:a17:906:7395:b0:98c:8694:9525 with SMTP id f21-20020a170906739500b0098c86949525mr5198845ejl.4.1688754786743; Fri, 07 Jul 2023 11:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688754786; cv=none; d=google.com; s=arc-20160816; b=YcKjqflEh6y9tl5DqXdDpwFTrm6jlahqIQ5yr3FAvxMbUFEzovReDoLj126+EQUDhZ CxZaYwax8zAGSd0hN9RZYrV1LJIBTYY8HIyxgimtwjpVoIKzpIFSTgq55Clow1mpjzeg qNWaS53i7nTT3PXAemtktnSj0v5PI0MSmto5t65NaByzMEDJPU7Glv1PVfWJeTYz439o eXs72g5TNGMjaAQ47rEALWC142HCPA+rY4VuV5md4cYq9VZaWgank13ue3prpux+YmPy v6rUAKKN+HX/bQ6Gkjo3vNJO7vmiv/JUxXMdiICXhbeqU1oLRvqJLbZIg4mP5G9bFFvy rIpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:ui-outboundreport :sensitivity:importance:date:subject:to:message-id:mime-version :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=GMpVG52H3aB3cGBVr5pEuxQ2OPlj14YTZF17wlAhxHU=; fh=QK0YdXSiSCa48e9o4Ff7k6xpBN/ax2bSUZqWzYlsl7Q=; b=n9y60XfsYcGQSTsBoalwOVsVWBzNj1WdeScBdlflVYWy+eTkeEOk4DXVU0Jriq26KM hTaiFDwTcyGhmpxaraCMRz5uTyidawR9CIUBt7drinf9gVOB5AiXkrbqXWJIMHLbI9l3 HEJUBbx84yByI9O1O3MavuQ83cP8u9kyV7flrHaEUCtPryiatFSntys0usIsGU8rPce6 KOwx2zXjxRhwIgv6tJGL/ia2yJ6g6f12WKnwHl2ARafKZxykc0JNMbUK+IfwHlo2e3EK Mxu24KpUzw8sZd0OwbPyBNRuwZr4YBTw0WWhSWoCo6SoVzVrNS3XFRSzkYG/OXvGLOWI uFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Rx5ffa/C"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id v26-20020a17090606da00b00992e0f4e861si2528158ejb.236.2023.07.07.11.33.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jul 2023 11:33:06 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="Rx5ffa/C"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A42173865C15 for ; Fri, 7 Jul 2023 18:33:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A42173865C15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688754785; bh=GMpVG52H3aB3cGBVr5pEuxQ2OPlj14YTZF17wlAhxHU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Rx5ffa/CDft9YMB/YTFHafgfiWQUVDJYkPYmU2y/lnRy+/dtpSKRocNqno/i5VR79 1wOaZ6cMHf7ei3LmXX+xHi5fYPtM80uRlK6gqnMMwFzwe3cBiR5frQrZvTVKJPGs8J g59Hb/o4sH6I304fe3wgkaEUrNCqmhnKVw3FYRJk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by sourceware.org (Postfix) with ESMTPS id 4AE37385703D; Fri, 7 Jul 2023 18:32:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4AE37385703D X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [93.207.83.196] ([93.207.83.196]) by web-mail.gmx.net (3c-app-gmx-bs47.server.lan [172.19.170.99]) (via HTTP); Fri, 7 Jul 2023 20:32:20 +0200 MIME-Version: 1.0 Message-ID: To: fortran , gcc-patches Subject: [PATCH] Fortran: simplification of FINDLOC for constant complex arguments [PR110585] Date: Fri, 7 Jul 2023 20:32:20 +0200 Importance: normal Sensitivity: Normal X-Priority: 3 X-Provags-ID: V03:K1:kjOo/b9oTUj5N//MILsfQKzsnHyLjTU1u9nSsiY8kQ1RVheIfT5+Fis1VMm1o5GK3Wkox glgpYSViGu+LwYjvTsC3exURPAApdiIHYVpe0d8w198yMehJadqSlHJN4d4bsEPrAkwdxK03rIyT GDSpfSeN8AYVWmZwtxyo57eO+JwcHWXkB1WB6eZxNxxcOeVdKuEB8LYCcuH9/c2JjAQefOton9yS TY7k694aW6gVS9mT8mYXjXowzVZtznIUNTdtBUvCT0A9K83rIpRpvN/e+NoCTCdYN3IC+ZxcZTrl sU= UI-OutboundReport: notjunk:1;M01:P0:9yVKBkPYwt0=;Krd4FiHesU0fR3MpFtE4Y+DtDa7 Wyk/ttpEwORHkoPOa6hsfLDXdmE20mFQYnoOV+Q9blYPA/jmW+Hq3DJ1Xc3ZA+VLbnLKkzfzK RLm9QoHofMH91Y0BJkQYe7P2LgHmY+sxYwgqBib5OjcobQGoA3l4L/7hR2MgaMlxO5uBm6pae qZhfGEV1LcZjY49X/wZVwrVqXOsRoW9VsZ3EmPcm8QGGGyHrwWGa33bubmS+2rfWPEdG/+uLj 1LuBOnQE1uthqPOp83MYHpx7n++3opI7BAfyhlTRGx5pA2KaGUrhQ75dyTbYRpzDACW13AvK5 cD1pr2UdXnR8Yhj+un1EEJ3yHOiMDLWh612LSJSQHxs9ses39nD/7yuY1C2yMvbqRDXCW2ffC LdKg1bAWqn51CGm1haE40lwXmitsZWZH/vJufu8fRNjDCKUUwuoyUgpVvsf4ZDRU7ggyU55kK HSRZ7kHtM4FczI3LnGXkZ54msUHC0BVRDMvmgguLLQtFJ7dUcmT8XSiCqK/HX/ABB06F0ltFE exyBUC4QIPeCSAkv4T99oQwJlUTGV/WCRPyhhRpqCykglZ6PRAvu+396ZYu+EgaLNhm1b/w9T xdmULNgW4mfldeFOkQhesBqglSzYy94D9CZWZrFH3Q7FQJrQQi4YekULBYR7JEYsf4Zzqdrpm U5Gc59l/wD1veiEsLvX2zyF7tnPSs1dnjV1T83pyN549WH0Qh4Thc03VVyQhxRINIiqAh/SK9 wENxw75IdQLyGW84rnug9jAO5i8BqOFWf/rC7W65tzpkMYiapvoPek75gb9qvj6y6356afqPb 78L+gRCzuG5LLqZ+4blGO0lQ== X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Harald Anlauf via Gcc-patches From: Harald Anlauf Reply-To: Harald Anlauf Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770787739077028372?= X-GMAIL-MSGID: =?utf-8?q?1770787739077028372?= Dear all, I intend to commit the attached obvious patch within 24h unless someone objects. gfc_compare_expr() did not handle the case of complex constants, which may be compared for equality. This case is needed in the simplification of the FINDLOC intrinsic. Regtested on x86_64-pc-linux-gnu. Thanks, Harald From b6c4f70d2dac4863335874f0bd3486ea7db348d7 Mon Sep 17 00:00:00 2001 From: Harald Anlauf Date: Fri, 7 Jul 2023 20:25:06 +0200 Subject: [PATCH] Fortran: simplification of FINDLOC for constant complex arguments [PR110585] gcc/fortran/ChangeLog: PR fortran/110585 * arith.cc (gfc_compare_expr): Handle equality comparison of constant complex gfc_expr arguments. gcc/testsuite/ChangeLog: PR fortran/110585 * gfortran.dg/findloc_9.f90: New test. --- gcc/fortran/arith.cc | 5 +++++ gcc/testsuite/gfortran.dg/findloc_9.f90 | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/findloc_9.f90 diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc index 86d56406047..f9c6658f860 100644 --- a/gcc/fortran/arith.cc +++ b/gcc/fortran/arith.cc @@ -1120,6 +1120,11 @@ gfc_compare_expr (gfc_expr *op1, gfc_expr *op2, gfc_intrinsic_op op) || (op1->value.logical && !op2->value.logical)); break; + case BT_COMPLEX: + gcc_assert (op == INTRINSIC_EQ); + rc = mpc_cmp (op1->value.complex, op2->value.complex); + break; + default: gfc_internal_error ("gfc_compare_expr(): Bad basic type"); } diff --git a/gcc/testsuite/gfortran.dg/findloc_9.f90 b/gcc/testsuite/gfortran.dg/findloc_9.f90 new file mode 100644 index 00000000000..05974476cb3 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/findloc_9.f90 @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-options "-fdump-tree-original" } +! PR fortran/110585 - simplification of FINDLOC for constant complex arguments + +program mvce + implicit none + integer, parameter :: a(*) = findloc([(1.,0.),(2.,1.)], (2.,0.)) + integer, parameter :: b(*) = findloc([(1.,0.),(2.,1.)], (2.,0.), back=.true.) + integer, parameter :: c(*) = findloc([(1.,0.),(2.,1.)], (2.,1.)) + integer, parameter :: d(*) = findloc([(1.,0.),(2.,1.)], (2.,1.), back=.true.) + integer, parameter :: e = findloc([(1.,0.),(2.,1.)], (2.,1.), dim=1) + if (a(1) /= 0) stop 1 + if (b(1) /= 0) stop 2 + if (c(1) /= 2) stop 3 + if (d(1) /= 2) stop 4 + if (e /= 2) stop 5 +end + +! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } } -- 2.35.3