From patchwork Fri Mar 10 17:54:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 67620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp1014434wrd; Fri, 10 Mar 2023 09:55:31 -0800 (PST) X-Google-Smtp-Source: AK7set+2dO+yfzLSm7W0i2g0C0knkq9zNS8qC++3GSy4X79pnT3xhJk2ZsghRO2d1bBWP7rjARw0 X-Received: by 2002:a17:907:36e:b0:878:673f:5492 with SMTP id rs14-20020a170907036e00b00878673f5492mr25781629ejb.40.1678470931605; Fri, 10 Mar 2023 09:55:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678470931; cv=none; d=google.com; s=arc-20160816; b=v2uwZhdkqdlnpc/5zFnj+7UuWzOyHfRLeV9cCIfzHaa6wAn6xKZsYTACjsw/LtD8cV ZYCY5+ZMyRXOghVFjrO8JTHwqo7BnRh1PcK+IdN5WTHhIrJDVoiKzdqI7I7Lo/AyPN+O 7z78azOHPDnzr/FgrYIaRVITw6w4j9Zu4Ftz28roI3C70Anat5OdtCJM5rsUhISQndHL SDCvKs0hqEzBuJzzDqFtl38Mx32HiSaB6giBXRDppAAwczvVxS+xWlfHhOd7CCjhiU+O ZLivvljzIPIGoCJnUOad9Rxw0g+TH9QBpM9mjaqGCjVLgtNzgV7Gvwb/JIRFDHoUcwU9 bQCg== 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:subject:to :content-language:user-agent:mime-version:date:message-id :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=i0JiVveBvwd08GSzRNIxmgrFtXe0KJ0WL5EJFyPUbr8=; b=e7USQF1ousqQtQgCauSMmTKenCc+7kQ4mVosZr1HUTPnhK7/92Zxy+DRB7Ygjna36c PRVYkSEwTIJPSxwwhTKSW10vbJkGRN7gUZND5PIAffrlCuECoIocEFtmF0b2DY8fDkbK hV84i0dCrgaqsIbRtYMoKiZdP6z2eJcT+TaAGZ7WVsKa9ZhRgCuvtH1oomBgtLIcZCWc /I5VgwiDr1Qr6nDaPH/zkMR0HmCQsAh4oVlnilHoeDIE611xh2gXFmST5FEXxQROjNl9 jdfsdzvOHzFS/R1dZun91TU8qm64uPqylge/2HbzNWHlR33e5hYgr9ZCud0AakiUFqjq eEzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sLiAzt80; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ch15-20020a170906c2cf00b008cab1ae71e4si300571ejb.818.2023.03.10.09.55.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Mar 2023 09:55:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sLiAzt80; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 CC71F3857835 for ; Fri, 10 Mar 2023 17:54:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CC71F3857835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678470899; bh=i0JiVveBvwd08GSzRNIxmgrFtXe0KJ0WL5EJFyPUbr8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=sLiAzt80GiVQZTu27+mSquw6ZsUervz8M5Sg4ZDk97U+r4IN7JUDO97rpgDcs+4fU 8RXWfAu1zPL0sPdeMPVqYv2xQTP2B7DvXXBsRqxFUS9fkCkFPGgwo6HCYE3g10gnDJ MjFHoj5vFRUbmqYAvUdtbnVkJglFbTumg6bt8s8Q= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cc-smtpout2.netcologne.de (cc-smtpout2.netcologne.de [89.1.8.212]) by sourceware.org (Postfix) with ESMTPS id 579F33858D32; Fri, 10 Mar 2023 17:54:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 579F33858D32 Received: from cc-smtpin2.netcologne.de (cc-smtpin2.netcologne.de [89.1.8.202]) by cc-smtpout2.netcologne.de (Postfix) with ESMTP id 7A735125F8; Fri, 10 Mar 2023 18:54:12 +0100 (CET) Received: from [IPV6:2001:4dd7:c7b6:0:7285:c2ff:fe6c:992d] (2001-4dd7-c7b6-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:c7b6:0:7285:c2ff:fe6c:992d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by cc-smtpin2.netcologne.de (Postfix) with ESMTPSA id 2794D11FEC; Fri, 10 Mar 2023 18:54:11 +0100 (CET) Message-ID: Date: Fri, 10 Mar 2023 18:54:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, Fortran] Enable -fwrapv for -std=legacy X-NetCologne-Spam: L X-Spamd-Bar: / X-Rspamd-Action: no action X-Rspamd-Queue-Id: 2794D11FEC X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, 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: , X-Patchwork-Original-From: Thomas Koenig via Gcc-patches From: Thomas Koenig Reply-To: Thomas Koenig 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?1760004335657062330?= X-GMAIL-MSGID: =?utf-8?q?1760004335657062330?= Hello world, here's the patch that was discussed. Regression-tested. OK for trunk? Since this appeared only in gcc13, I see no need for a backport. I will also document this in the changes file. Best regards Thomas Set -frapv if -std=legacy is set. Fortran legacy codes sometimes contain linear congruential seudorandom number generators. These generators implicitly depend on wrapping behavior on integer overflow, which is illegal Fortran, but the best they could to at the time. A gcc13 change exposed this in rnflow, part of the Polyhedron benchmark, with -O3. Rather than "regress" on such code, this patch enables -fwrapv if -std=legacy is enabled. This allows the benchmark to run successfully, and presumably lots of other code as well. gcc/fortran/ChangeLog: PR fortran/109075 * options.cc (gfc_handle_option): If -std=legacy is set, also set -frwapv. * invoke.texi: Document the change. diff --git a/gcc/fortran/invoke.texi b/gcc/fortran/invoke.texi index 5679e2f2650..4f4950dad41 100644 --- a/gcc/fortran/invoke.texi +++ b/gcc/fortran/invoke.texi @@ -549,15 +549,16 @@ Fortran standard that includes all of the extensions supported by GNU Fortran, although warnings will be given for obsolete extensions not recommended for use in new code. The @samp{legacy} value is equivalent but without the warnings for obsolete extensions, and may -be useful for old non-standard programs. The @samp{f95}, -@samp{f2003}, @samp{f2008}, and @samp{f2018} values specify strict -conformance to the Fortran 95, Fortran 2003, Fortran 2008 and Fortran -2018 standards, respectively; errors are given for all extensions -beyond the relevant language standard, and warnings are given for the -Fortran 77 features that are permitted but obsolescent in later -standards. The deprecated option @samp{-std=f2008ts} acts as an alias for -@samp{-std=f2018}. It is only present for backwards compatibility with -earlier gfortran versions and should not be used any more. +be useful for old non-standard programs. It also sets +@option{-fwrapv}. The @samp{f95}, @samp{f2003}, @samp{f2008}, and +@samp{f2018} values specify strict conformance to the Fortran 95, +Fortran 2003, Fortran 2008 and Fortran 2018 standards, respectively; +errors are given for all extensions beyond the relevant language +standard, and warnings are given for the Fortran 77 features that are +permitted but obsolescent in later standards. The deprecated option +@samp{-std=f2008ts} acts as an alias for @samp{-std=f2018}. It is only +present for backwards compatibility with earlier gfortran versions and +should not be used any more. @opindex @code{ftest-forall-temp} @item -ftest-forall-temp diff --git a/gcc/fortran/options.cc b/gcc/fortran/options.cc index 27311961325..76166ac69aa 100644 --- a/gcc/fortran/options.cc +++ b/gcc/fortran/options.cc @@ -797,6 +797,8 @@ gfc_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value, case OPT_std_legacy: set_default_std_flags (); gfc_option.warn_std = 0; + /* -std=legacy implies -fwapv, but the user can override it. */ + flag_wrapv = 1; break; case OPT_fshort_enums: