From patchwork Thu Feb 9 08:56:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 54804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp218715wrn; Thu, 9 Feb 2023 00:57:11 -0800 (PST) X-Google-Smtp-Source: AK7set+6pOa6lqtfnA1gM3SQgYDDtV9GfBNHphVVLq3Cm7wLtRFDsxAuwIYKsWnkUGjfuGYg2WHG X-Received: by 2002:a17:906:fe41:b0:8aa:12c2:5ef2 with SMTP id wz1-20020a170906fe4100b008aa12c25ef2mr13273337ejb.13.1675933031560; Thu, 09 Feb 2023 00:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675933031; cv=none; d=google.com; s=arc-20160816; b=dkpPnoOYjR0v2WVQz1IIP4nEzS8rOvioLoiaNuHyONASOF1OCt6tzhs9F14rchjcyf f0ZVq52WxVye2OvQwhHRfVOtWxwRVddly/qebU6dLUgKKPkFvIrzwsq99HMXKYKtF+4A ltcvvsfXKEknZTjSZ2vv28nYoAqCaI7uMjGSU0wXU5y5/ghorhf+0QGI5/HG0vNXcB98 77TVACLaUzu9IbD8ooI7aeW0iKKR9XagVb+/iHVVO4XbouODZD8eOP5p+MdozpAggWB2 CxI8EXix5M5Hg9rJKTILmn6vALACk8XBoivQ1G9ilf4WtGC0nL/KlNCx0Zkqnt4MP7U1 dqlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:from:to :content-language:user-agent:mime-version:date:message-id :ironport-sdr:dmarc-filter:delivered-to; bh=vc8B9hpFeVehIqxeqMIZy93/mUH8n1/9Xy/CGRsiI+Q=; b=osunhQhVYiSsrkkI5e5hpg64QcZpq8IHOt+l5DIkP/9VL2RTI85aKqdEZLsANoxMcY Zqo4pXLEy/xTi1wY6nyX7G4ENtX3eRyEMw5HMrPVZbTAsRmZUN/CmhVPQyoaofWxtVtg HUBJcUh/ACbHX206IOejdQMC5pIGVoHk1vf4S982Qo1DhPJdjZT2tnFLstYET2h50XMO o8ioOhfN8XPB6V2PGYPARPIXTSb7PU7Xi7nzURilzeeY+0A871FCt5iQRVBtncED9JSX pkLJNN3mR55G8Ex4hjn005Pdt6PyNHWhvf+Rf7nT/qUFGebYzm5y+N/OAK7vVPX9BdzI csig== ARC-Authentication-Results: i=1; mx.google.com; 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" Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fe20-20020a1709072a5400b0087f8b529f1asi1720948ejc.611.2023.02.09.00.57.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Feb 2023 00:57:11 -0800 (PST) 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; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EA7F03857C43 for ; Thu, 9 Feb 2023 08:56:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 293863858C50; Thu, 9 Feb 2023 08:56:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 293863858C50 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.97,283,1669104000"; d="diff'?scan'208";a="96326098" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 09 Feb 2023 00:56:13 -0800 IronPort-SDR: dwJ/lJxFUoyyIIJXhMMoeZ6cwwejCtpGkLdRvZRGv9HW5k7s8Mh0dQJ0wlDRQYQuzysKfd3nc+ C5BDVve5+ikXoAlWO57vnJBRF7RrSSjv8nGjcM18WYOTTecfDZZgKrmtQ93Wmers8qCZ2bF6rx gIaD5WhESR0G1+o3syhKA/O3JE+4X5ODeUJymx8Zn5sadwLc0QXD2uoCOn9IOdfT8zU18Z9JNU i/oIvGZyAqzdWTxk0YEUP4R8jHROBydc2EP69dgKZaBRjSPsqMf2oHU5T/Z9DGdOtomWMgfMs0 K7U= Message-ID: <026d0b0c-bd42-1939-e500-f1f9b2676825@codesourcery.com> Date: Thu, 9 Feb 2023 09:56:09 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.2 Content-Language: en-US To: gcc-patches , Jakub Jelinek , fortran From: Tobias Burnus Subject: [Patch] Fortran/OpenMP: Fix -fopenmp-simd for 'omp assume(s)' X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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?1757343154640966931?= X-GMAIL-MSGID: =?utf-8?q?1757343154640966931?= Found by chance recently; I thought about a couple of ways to handle it but then settled to the proposed solution. OK for mainline? Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 Fortran/OpenMP: Fix -fopenmp-simd for 'omp assume(s)' While 'omp assume' is enabled by -fopenmp-simd, 'omp assumes' is not; however, due to the way parsing works in Fortran (esp. for fixed-form source code), 'assumes' was parsed by 'assume' which then stumbled over the tailing 's'. gcc/fortran/ * parse.cc (decode_omp_directive): Really ignore 'assumes' with -fopenmp-simd. gcc/testsuite/ * gfortran.dg/gomp/openmp-simd-8.f90: New test. gcc/fortran/parse.cc | 3 +++ gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 | 25 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc index 039e7e7da53..f5154d97ae8 100644 --- a/gcc/fortran/parse.cc +++ b/gcc/fortran/parse.cc @@ -885,6 +885,9 @@ decode_omp_directive (void) switch (c) { case 'a': + /* For -fopenmp-simd, ignore 'assumes'; note no clause starts with 's'. */ + if (!flag_openmp && gfc_match ("assumes") == MATCH_YES) + break; matcho ("assumes", gfc_match_omp_assumes, ST_OMP_ASSUMES); matchs ("assume", gfc_match_omp_assume, ST_OMP_ASSUME); matcho ("atomic", gfc_match_omp_atomic, ST_OMP_ATOMIC); diff --git a/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 new file mode 100644 index 00000000000..cf92abf2f9e --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 @@ -0,0 +1,25 @@ +! { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-original" } + +! While 'omp assumes' is ignored with -fopenmp-simd, +! 'omp assume' is processed - check that this works. + +module m + !$omp assumes no_openmp invalid_clause ! Should get ignored +contains + integer function foo() + foo = 5 + end function +end + +program main + use m + implicit none + !$omp assumes no_openmp ! likewise ignored + integer :: n + !$omp assume holds (foo() > 0) ! should be honoured + n = foo() + if (n == 0) stop + !$omp end assume +end + +! { dg-final { scan-tree-dump "\\.ASSUME \\(foo \\(\\) > 0\\);" "original" } }