Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2019 10:40:28 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        John Baldwin <jhb@freebsd.org>
Cc:        "freebsd-toolchain@FreeBSD.org" <freebsd-toolchain@freebsd.org>,  freebsd-current <freebsd-current@freebsd.org>
Subject:   Re: Optimization bug with floating-point?
Message-ID:  <CAG6CVpWjYP_0D2YU_=EzGcShW6Dz28mM%2B=h9R_cpf=emJetDSA@mail.gmail.com>
In-Reply-To: <e638e0bf-b8d0-9bd1-d034-8acc6eef872c@FreeBSD.org>
References:  <20190313024506.GA31746@troutmask.apl.washington.edu> <20190313151635.GA34757@troutmask.apl.washington.edu> <e290b68f-7a1d-2456-4a0c-9f7dfd303f55@FreeBSD.org> <20190313164039.GA35340@troutmask.apl.washington.edu> <e638e0bf-b8d0-9bd1-d034-8acc6eef872c@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi John,

On Wed, Mar 13, 2019 at 10:17 AM John Baldwin <jhb@freebsd.org> wrote:
> One issue I'm aware of is that clang does not have any support for the
> special arrangement FreeBSD/i386 uses where it uses different precision
> for registers vs in-memory for some of the floating point types (GCC has
> a special hack that is only used on FreeBSD for this but isn't used on
> any other OS's).  I wonder if that could be a factor?  Volatile probably
> forces a round trip between memory which might explain why this is the
> case.
>
> I wonder what your test program does on i386 Linux with GCC?

$ uname -sr
Linux 4.20.4
$ gcc --version
gcc (GCC) 8.2.1 20181215 (Red Hat 8.2.1-6)
...
$ rpm -qf /usr/lib/libm-2.27.so
glibc-2.27-37.fc28.i686

$ gcc -m32 -fno-builtin -o z kargl.c -lm && ./z
Max ULP: 1.959975
Count: 0
$ gcc -O -m32 -fno-builtin -o z kargl.c -lm && ./z
Max ULP: 1.959975
Count: 0
$ gcc -O1 -m32 -fno-builtin -o z kargl.c -lm && ./z
Max ULP: 1.959975
Count: 0
$ gcc -O2 -m32 -fno-builtin -o z kargl.c -lm && ./z
Max ULP: nan
Count: 0
$ gcc -O3 -m32 -fno-builtin -o z kargl.c -lm && ./z
Max ULP: nan
Count: 0

Uh.

kargl.c: In function =E2=80=98main=E2=80=99:
kargl.c:80:10: warning: =E2=80=98u=E2=80=99 may be used uninitialized in th=
is function
[-Wmaybe-uninitialized]
       if (ur > u) u =3D ur;
          ^

If I initialize 'u' (to, e.g., -1e52), I get:
Max ULP: 1.959975
Count: 0

at -O2 and -O3 as well.

Best,
Conrad



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpWjYP_0D2YU_=EzGcShW6Dz28mM%2B=h9R_cpf=emJetDSA>