Date: Wed, 13 Mar 2019 09:13:26 -0700 From: Steve Kargl <sgk@troutmask.apl.washington.edu> To: Hans Petter Selasky <hps@selasky.org> Cc: freebsd-toolchain@freebsd.org, freebsd-current@freebsd.org Subject: Re: Optimization bug with floating-point? Message-ID: <20190313161326.GA35122@troutmask.apl.washington.edu> In-Reply-To: <e4b75a93-8ec9-2cc0-641e-7bbd5f466e10@selasky.org> References: <20190313024506.GA31746@troutmask.apl.washington.edu> <20190313151635.GA34757@troutmask.apl.washington.edu> <14ead2c2-b586-309d-947f-1395b5284dd1@selasky.org> <20190313155009.GA34852@troutmask.apl.washington.edu> <e4b75a93-8ec9-2cc0-641e-7bbd5f466e10@selasky.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 13, 2019 at 04:56:26PM +0100, Hans Petter Selasky wrote:
> On 3/13/19 4:50 PM, Steve Kargl wrote:
> > Using sin() and cos() directly as in
> >
> > /* Double precision csinh() without using C's double complex.s */
> > void
> > dp_csinh(double x, double y, double *re, double *im)
> > {
> > double c, s;
> > *re = sinh(x) * cos(y);
> > *im = cosh(x) * sin(y);
> > }
> >
> > does not change the result. I'll also note that libm
> > is compiled by clang, and I do not recompile it for the
> > tests. Both gcc8 and cc are using the same libm.
> >
> > I've also tested clang of amd64 with the -m32, it fails
> > as well.
>
> Hi,
>
> I cannot see this is failing with 11-stable userland. Can you check with
> objdump() that clang doesn't optimise it to sincos() ?
It doesn't.
% nm z | grep sin
U csinhf
00401360 T dp_csinh
U sin
U sinh
> FreeBSD clang version 3.8.0 (tags/RELEASE_380/final 262564) (based on
> LLVM 3.8.0)
> Target: x86_64-unknown-freebsd11.0
The test does not fail on x86_64 unless you add the -m32 option,
which forces i386 behavior.
cc --version
FreeBSD clang version 7.0.1 (tags/RELEASE_701/final 349250)
(based on LLVM 7.0.1)
Target: x86_64-unknown-freebsd13.0
cc -fno-builtin -O2 -o z a.c -lm && ./z
Max u: 2.297073
Count: 0
cc -fno-builtin -O2 -o z a.c -lm -m32 && ./z
Max u: 23.061242
Count: 39
> Thread model: posix
> InstalledDir: /usr/bin
>
> cc -lm -O2 -Wall test.c && ./a.out
> Max ULP: 2.297073
> Count: 0
add -m32.
>
> clang40 -lm -O2 test6.c
> > ./a.out
> Max ULP: 2.297073
> Count: 0
>
> clang50 -lm -O2 test6.c
> > ./a.out
> Max ULP: 2.297073
> Count: 0
>
> clang60 -lm -O2 test6.c
> > ./a.out
> Max ULP: 2.297073
> Count: 0
--
Steve
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190313161326.GA35122>
