unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Gary Houston <ghouston@arglist.com>
Cc: hanwen@cs.uu.nl, mvo@zagadka.ping.de, guile-devel@gnu.org
Subject: Re: gcc optimisation breaks guile floating point
Date: 24 Sep 2002 23:32:01 +0100	[thread overview]
Message-ID: <200209242233.PAA04186@onyx.he.net> (raw)
In-Reply-To: <v4jr8g0asjc.fsf@bogomips.newtonlabs.com> (cwitty@newtonlabs.com)

> From: cwitty@newtonlabs.com (Carl R. Witty)
> Date: 11 Sep 2002 18:46:47 -0700
> 
> Han-Wen Nienhuys <hanwen@cs.uu.nl> 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


  parent reply	other threads:[~2002-09-24 22:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-27 21:10 gcc optimisation breaks guile floating point Gary Houston
2002-08-27 22:30 ` Han-Wen Nienhuys
2002-08-28 20:26   ` Marius Vollmer
2002-08-28 22:53     ` Han-Wen Nienhuys
2002-08-30 17:44       ` Gary Houston
2002-09-05 21:10         ` Han-Wen Nienhuys
2002-09-12  1:46           ` Carl R. Witty
2002-09-13 21:20             ` Han-Wen Nienhuys
2002-09-24 22:32             ` Gary Houston [this message]
     [not found]             ` <200209242233.PAA04201@onyx.he.net>
2002-10-02 22:40               ` Marius Vollmer
2002-10-02 23:34                 ` Gary Houston
     [not found]                 ` <200210022336.QAA18265@onyx.he.net>
2002-10-03 12:33                   ` Marius Vollmer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200209242233.PAA04186@onyx.he.net \
    --to=ghouston@arglist.com \
    --cc=guile-devel@gnu.org \
    --cc=hanwen@cs.uu.nl \
    --cc=mvo@zagadka.ping.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).