From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Gary Houston Newsgroups: gmane.lisp.guile.devel Subject: Re: gcc optimisation breaks guile floating point Date: 24 Sep 2002 23:32:01 +0100 Sender: guile-devel-admin@gnu.org Message-ID: <200209242233.PAA04186@onyx.he.net> References: <200208272110.OAA20247@onyx.he.net> <15723.64888.759743.439428@blauw.xs4all.nl> <8765xuzq57.fsf@zagadka.ping.de> <15725.21637.516981.623205@blauw.xs4all.nl> <200208301751.KAA21818@onyx.he.net> <15735.51280.569410.22724@blauw.xs4all.nl> NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1032906816 11672 127.0.0.1 (24 Sep 2002 22:33:36 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 24 Sep 2002 22:33:36 +0000 (UTC) Cc: hanwen@cs.uu.nl, mvo@zagadka.ping.de, guile-devel@gnu.org Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17tyFJ-00031y-00 for ; Wed, 25 Sep 2002 00:33:33 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17tyFM-000302-00; Tue, 24 Sep 2002 18:33:36 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17tyEl-0002xR-00 for guile-devel@gnu.org; Tue, 24 Sep 2002 18:32:59 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17tyEj-0002ww-00 for guile-devel@gnu.org; Tue, 24 Sep 2002 18:32:59 -0400 Original-Received: from onyx.he.net ([216.218.161.2]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17tyEi-0002wd-00 for guile-devel@gnu.org; Tue, 24 Sep 2002 18:32:57 -0400 Original-Received: from onyx.he.net (onyx.he.net [216.218.161.2]) by onyx.he.net (8.8.6/8.8.2) with ESMTP id PAA04186 for ; Tue, 24 Sep 2002 15:33:00 -0700 Original-Received: (qmail 9794 invoked from network); 24 Sep 2002 22:32:01 -0000 Original-Received: from localhost (HELO x.localnet) (127.0.0.1) by localhost with SMTP; 24 Sep 2002 22:32:01 -0000 Original-To: cwitty@newtonlabs.com In-reply-to: (cwitty@newtonlabs.com) Errors-To: guile-devel-admin@gnu.org X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Developers list for Guile, the GNU extensibility library List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.devel:1369 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.devel:1369 > From: cwitty@newtonlabs.com (Carl R. Witty) > Date: 11 Sep 2002 18:46:47 -0700 > > Han-Wen Nienhuys writes: > > > ghouston@arglist.com writes: > > > > > > However scm_double_cell itself probably needs to be fixed, otherwise > > > this problem will turn up again some day, or in user code (I'll look > > > at it myself if it's still a problem in a couple of weeks.) > > > > I think the proper solution is some kind of asm/gcc statement that > > prevents the reordering. Any C gurus that know a portable way of > > ensuring that? A function call like scm_remember() from > > scm_[double_]cell() defeats the purpose of inlining scm_[double_]cell. > > Under gcc, the following statement: > > asm volatile ("" : : : "memory"); > > is approximately what you want. This specifies the empty string as > inline assembly (so nothing is actually inserted into the assembly > output), but tells gcc that the instruction may read and write memory > in arbitrary ways. Thus, gcc will not reorder memory reads or writes > past this statement. This is good, it's similar to a previous work-around in libguile/throw.c. > Of course, this does have other undesirable effects on optimization -- > gcc cannot reorder other, unrelated memory reads or writes past this > statement either, and it also cannot keep values from memory cached in > registers across the statement. It also only works with gcc. Judging by the assembler output, it doesn't seem to do much damage. For other compilers, calling scm_remember_upto_here_1 will avoid the problem, with slightly greater overhead perhaps. So I've moved the work-around into scm_double_cell itself. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://mail.gnu.org/mailman/listinfo/guile-devel