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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 8AB8E3857831 for ; Sat, 21 Nov 2020 04:33:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8AB8E3857831 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-NIB5udj4NmmqRyPjHO6B3A-1; Fri, 20 Nov 2020 23:33:51 -0500 X-MC-Unique: NIB5udj4NmmqRyPjHO6B3A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8542107AD3A; Sat, 21 Nov 2020 04:33:49 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-152.phx2.redhat.com [10.3.113.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6077C5D9D5; Sat, 21 Nov 2020 04:33:49 +0000 (UTC) Subject: Re: [PATCH v2] Fix -ffast-math flags handling inconsistencies To: Ulrich Weigand , gcc-patches@gcc.gnu.org Cc: joseph@codesourcery.com, richard.guenther@gmail.com, segher@kernel.crashing.org References: <20200211184332.0968DD80313@oc3748833570.ibm.com> From: Jeff Law Message-ID: <408dfef3-b4ea-9605-5466-efd215f573cd@redhat.com> Date: Fri, 20 Nov 2020 21:33:48 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20200211184332.0968DD80313@oc3748833570.ibm.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Sat, 21 Nov 2020 04:33:58 -0000 On 2/11/20 11:43 AM, Ulrich Weigand wrote: > Hello, > > this second version of the patch incorporates all changes discussed > in the original mail thread starting here: > https://gcc.gnu.org/ml/gcc-patches/2020-01/msg02097.html > > The patch now implements the following set of changes: > > 1. If a component flag of -ffast-math (or -funsafe-math-optimizations) > is explicitly set (or reset) on the command line, this should override > any implicit change due to -f(no-)fast-math, no matter in which order > the flags come on the command line. This change affects all flags. > > 2. Any component flag modified from its default by -ffast-math should > be reset to the default by -fno-fast-math. This was previously > not done for the following flags: > -fcx-limited-range > -fexcess-precision= > > 3. Once -ffinite-math-only is true, the -f(no-)signaling-nans flag has > no meaning (if we have no NaNs at all, it does not matter whether > there is a difference between quiet and signaling NaNs). Therefore, > it does not make sense for -ffast-math to imply -fno-signaling-nans. > This is also a documentation change. > > 4. -ffast-math is documented to imply -fno-rounding-math, however the > latter setting is the default anyway; therefore it does not make > sense to try to modify it from its default setting. > > 5. The __FAST_MATH__ preprocessor macro should be defined if and only > if all the component flags of -ffast-math are set to the value that > is documented as the effect of -ffast-math. The following flags > were currently *not* so tested: > -fcx-limited-range > -fassociative-math > -freciprocal-math > -frounding-math > (Note that we should still *test* for -fno-rounding-math here even > though it is not set as per 4. -ffast-math -frounding-math should > not set the __FAST_MATH__ macro.) > This is also a documentation change. > > > Tested on s390x-ibm-linux. > > OK for mainline? > > Bye, > Ulrich > > gcc/ChangeLog: > > * doc/invoke.texi (-ffast-math): Remove mention of -fno-signaling-nans. > Clarify conditions when __FAST_MATH__ preprocessor macro is defined. > > * opts.c (common_handle_option): Pass OPTS_SET to set_fast_math_flags > and set_unsafe_math_optimizations_flags. > (set_fast_math_flags): Add OPTS_SET argument, and use it to avoid > setting flags already explicitly set on the command line. In the !set > case, also reset x_flag_cx_limited_range and x_flag_excess_precision. > Never reset x_flag_signaling_nans or x_flag_rounding_math. > (set_unsafe_math_optimizations_flags): Add OPTS_SET argument, and use > it to avoid setting flags already explicitly set on the command line. > (fast_math_flags_set_p): Also test x_flag_cx_limited_range, > x_flag_associative_math, x_flag_reciprocal_math, and > x_flag_rounding_math. It appears this was dropped on the floor.  It looks reasonable to me.  Please retest and commit.  Thanks! Jeff