From owner-freebsd-sparc64@FreeBSD.ORG Wed Mar 3 22:14:14 2010 Return-Path: Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 17DFF106566B for ; Wed, 3 Mar 2010 22:14:14 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 7FA388FC14 for ; Wed, 3 Mar 2010 22:14:13 +0000 (UTC) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.3/8.14.3/ALCHEMY.FRANKEN.DE) with ESMTP id o23ME9aZ039093; Wed, 3 Mar 2010 23:14:09 +0100 (CET) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.3/8.14.3/Submit) id o23ME9iL039092; Wed, 3 Mar 2010 23:14:09 +0100 (CET) (envelope-from marius) Date: Wed, 3 Mar 2010 23:14:09 +0100 From: Marius Strobl To: Peter Jeremy Message-ID: <20100303221409.GM18466@alchemy.franken.de> References: <20100228192329.GA68252@server.vk2pj.dyndns.org> <20100303195354.GA38017@alchemy.franken.de> <20100303203134.GA13366@server.vk2pj.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100303203134.GA13366@server.vk2pj.dyndns.org> User-Agent: Mutt/1.4.2.3i Cc: freebsd-sparc64@freebsd.org Subject: Re: gcc code generation problems X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Mar 2010 22:14:14 -0000 On Thu, Mar 04, 2010 at 07:31:34AM +1100, Peter Jeremy wrote: > On 2010-Mar-03 20:53:55 +0100, Marius Strobl wrote: > >On Mon, Mar 01, 2010 at 06:23:30AM +1100, Peter Jeremy wrote: > >> I've been trying to use FreeBSD 8-stable from a couple of weeks ago on > >> a SunBlade 1500 to investigate some perl problems I'm seeing on > >> Solaris and have bumped into different and more worrying problems on > >> FreeBSD. > >> > >> In particular, the test program used to determine the number of > >> fraction bits in a double (slightly adapted variant attached) is > > > >There was no attachment. > > Oops, sorry. It's attached now. Try comparing the output from > running "cc tryfp.c;./a.out" with "cc -O2 tryfp.c;./a.out". > > The correct answer is 53. > Hrm, this appears to be CPU specific (but neither FreeBSD nor compiler version specific): marius@t1-105:/tmp > grep cpu0 /var/run/dmesg.boot cpu0: Sun Microsystems UltraSparc-IIi Processor (440.04 MHz CPU) marius@t1-105:/tmp > cc tryfp.c;./a.out 53 marius@t1-105:/tmp > cc -O2 tryfp.c;./a.out 53 marius@v215:/tmp > grep cpu0 /var/run/dmesg.boot cpu0: Sun Microsystems UltraSparc-IIIi Processor (1504.00 MHz CPU) marius@v215:/tmp > cc tryfp.c;./a.out 53 marius@v215:/tmp > cc -O2 tryfp.c;./a.out 51 There's some well known difference between spitfire-class (i.e. sun4u < USIII) and cheetah-class (i.e. sun4u >= USIII) CPUs where IIRC the latter do some floating point operations with higher precision in hardware while the former rely on software emulation, leading to different albeit both "correct" results as only the less precise software emulation is guaranteed. Could this also be the reason for the unexpected result you're seeing? Unfortunately, I currently fail to find a reference to this although I remember to have read at least one analysis of this issue on the web and a note about it in some ABI documentation. Marius