From owner-freebsd-arm@FreeBSD.ORG Sun Jan 15 01:33:37 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 CE1B91065676 for ; Sun, 15 Jan 2012 01:33:37 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta06.emeryville.ca.mail.comcast.net (qmta06.emeryville.ca.mail.comcast.net [76.96.30.56]) by mx1.freebsd.org (Postfix) with ESMTP id AD70D8FC0A for ; Sun, 15 Jan 2012 01:33:37 +0000 (UTC) Received: from omta20.emeryville.ca.mail.comcast.net ([76.96.30.87]) by qmta06.emeryville.ca.mail.comcast.net with comcast id Mc9N1i0041smiN4A6dZdsP; Sun, 15 Jan 2012 01:33:37 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta20.emeryville.ca.mail.comcast.net with comcast id MdZc1i0064NgCEG8gdZcLf; Sun, 15 Jan 2012 01:33:37 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q0F1XY0b002355; Sat, 14 Jan 2012 18:33:34 -0700 (MST) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: David Schultz In-Reply-To: <20120114211039.GA18310@zim.MIT.EDU> References: <1326144525.2199.32.camel@revolution.hippie.lan> <20120111052634.GA96534@zim.MIT.EDU> <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> Content-Type: text/plain Date: Sat, 14 Jan 2012 18:33:34 -0700 Message-Id: <1326591214.1678.85.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit 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: Sun, 15 Jan 2012 01:33:37 -0000 Here are some intermediate results from the llrint() problem before I call it a night... The totally degenerate case to get FE_INVALID set is (long long)1.0; That is, llrint() calls rint() then casts the result to long long. rint() doesn't even break a sweat converting 1.0 to 1.0 and returns with no exception flags set, then the cast from 1.0 to 1LL raises FE_INVALID. 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 think this may be overall bad news. It seems to imply that certain normal operations on doubles can raise FE_INVALID as a side effect while generating valid results, and because of those words in the spec about how the rounding routines have to behave as if they're a single operation, I think that means that each rounding routine has to check for invalid inputs explicitly and raise FE_INVALID, and otherwise don't let FE_INVALID from rounding or casting leak out to the caller. Ick. Or, maybe the fact that (long long)1.0 raises FE_INVALID is the real problem, like it's not a normal or expected side effect. Hmmm, for that matter, what does the spec say about things like casting raising exceptions? I think I'll go fix dinner and leave you to ponder that. :) -- Ian