From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DDC643858D38 for ; Fri, 10 Mar 2023 18:01:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DDC643858D38 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678471299; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=pxIiFsCBwXlRMvpauSTpKDgZDZQihYDfhkaUKyNlI64=; b=OnrmhDpmGFdadKfBVcMndL/Qej+u7Gv65RxW02Db+t3MKNTLR9VatVjFpQ51kuvCKa402I 9q3/v84tVxCJKAi3ITCf/CjW3pzgl59M43PYydoBpAtDXlSOEwG/WuDUX1oUfte6M+EEFa LtMK5b0/8+Yf3U8Lf/AMTTZ36Ala1Zc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-176-X-1Q-3EpPv6fqlhHIN0C7g-1; Fri, 10 Mar 2023 13:01:35 -0500 X-MC-Unique: X-1Q-3EpPv6fqlhHIN0C7g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CCB318E0A6E; Fri, 10 Mar 2023 18:01:34 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 481872166B2C; Fri, 10 Mar 2023 18:01:34 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32AI1UEs896532 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 10 Mar 2023 19:01:30 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32AI1Tmj896531; Fri, 10 Mar 2023 19:01:29 +0100 Date: Fri, 10 Mar 2023 19:01:29 +0100 From: Jakub Jelinek To: Thomas Koenig Cc: "fortran@gcc.gnu.org" , gcc-patches Subject: Re: [patch, Fortran] Enable -fwrapv for -std=legacy Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, Mar 10, 2023 at 06:54:10PM +0100, Thomas Koenig via Gcc-patches wrote: > 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. s/frapv/fwrapv/ > 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. I think it certainly shouldn't overwrite it, it can adjust the default, but if user asks for -std=legacy -fno-wrapv or -fno-wrapv -std=legacy, it should honor that. > gcc/fortran/ChangeLog: > > PR fortran/109075 > * options.cc (gfc_handle_option): If -std=legacy is set, s/ / / > also set -frwapv. s/rwapv/wrapv/ > * invoke.texi: Document the change. > --- 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: So, I think it should be done later, after option processing, say in gfc_post_options if it is possible to determine if -std=legacy has been specified (and not say -std=legacy -std=f2018 etc.), and using SET_OPTION_IF_UNSET. Jakub