Date: Sat, 13 May 2017 13:00:59 +0200 From: Dimitry Andric <dimitry@andric.com> To: sgk@troutmask.apl.washington.edu Cc: numerics@freebsd.org, freebsd-hackers@freebsd.org Subject: Re: catrig[fl].c and inexact Message-ID: <42D3F536-42D7-4097-A500-0EF939584592@andric.com> In-Reply-To: <20170512215654.GA82545@troutmask.apl.washington.edu> References: <20170512215654.GA82545@troutmask.apl.washington.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_3FD2EBD2-6E86-4877-858B-D4C2722775DB Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On 12 May 2017, at 23:56, Steve Kargl <sgk@troutmask.apl.washington.edu> = wrote: >=20 > So, I've been making improvements to my implementations of > the half-cycle trig functions. In doing so, I decide to > add WARNS=3D2 to msun/Makefile. clang 4.0.0 dies with an > error about an unused variable in raise_inexact() from > catrig[fl].c. >=20 > /usr/home/kargl/trunk/math/libm/msun/src/catrigl.c:195:2: error: = unused variable > 'junk' [-Werror,-Wunused-variable] > raise_inexact(); > ^ > /usr/home/kargl/trunk/math/libm/msun/src/catrigl.c:56:45: note: = expanded from > macro 'raise_inexact' > #define raise_inexact() do { volatile float junk =3D 1 + tiny; } = while(0) > ^ > Grepping catrig.o for the variable 'junk' suggests that 'junk' is > optimized out (with at least -O2). As far as I can see, this is not the case. The simplest reduction is this: static const volatile float tiny =3D 0x1p-100; void f(void) { volatile float junk =3D 1 + tiny; } For i386-freebsd, this results in the following (boilerplate left out): $ clang-4.0.0 -target i386-freebsd -O2 -S vol1.c -o - [...] pushl %ebp movl %esp, %ebp pushl %eax fld1 fadds tiny fstps -4(%ebp) addl $4, %esp popl %ebp retl [...] tiny: .long 226492416 # float 7.88860905E-31 For amd64-freebsd: $ clang-4.0.0 -target amd64-freebsd -O2 -S vol1.c -o - [...] .LCPI0_0: .long 1065353216 # float 1 [...] pushq %rbp movq %rsp, %rbp movss tiny(%rip), %xmm0 # xmm0 =3D mem[0],zero,zero,zero addss .LCPI0_0(%rip), %xmm0 movss %xmm0, -4(%rbp) popq %rbp retq [...] tiny: .long 226492416 # float 7.88860905E-31 I also tried -O3, but it doesn't change the result. -Dimitry --Apple-Mail=_3FD2EBD2-6E86-4877-858B-D4C2722775DB Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.30 iEYEARECAAYFAlkW53gACgkQsF6jCi4glqPkNACfTDp+YbDQinSkExo64JsidEmj bWMAnA3VM6qYzUFY/5BpESn9zX3x2nxk =NqYy -----END PGP SIGNATURE----- --Apple-Mail=_3FD2EBD2-6E86-4877-858B-D4C2722775DB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42D3F536-42D7-4097-A500-0EF939584592>