From owner-svn-src-head@FreeBSD.ORG Mon Jun 3 17:51:09 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 09B2E556; Mon, 3 Jun 2013 17:51:09 +0000 (UTC) (envelope-from kargl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EF7731CF1; Mon, 3 Jun 2013 17:51:08 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r53Hp8M1099655; Mon, 3 Jun 2013 17:51:08 GMT (envelope-from kargl@svn.freebsd.org) Received: (from kargl@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r53Hp8Mm099653; Mon, 3 Jun 2013 17:51:08 GMT (envelope-from kargl@svn.freebsd.org) Message-Id: <201306031751.r53Hp8Mm099653@svn.freebsd.org> From: Steve Kargl Date: Mon, 3 Jun 2013 17:51:08 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r251327 - in head/lib/msun: ld128 ld80 X-SVN-Group: head 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.14 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: Mon, 03 Jun 2013 17:51:09 -0000 Author: kargl Date: Mon Jun 3 17:51:08 2013 New Revision: 251327 URL: http://svnweb.freebsd.org/changeset/base/251327 Log: Introduce the macro LOG2_INTERVAL, which is log2(number of intervals). Use the macroi as a micro-optimization to convert a subtraction and division to a shift. Obtained from: bde Modified: head/lib/msun/ld128/s_expl.c head/lib/msun/ld80/s_expl.c Modified: head/lib/msun/ld128/s_expl.c ============================================================================== --- head/lib/msun/ld128/s_expl.c Mon Jun 3 17:41:11 2013 (r251326) +++ head/lib/msun/ld128/s_expl.c Mon Jun 3 17:51:08 2013 (r251327) @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" #define INTERVALS 128 +#define LOG2_INTERVALS 7 #define BIAS (LDBL_MAX_EXP - 1) static volatile const long double tiny = 0x1p-10000L; @@ -229,7 +230,7 @@ expl(long double x) fn = x * INV_L + 0x1.8p112 - 0x1.8p112; n = (int)fn; n2 = (unsigned)n % INTERVALS; - k = (n - n2) / INTERVALS; + k = n >> LOG2_INTERVALS; r1 = x - fn * L1; r2 = -fn * L2; Modified: head/lib/msun/ld80/s_expl.c ============================================================================== --- head/lib/msun/ld80/s_expl.c Mon Jun 3 17:41:11 2013 (r251326) +++ head/lib/msun/ld80/s_expl.c Mon Jun 3 17:51:08 2013 (r251327) @@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$"); #include "math_private.h" #define INTERVALS 128 +#define LOG2_INTERVALS 7 #define BIAS (LDBL_MAX_EXP - 1) static const long double @@ -269,7 +270,8 @@ expl(long double x) n = (int)fn; #endif n2 = (unsigned)n % INTERVALS; - k = (n - n2) / INTERVALS; + /* Depend on the sign bit being propagated: */ + k = n >> LOG2_INTERVALS; r1 = x - fn * L1; r2 = -fn * L2;