From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14809 invoked by alias); 18 Jul 2018 15:10:10 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14779 invoked by uid 89); 18 Jul 2018 15:10:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=afaiu, AFAIU, sensible, H*c:alternative X-HELO: mail-yb0-f171.google.com Received: from mail-yb0-f171.google.com (HELO mail-yb0-f171.google.com) (209.85.213.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 18 Jul 2018 15:10:08 +0000 Received: by mail-yb0-f171.google.com with SMTP id r3-v6so1966120ybo.4; Wed, 18 Jul 2018 08:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=OOzvRXirzqRI0U0rmV7YM8rh0zk29RoTMINn4QpchpI=; b=srDL81ZuVw4pnjzy51G8OijTAEvGi1tZge31mraDMif1JnTAEIn7Qq484LPppnZmUM sytZQHYi0VOi7XmmXwk9a8n+kBD9p9tH1w5UFR5uCTbwy+jbGoRftsjyruurCzXK3WsN 4HW7WtsK2ycpDXjyBpa1KtkeRv0Vvn8hJOEyaawGqK/Xia2PqRQ6FMHkNn4eWCj3F3FC /PdFOaLmP79iD5JYR3HM8ARZ8nFXlQvyGEXfc+7R81DT6+q/8n2eukeru6TdJ3PBupsn sbsDGqNW0OQwJg51sWsJdE/CBuB4XEUCBpKn3aW7E76z+hT/qt0+sfSPv4Iq8UdgebIn haWA== MIME-Version: 1.0 Received: by 2002:a0d:e304:0:0:0:0:0 with HTTP; Wed, 18 Jul 2018 08:10:05 -0700 (PDT) In-Reply-To: <2AD7441E-7E57-47EC-9073-92375938B8B8@tkoenig.net> References: <5B4DE283.9060100@foss.arm.com> <5B4DF325.2050609@foss.arm.com> <9d0cf3dc-8c5c-bbb2-960c-386b2c936a50@netcologne.de> <5B4F21E0.3060307@foss.arm.com> <2AD7441E-7E57-47EC-9073-92375938B8B8@tkoenig.net> From: Janne Blomqvist Date: Wed, 18 Jul 2018 15:10:00 -0000 Message-ID: Subject: Re: [PATCH][Fortran][v2] Use MIN/MAX_EXPR for min/max intrinsics To: =?UTF-8?Q?Thomas_K=C3=B6nig?= Cc: Kyrill Tkachov , Thomas Koenig , Richard Biener , "fortran@gcc.gnu.org" , GCC Patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-SW-Source: 2018-07/txt/msg01005.txt.bz2 On Wed, Jul 18, 2018 at 4:26 PM, Thomas K=C3=B6nig wrote: > Hi Kyrlll, > > > Am 18.07.2018 um 13:17 schrieb Kyrill Tkachov < > kyrylo.tkachov@foss.arm.com>: > > > > Thomas, Janne, would this relaxation of NaN handling be acceptable given > the benefits > > mentioned above? If so, what would be the recommended adjustment to the > nan_1.f90 test? > > I would be a bit careful about changing behavior in such a major way. What > would the results with NaN and infinity then be, with or without > optimization? Would the results be consistent with min(nan,num) vs > min(num,nan)? Would they be consistent with the new IEEE standard? > AFAIU, MIN/MAX_EXPR do the right thing when comparing a normal number with Inf. For NaN the result is undefined, and you might indeed have min(a, NaN) =3D a min(NaN, a) =3D NaN where "a" is a normal number. (I think that happens at least on x86 if MIN_EXPR is expanded to minsd/minpd. Apparently what the proper result for min(a, NaN) should be is contentious enough that minnum was removed from the upcoming IEEE 754 revision, and new operations AFAICS have the semantics minimum(a, NaN) =3D minimum(NaN, a) =3D NaN minimumNumber(a, NaN) =3D minimumNumber(NaN, a) =3D a That is minimumNumber corresponds to minnum in IEEE 754-2008 and fmin* in C, and to the current behavior of gfortran. > In general, I think that min(nan,num) should be nan and that our current > behavior is not the best. > There was some extensive discussion of that in the Julia bug report I linked to in an earlier message, and they came to the same conclusion and changed their behavior. > Does anybody have dats points on how this is handled by other compilers? > The only other compiler I have access to at the moment is ifort (and not the latest version), but maybe somebody has access to a wider variety? > Oh, and if anything is changed, then compile and runtime behavior should > always be the same. > Well, IFF we place some weight on the runtime behavior being particularly sensible wrt NaN's, which it wouldn't be if we just use a plain MIN/MAX_EXPR. Is it worth taking a performance hit for, though? In particular, if other compilers are inconsistent, we might as well do whatever is fastest. --=20 Janne Blomqvist