lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] odd/expm1_log1p 59fff893 4/4: Test gcc builtins


From: Vadim Zeitlin
Subject: Re: [lmi] [lmi-commits] odd/expm1_log1p 59fff893 4/4: Test gcc builtins for certain transcendentals
Date: Thu, 19 May 2022 18:32:24 +0200

On Thu, 19 May 2022 06:37:38 -0400 (EDT) Greg Chicares 
<gchicares@sbcglobal.net> wrote:

GC> branch: odd/expm1_log1p
GC> commit 59fff893554eff66f5dd097477a204f218692d7a
GC> Author: Gregory W. Chicares <gchicares@sbcglobal.net>
GC> Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
GC> 
GC>     Test gcc builtins for certain transcendentals
GC>     
GC>     __builtin_expm1() seems to behave differently between platforms--in
GC>     these tests, lmi::foo() simply forwards to __builtin_foo():
GC>     
GC>     x86_64, sse, gcc, posix
GC>       1.74560101501691655734305 std::expm1(1.01)
GC>       0.00995033085316808334209 std::log1p(0.01)
GC>       0.00327373978219886374239 std::expm1(std::log1p(0.04) / 12)
GC>       1.74560101501691655734305 lmi::expm1(1.01)
GC>       0.00995033085316808334209 lmi::log1p(0.01)
GC>       0.00327373978219886374239 lmi::expm1(lmi::log1p(0.04) / 12)
GC>     
GC>     x86_64, sse, gcc, msw
GC>       1.74560101501691633529845 std::expm1(1.01)
GC>       0.00995033085316808334209 std::log1p(0.01)
GC>       0.00327373978219886417607 std::expm1(std::log1p(0.04) / 12)
GC>       1.74560101501691633529845 lmi::expm1(1.01)
GC>       0.00995033085316808334209 lmi::log1p(0.01)
GC>       0.00327373978219886417607 lmi::expm1(lmi::log1p(0.04) / 12)
GC>     
GC>     ...so either these builtins merely forward to the C RTL, or they differ
GC>     by version:
GC>     
GC>     $gcc -v 2>&1 |grep "gcc version"
GC>     gcc version 11.2.0 (Debian 11.2.0-13)
GC>     
GC>     $x86_64-w64-mingw32-gcc -v 2>&1 |grep "gcc version"
GC>     gcc version 10-win32 20210110 (GCC)
GC>     
GC>     ...but they certainly don't behave the same across platforms and
GC>     compiler versions.

 I've tried expm1(1.01) with gcc versions from 8 to 11 under Linux and they
all output the same value, which is the same one as you obtain
(which is 3FFBEDFB5475CB01 as raw IEEE-754 64-bit or also 0x1.bedfb5475cb01
using %a printf() specifier), so it doesn't seem like there is any
difference between gcc versions, but there is indeed a difference of one
ULP between Linux and MSW. Interestingly, MSVC also returns the same value
(0x1.bedfb5475cb00) as MinGW, even though, AFAIK, MinGW does _not_ use its
CRT for the maths functions implementation.

 And I can also confirm that, rather disappointingly, __builtin_expm1()
expands into just a call to expm1() instead of being directly inlined or
anything like that.

 I don't know if there is any conclusion to make here, but just wanted to
add a couple of data points to this discussion in case they might be useful.

 Regards,
VZ

Attachment: pgpCElg7s1s_J.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]