From owner-freebsd-numerics@freebsd.org Mon Jul 23 21:59:31 2018 Return-Path: Delivered-To: freebsd-numerics@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 587771055BD4 for ; Mon, 23 Jul 2018 21:59:31 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D8DC570781 for ; Mon, 23 Jul 2018 21:59:30 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id w6NLxSKA098486 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 23 Jul 2018 14:59:28 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id w6NLxSWP098485; Mon, 23 Jul 2018 14:59:28 -0700 (PDT) (envelope-from sgk) Date: Mon, 23 Jul 2018 14:59:28 -0700 From: Steve Kargl To: Bruce Evans Cc: enh via freebsd-numerics Subject: Re: fmod nan_mix usage Message-ID: <20180723215928.GA98418@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu References: <20180723193418.GA66380@troutmask.apl.washington.edu> <20180724071036.O868@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180724071036.O868@besplex.bde.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jul 2018 21:59:31 -0000 On Tue, Jul 24, 2018 at 07:41:17AM +1000, Bruce Evans wrote: > On Mon, 23 Jul 2018, Steve Kargl wrote: > > > > Can you share the code for the relevant tests? > > This simple program gives the expected results > > on amd64. > > > > #include > > #include > > > > int > > main(void) > > { > > printf("%e %d\n", fmodf(3.f, 0.f), isnan(fmodf(3.f, 0.f))); > > printf("%le %d\n", fmod(3.0, 0.0), isnan(fmod(3.0, 0.0))); > > printf("%Le %d\n", fmodl(3.L, 0.L), isnan(fmodl(3.L, 0.L))); > > return 0; > > } > > > > % cc -o z -O a.c -lm && ./z > > nan 1 > > nan 1 > > nan 1 > > clang normally evaluates this at compile, so it doesn't test the libary. > This is arguably a bug in clang, since it doesn't set the exception flags. > #pragma FENV_ACCESS should control this, but it is hard to use and rarely > works. > > The test data needs to be non-literal and perhaps even volatile to prevent > the compiler evaluating it at compile time. > Whoops. I should know better! I have -fno-builtins hardcoded in my development trees and completely forgot about constant folding. -- Steve