From owner-svn-src-all@FreeBSD.ORG Sun Oct 16 05:37:02 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D819106568A; Sun, 16 Oct 2011 05:37:02 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2D92C8FC12; Sun, 16 Oct 2011 05:37:02 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p9G5b29c047185; Sun, 16 Oct 2011 05:37:02 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p9G5b2x0047181; Sun, 16 Oct 2011 05:37:02 GMT (envelope-from das@svn.freebsd.org) Message-Id: <201110160537.p9G5b2x0047181@svn.freebsd.org> From: David Schultz Date: Sun, 16 Oct 2011 05:37:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226413 - head/lib/msun/src X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Oct 2011 05:37:02 -0000 Author: das Date: Sun Oct 16 05:37:01 2011 New Revision: 226413 URL: http://svn.freebsd.org/changeset/base/226413 Log: Optimize the case of pure imaginary arguments. Calls like this are common, e.g., in DFT implementations. Discussed with: bde, kargl Modified: head/lib/msun/src/s_cexp.c head/lib/msun/src/s_cexpf.c Modified: head/lib/msun/src/s_cexp.c ============================================================================== --- head/lib/msun/src/s_cexp.c Sun Oct 16 05:36:39 2011 (r226412) +++ head/lib/msun/src/s_cexp.c Sun Oct 16 05:37:01 2011 (r226413) @@ -56,8 +56,12 @@ cexp(double complex z) /* cexp(x + I 0) = exp(x) + I 0 */ if ((hy | ly) == 0) return (cpack(exp(x), y)); + EXTRACT_WORDS(hx, lx, x); + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if (((hx & 0x7fffffff) | lx) == 0) + return (cpack(cos(y), sin(y))); + if (hy >= 0x7ff00000) { - EXTRACT_WORDS(hx, lx, x); if (lx != 0 || (hx & 0x7fffffff) != 0x7ff00000) { /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */ return (cpack(y - y, y - y)); @@ -70,7 +74,6 @@ cexp(double complex z) } } - GET_HIGH_WORD(hx, x); if (hx >= exp_ovfl && hx <= cexp_ovfl) { /* * x is between 709.7 and 1454.3, so we must scale to avoid Modified: head/lib/msun/src/s_cexpf.c ============================================================================== --- head/lib/msun/src/s_cexpf.c Sun Oct 16 05:36:39 2011 (r226412) +++ head/lib/msun/src/s_cexpf.c Sun Oct 16 05:37:01 2011 (r226413) @@ -57,6 +57,10 @@ cexpf(float complex z) if (hy == 0) return (cpackf(expf(x), y)); GET_FLOAT_WORD(hx, x); + /* cexp(0 + I y) = cos(y) + I sin(y) */ + if ((hx & 0x7fffffff) == 0) + return (cpackf(cosf(y), sinf(y))); + if (hy >= 0x7f800000) { if ((hx & 0x7fffffff) != 0x7f800000) { /* cexp(finite|NaN +- I Inf|NaN) = NaN + I NaN */