Hi,
src/regress/usr.bin/bc fails on amd64 since clang 7.0.1 update.
cc -O2 -pipe -MD -MP -lm -o t19 /usr/src/regress/usr.bin/bc/t19.c
./t19
s 15 -3.141593e+00 0.000000e+00 -1.078061e-14 1.078061e-14 2.000000e-15
s 15 3.141593e+00 0.000000e+00 1.078061e-14 1.078061e-14 2.000000e-15
s 20 -3.141593e+00 -1.224600e-16 -1.078061e-14 1.065815e-14 2.168404e-19
s 20 3.141593e+00 1.224600e-16 1.078061e-14 1.065815e-14 2.168404e-19
s 30 -3.141593e+00 -1.224626e-16 -1.078061e-14 1.065814e-14 2.168404e-19
s 30 3.141593e+00 1.224626e-16 1.078061e-14 1.065814e-14 2.168404e-19
*** Error 1 in . (Makefile:44 't19test')
FAILED
This can be tracked down to a loop in src/lib/libm/src/s_sinl.c .
With a print we get:
z.e = scalbnl(z.e, -e0);
for (i = 0; i < NX; i++) {
xd[i] = (double)((int32_t)z.e);
z.e = (z.e - xd[i]) * two24;
}
+ for (i = 0; i < NX; i++)
+ printf("z.e %Le, x[%d] %e\n", z.e, i, xd[i]);
clang 6.0.0
x[0] 1.317679e+07
x[1] 1.062538e+07
x[2] 1.258291e+07
clang 7.0.1
x[0] 1.317679e+07
x[1] 1.062538e+07
x[2] 0.000000e+00
The loop is unrolled by both compilers, but objdump -d shows a
difference in the final iteration. When I switch a fmul and fldcw
in the assembly code, libm produces the expected result.
It looks like the llvm bug that FreeBSD developers have reported.
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=234040
https://bugs.llvm.org/show_bug.cgi?id=40206
bluhm