From owner-svn-src-head@freebsd.org Tue Jul 17 12:02:00 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 530F8103CC6B; Tue, 17 Jul 2018 12:02:00 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 073DC86127; Tue, 17 Jul 2018 12:02:00 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DDDDB3145; Tue, 17 Jul 2018 12:01:59 +0000 (UTC) (envelope-from bde@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6HC1x1J098717; Tue, 17 Jul 2018 12:01:59 GMT (envelope-from bde@FreeBSD.org) Received: (from bde@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6HC1xf8098715; Tue, 17 Jul 2018 12:01:59 GMT (envelope-from bde@FreeBSD.org) Message-Id: <201807171201.w6HC1xf8098715@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bde set sender to bde@FreeBSD.org using -f From: Bruce Evans Date: Tue, 17 Jul 2018 12:01:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336412 - head/lib/msun/src X-SVN-Group: head X-SVN-Commit-Author: bde X-SVN-Commit-Paths: head/lib/msun/src X-SVN-Commit-Revision: 336412 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Jul 2018 12:02:00 -0000 Author: bde Date: Tue Jul 17 12:01:59 2018 New Revision: 336412 URL: https://svnweb.freebsd.org/changeset/base/336412 Log: Minor cleanups to csqrt*(), mostly in comments. Remove the STDC CX_LIMITED_RANGE pragma and its verbose comment. We still don't have any C99 compilers (that support fenv pragmas), and if we did then there are thousands of other places in libm that would need to use them more than here. The other cleanups are smaller. Modified: head/lib/msun/src/s_csqrt.c head/lib/msun/src/s_csqrtf.c head/lib/msun/src/s_csqrtl.c Modified: head/lib/msun/src/s_csqrt.c ============================================================================== --- head/lib/msun/src/s_csqrt.c Tue Jul 17 11:53:37 2018 (r336411) +++ head/lib/msun/src/s_csqrt.c Tue Jul 17 12:01:59 2018 (r336412) @@ -35,16 +35,7 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" -/* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. - */ -#pragma STDC CX_LIMITED_RANGE ON - -/* We risk spurious overflow for components >= DBL_MAX / (1 + sqrt(2)). */ +/* For avoiding overflow for components >= DBL_MAX / (1 + sqrt(2)). */ #define THRESH 0x1.a827999fcef32p+1022 double complex Modified: head/lib/msun/src/s_csqrtf.c ============================================================================== --- head/lib/msun/src/s_csqrtf.c Tue Jul 17 11:53:37 2018 (r336411) +++ head/lib/msun/src/s_csqrtf.c Tue Jul 17 12:01:59 2018 (r336412) @@ -34,21 +34,15 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" -/* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. - */ -#pragma STDC CX_LIMITED_RANGE ON - float complex csqrtf(float complex z) { - float a = crealf(z), b = cimagf(z); double t; + float a, b; + a = creal(z); + b = cimag(z); + /* Handle special cases. */ if (z == 0) return (CMPLXF(0, b)); @@ -82,9 +76,9 @@ csqrtf(float complex z) */ if (a >= 0) { t = sqrt((a + hypot(a, b)) * 0.5); - return (CMPLXF(t, b / (2.0 * t))); + return (CMPLXF(t, b / (2 * t))); } else { t = sqrt((-a + hypot(a, b)) * 0.5); - return (CMPLXF(fabsf(b) / (2.0 * t), copysignf(t, b))); + return (CMPLXF(fabsf(b) / (2 * t), copysignf(t, b))); } } Modified: head/lib/msun/src/s_csqrtl.c ============================================================================== --- head/lib/msun/src/s_csqrtl.c Tue Jul 17 11:53:37 2018 (r336411) +++ head/lib/msun/src/s_csqrtl.c Tue Jul 17 12:01:59 2018 (r336412) @@ -36,24 +36,17 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" /* - * gcc doesn't implement complex multiplication or division correctly, - * so we need to handle infinities specially. We turn on this pragma to - * notify conforming c99 compilers that the fast-but-incorrect code that - * gcc generates is acceptable, since the special cases have already been - * handled. + * THRESH is now calculated portably (up to 113-bit precision). However, + * the denormal threshold is hard-coded for a 15-bit exponent with the usual + * bias. s_logl.c and e_hypotl have less hard-coding but end up requiring + * the same for the exponent and more for the mantissa. */ -#pragma STDC CX_LIMITED_RANGE ON - -/* - * We risk spurious overflow for components >= LDBL_MAX / (1 + sqrt(2)). - * Rather than determining the fully precise value at which we might - * overflow, just use a threshold of approximately LDBL_MAX / 4. - */ #if LDBL_MAX_EXP != 0x4000 #error "Unsupported long double format" -#else -#define THRESH 0x1p16382L #endif + +/* For avoiding overflow for components >= LDBL_MAX / (1 + sqrt(2)). */ +#define THRESH (LDBL_MAX / 2.414213562373095048801688724209698L) long double complex csqrtl(long double complex z)