From owner-freebsd-numerics@freebsd.org Fri May 12 21:56:58 2017 Return-Path: Delivered-To: freebsd-numerics@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 58BD6D69E31 for ; Fri, 12 May 2017 21:56:58 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 45D31890 for ; Fri, 12 May 2017 21:56:58 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: by mailman.ysv.freebsd.org (Postfix) id 452B2D69E30; Fri, 12 May 2017 21:56:58 +0000 (UTC) Delivered-To: numerics@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 42F02D69E2F; Fri, 12 May 2017 21:56:58 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "troutmask", Issuer "troutmask" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2FAE088E; Fri, 12 May 2017 21:56:55 +0000 (UTC) (envelope-from sgk@troutmask.apl.washington.edu) Received: from troutmask.apl.washington.edu (localhost [127.0.0.1]) by troutmask.apl.washington.edu (8.15.2/8.15.2) with ESMTPS id v4CLusWo082601 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 12 May 2017 14:56:54 -0700 (PDT) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.15.2/8.15.2/Submit) id v4CLusWG082600; Fri, 12 May 2017 14:56:54 -0700 (PDT) (envelope-from sgk) Date: Fri, 12 May 2017 14:56:54 -0700 From: Steve Kargl To: numerics@freebsd.org, freebsd-hackers@freebsd.org Subject: catrig[fl].c and inexact Message-ID: <20170512215654.GA82545@troutmask.apl.washington.edu> Reply-To: sgk@troutmask.apl.washington.edu MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.2 (2016-11-26) X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 May 2017 21:56:58 -0000 So, I've been making improvements to my implementations of the half-cycle trig functions. In doing so, I decide to add WARNS=2 to msun/Makefile. clang 4.0.0 dies with an error about an unused variable in raise_inexact() from catrig[fl].c. /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 = 1 + tiny; } while(0) ^ Grepping catrig.o for the variable 'junk' suggests that 'junk' is optimized out (with at least -O2). A quick and dirty patch to achieve the intent of the original code follows. It would be nice if some would like to commit the patch. Of course, you may want to wait for Bruce to review the diff. Index: src/catrig.c =================================================================== --- src/catrig.c (revision 1935) +++ src/catrig.c (working copy) @@ -37,7 +37,7 @@ __FBSDID("$FreeBSD: head/lib/msun/src/catrig.c 313863 #define isinf(x) (fabs(x) == INFINITY) #undef isnan #define isnan(x) ((x) != (x)) -#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0) +#define raise_inexact(x) do { (x) = 1 + tiny; } while(0) #undef signbit #define signbit(x) (__builtin_signbit(x)) @@ -315,7 +315,7 @@ casinh(double complex z) return (z); /* All remaining cases are inexact. */ - raise_inexact(); + raise_inexact(new_y); if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) return (z); @@ -400,7 +400,7 @@ cacos(double complex z) return (CMPLX(0, -y)); /* All remaining cases are inexact. */ - raise_inexact(); + raise_inexact(new_x); if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) return (CMPLX(pio2_hi - (x - pio2_lo), -y)); @@ -607,7 +607,7 @@ catanh(double complex z) * inexact, but this is the only only that needs to do it * explicitly. */ - raise_inexact(); + raise_inexact(ax); return (z); } Index: src/catrigf.c =================================================================== --- src/catrigf.c (revision 1935) +++ src/catrigf.c (working copy) @@ -51,7 +51,7 @@ __FBSDID("$FreeBSD: head/lib/msun/src/catrigf.c 275819 #define isinf(x) (fabsf(x) == INFINITY) #undef isnan #define isnan(x) ((x) != (x)) -#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0) +#define raise_inexact(x) do { (x) = 1 + tiny; } while(0) #undef signbit #define signbit(x) (__builtin_signbitf(x)) @@ -176,7 +176,7 @@ casinhf(float complex z) if (x == 0 && y == 0) return (z); - raise_inexact(); + raise_inexact(new_y); if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) return (z); @@ -234,7 +234,7 @@ cacosf(float complex z) if (x == 1 && y == 0) return (CMPLXF(0, -y)); - raise_inexact(); + raise_inexact(new_x); if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) return (CMPLXF(pio2_hi - (x - pio2_lo), -y)); @@ -365,7 +365,7 @@ catanhf(float complex z) copysignf(pio2_hi + pio2_lo, y))); if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) { - raise_inexact(); + raise_inexact(ax); return (z); } Index: src/catrigl.c =================================================================== --- src/catrigl.c (revision 1935) +++ src/catrigl.c (working copy) @@ -53,7 +53,7 @@ __FBSDID("$FreeBSD: head/lib/msun/src/catrigl.c 313761 #define isinf(x) (fabsl(x) == INFINITY) #undef isnan #define isnan(x) ((x) != (x)) -#define raise_inexact() do { volatile float junk = 1 + tiny; } while(0) +#define raise_inexact(x) do { (x) = 1 + tiny; } while(0) #undef signbit #define signbit(x) (__builtin_signbitl(x)) @@ -192,7 +192,7 @@ casinhl(long double complex z) if (x == 0 && y == 0) return (z); - raise_inexact(); + raise_inexact(new_y); if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) return (z); @@ -251,7 +251,7 @@ cacosl(long double complex z) if (x == 1 && y == 0) return (CMPLXL(0, -y)); - raise_inexact(); + raise_inexact(new_x); if (ax < SQRT_6_EPSILON / 4 && ay < SQRT_6_EPSILON / 4) return (CMPLXL(pio2_hi - (x - pio2_lo), -y)); @@ -383,7 +383,7 @@ catanhl(long double complex z) copysignl(pio2_hi + pio2_lo, y))); if (ax < SQRT_3_EPSILON / 2 && ay < SQRT_3_EPSILON / 2) { - raise_inexact(); + raise_inexact(ax); return (z); } -- Steve 20170425 https://www.youtube.com/watch?v=VWUpyCsUKR4 20161221 https://www.youtube.com/watch?v=IbCHE-hONow