From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30347 invoked by alias); 5 Aug 2008 15:22:42 -0000 Received: (qmail 30338 invoked by uid 22791); 5 Aug 2008 15:22:40 -0000 X-Spam-Check-By: sourceware.org Received: from xena.cds1.net (HELO mail.cds1.net) (216.174.197.150) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 05 Aug 2008 15:22:06 +0000 Received: from localhost (neptune-canopy.cds1.net [172.16.10.246]) by mail.cds1.net (Postfix) with ESMTP id B24BDE8A5A40; Tue, 5 Aug 2008 08:22:00 -0700 (PDT) Received: from mail.cds1.net ([172.16.10.33]) by localhost (neptune.cds1.net [172.16.10.246]) (amavisd-new, port 10024) with ESMTP id VvCJ80fMdMlR; Tue, 5 Aug 2008 08:22:00 -0700 (PDT) Received: from [192.168.1.103] (dhcp-172-16-14-253.cds1.net [172.16.14.253]) by mail.cds1.net (Postfix) with ESMTP id 98527E8A378F; Tue, 5 Aug 2008 08:21:55 -0700 (PDT) Subject: Re: Optimization and double comparison From: Bob Plantz To: Torquil Macdonald =?ISO-8859-1?Q?S=F8rensen?= Cc: gcc-help@gcc.gnu.org In-Reply-To: <200808051019.13789.torquil@gmail.com> References: <200808042334.05408.torquil@gmail.com> <489780AB.8852489@dessent.net> <200808051019.13789.torquil@gmail.com> Content-Type: text/plain; charset=utf-8 Date: Tue, 05 Aug 2008 15:22:00 -0000 Message-Id: <1217949715.6022.7.camel@bob-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00051.txt.bz2 On Tue, 2008-08-05 at 10:19 +0200, Torquil Macdonald Sørensen wrote: > On Tuesday 5. August 2008 00:20, Brian Dessent wrote: > > > > Much has already been written on this topic, so I suggest just reading > > PR323 or googling. There are numerous workarounds: use sse2 instead of > > 387, set the 387 to double precision (e.g. -mpc64 or _FP_{GET,SET}CW), > > use -ffloat-store, don't compare for absolute equality but against some > > small delta, etc. > > > > Brian > > Hi Brian, thank you very much. Yes the target is x86. Your answer was very > interesting. The comparison was just to make sure that a certain quantity > still had the value that it is supposed to have, so it was only for debugging > my algorithm. It should be allright if I instead allow a small error in the > comparison, so I think that I don't have to worry about this problem then. You may wish to at least note that the default for 32-bit compile is x87, but for 64-bit it is SSE2. As Brian noted, x87 uses 80-bit internally, but SSE2 uses only 64-bit. Somebody down the road may port this to 64-bit and get different results. (In my experience, the "somebody down the road" may be myself, and I've forgotten why I did something. :) ) Bob