From owner-freebsd-arm@FreeBSD.ORG Mon Jan 16 02:26:50 2012 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A03E6106564A for ; Mon, 16 Jan 2012 02:26:50 +0000 (UTC) (envelope-from das@freebsd.org) Received: from zim.MIT.EDU (ZIM.MIT.EDU [18.95.3.101]) by mx1.freebsd.org (Postfix) with ESMTP id 5F89B8FC08 for ; Mon, 16 Jan 2012 02:26:50 +0000 (UTC) Received: from zim.MIT.EDU (localhost [127.0.0.1]) by zim.MIT.EDU (8.14.5/8.14.2) with ESMTP id q0G2QlWw037242; Sun, 15 Jan 2012 21:26:47 -0500 (EST) (envelope-from das@freebsd.org) Received: (from das@localhost) by zim.MIT.EDU (8.14.5/8.14.2/Submit) id q0G2Qldx037241; Sun, 15 Jan 2012 21:26:47 -0500 (EST) (envelope-from das@freebsd.org) Date: Sun, 15 Jan 2012 21:26:47 -0500 From: David Schultz To: Ian Lepore Message-ID: <20120116022647.GA36657@zim.MIT.EDU> References: <20120111101833.GA88428@ci0.org> <1326291254.2419.55.camel@revolution.hippie.lan> <20120111175516.GA99475@zim.MIT.EDU> <1326509894.48691.100.camel@revolution.hippie.lan> <20120114081214.GA14925@zim.MIT.EDU> <1326563626.1678.34.camel@revolution.hippie.lan> <20120114182933.GA17739@zim.MIT.EDU> <1326568038.1678.43.camel@revolution.hippie.lan> <20120114211039.GA18310@zim.MIT.EDU> <1326591214.1678.85.camel@revolution.hippie.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1326591214.1678.85.camel@revolution.hippie.lan> Cc: freebsd-arm Subject: Re: fenv.h fixes for softfloat X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 16 Jan 2012 02:26:50 -0000 On Sat, Jan 14, 2012, Ian Lepore wrote: > With the original value 1.1 instead of 1.0, rint() itself raises > FE_INVALID, in the path that falls out the bottom. I added printfs: > > printf("rint 7a: except %#x\n", fetestexcept(FE_ALL_EXCEPT)); > INSERT_WORDS(x,i0,i1); > printf("rint 7b: except %#x\n", fetestexcept(FE_ALL_EXCEPT)); > STRICT_ASSIGN(double,w,TWO52[sx]+x); > printf("rint 7c: except %#x\n", fetestexcept(FE_ALL_EXCEPT)); > result = w-TWO52[sx]; > printf("rint 8: except %#x i0=%#x i1=%#x x=%g w=%g result=%g\n", fetestexcept(FE_ALL_EXCEPT), i0, i1, x, w, result); > return result; > > And a run using rint(1.1) gave this output: > > rint 7a: except 0 > rint 7b: except 0 > rint 7c: except 0x10 > rint 8: except 0x10 i0=0x3ff20000 i1=0x9999999a x=1.125 w=4.5036e+15 result=1 I believe 0x10 is FE_INEXACT on arm, not FE_INVALID. FE_INEXACT is correct here, because w+TWO52[sx] is inexact. That still doesn't explain the lrint() failures, but it makes them less mysterious. For instance, the implementation of the cast from double to int could raise a bogus inexact exception when the number is an integer to begin with. In practice, I think the emulated casts don't raise the proper exceptions even when they should. It might depend on whether it's linking against libgcc's __fixdfsi() or libc's. Nice catch with the _fpmath.h bug, by the way. I'll commit that fix as well.