From owner-freebsd-hackers@freebsd.org Sat May 13 11:01:15 2017 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0192CD6A24E; Sat, 13 May 2017 11:01:15 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id BD736A95; Sat, 13 May 2017 11:01:14 +0000 (UTC) (envelope-from dimitry@andric.com) Received: from [IPv6:2001:470:7a58::a8c1:a7f4:edbc:3331] (unknown [IPv6:2001:470:7a58:0:a8c1:a7f4:edbc:3331]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 5AF543FD73; Sat, 13 May 2017 13:01:12 +0200 (CEST) From: Dimitry Andric Message-Id: <42D3F536-42D7-4097-A500-0EF939584592@andric.com> Content-Type: multipart/signed; boundary="Apple-Mail=_3FD2EBD2-6E86-4877-858B-D4C2722775DB"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: catrig[fl].c and inexact Date: Sat, 13 May 2017 13:00:59 +0200 In-Reply-To: <20170512215654.GA82545@troutmask.apl.washington.edu> Cc: numerics@freebsd.org, freebsd-hackers@freebsd.org To: sgk@troutmask.apl.washington.edu References: <20170512215654.GA82545@troutmask.apl.washington.edu> X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 May 2017 11:01:15 -0000 --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 = 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--