GNU bug report logs - #42147
28.0.50; pure vs side-effect-free, missing optimizations?

Previous Next

Package: emacs;

Reported by: Andrea Corallo <andrea_corallo <at> yahoo.it>

Date: Tue, 30 Jun 2020 22:28:02 UTC

Severity: normal

Found in version 28.0.50

Done: Mattias EngdegÄrd <mattiase <at> acm.org>

Bug is archived. No further changes may be made.

Full log


Message #152 received at 42147 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Pip Cet <pipcet <at> gmail.com>
Cc: mattiase <at> acm.org, Stefan Monnier <monnier <at> iro.umontreal.ca>,
 andrea_corallo <at> yahoo.it, 42147 <at> debbugs.gnu.org
Subject: Re: bug#42147: 28.0.50; pure vs side-effect-free, missing
 optimizations?
Date: Sun, 5 Jul 2020 02:56:23 -0700
On 7/4/20 11:37 AM, Pip Cet wrote:

> So it's a GCC bug? Wouldn't it be better to fix that?

Not without such a performance hit that nobody has wanted to do it. I expect it
would need software emulation for most floating-point operations.

Also, in theory the Linux kernel could emulate missing SSE2 instructions.
However, this is another workaround that nobody has wanted to do because it's
not worth the hassle to support these old CPUs.

> (The double-rounding issues you mention don't appear to be documented;

It's obvious from the generated code.

-fexcess-precision doesn't mean floating-point operations conform to IEEE-754
double; all it means is that floating-point values are representable as IEEE-754
double. This is why one cannot rely on -fexcess-precision=standard to get
reproducible results.

> The minor issue fixed by dropping support
> for pre-SSE x86 can, if I understand the GCC docs correctly, be evaded
> by making sure the C code does the appropriate amount of casting.

That won't suffice. On x87+387, GCC preserves excess precision through casts,
even if -ffloat-store is specified.

> SSE instructions require special OS support, too.

The Linux kernel has supported SSE2 since Linux 2.4 (2001). Any Linux kernel
that doesn't support SSE2 is so old that I suspect it won't run current Emacs
anyway, for other reasons.

> I also think it's unwise to establish that Emacs uses 64-bit IEEE-754
> floating point numbers exclusively.

What, will we switch to IBM mainframe floating-point format? :-)

Part of the problem we're trying to solve here is rounding discrepancies between
build-time and run-time computation. The idea is that an Elisp floating-point
operation should yield the same value regardless of whether it's byte-compiled
(or even machine-compiled, if we want to do that). Even if Emacs changed
floating-point format (by stealing a few bits for tags, say), we'd still run
into the same problem.


PS. I finally got around to benchmarking, and on my usual benchmark (make
compile-always, Fedora 31 x86), using SSE2 sped up Emacs by 4.6%. So there is a
performance argument for the change as well as a fix-the-rounding-glitches argument.




This bug report was last modified 4 years and 281 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.