From owner-freebsd-numerics@freebsd.org Sun Sep 8 14:45:30 2019 Return-Path: Delivered-To: freebsd-numerics@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EDA3EF52AE; Sun, 8 Sep 2019 14:45:30 +0000 (UTC) (envelope-from stefan.kanthak@nexgo.de) Received: from mx009.vodafonemail.xion.oxcs.net (mx009.vodafonemail.xion.oxcs.net [153.92.174.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 46RDc95bWHz3yfj; Sun, 8 Sep 2019 14:45:29 +0000 (UTC) (envelope-from stefan.kanthak@nexgo.de) Received: from vsmx002.vodafonemail.xion.oxcs.net (unknown [192.168.75.192]) by mta-6-out.mta.xion.oxcs.net (Postfix) with ESMTP id 0AFE060D643; Sun, 8 Sep 2019 14:45:27 +0000 (UTC) Received: from H270 (unknown [93.230.223.140]) by mta-6-out.mta.xion.oxcs.net (Postfix) with ESMTPA id 877DB60D6AE; Sun, 8 Sep 2019 14:45:22 +0000 (UTC) Message-ID: <769CF9CBA0A34DFA92C739C970FA2AAF@H270> From: "Stefan Kanthak" To: , Subject: Shorter releng/12.0/lib/msun/i387/e_exp.S and releng/12.0/lib/msun/i387/s_finite.S Date: Sun, 8 Sep 2019 16:37:03 +0200 Organization: Me, myself & IT MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Windows Mail 6.0.6002.18197 X-MimeOLE: Produced By Microsoft MimeOLE V6.1.7601.24158 X-VADE-STATUS: LEGIT X-Rspamd-Queue-Id: 46RDc95bWHz3yfj X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of stefan.kanthak@nexgo.de designates 153.92.174.39 as permitted sender) smtp.mailfrom=stefan.kanthak@nexgo.de X-Spamd-Result: default: False [-2.35 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_LONG(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:153.92.174.0/24]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; DMARC_NA(0.00)[nexgo.de]; HAS_ORG_HEADER(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; RCVD_TLS_LAST(0.00)[]; RCVD_IN_DNSWL_MED(-0.20)[39.174.92.153.list.dnswl.org : 127.0.5.2]; RCPT_COUNT_TWO(0.00)[2]; HAS_X_PRIO_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.40)[-0.396,0]; NEURAL_HAM_MEDIUM(-0.95)[-0.949,0]; IP_SCORE(-0.00)[country: DE(-0.01)]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MID_RHS_NOT_FQDN(0.50)[]; ASN(0.00)[asn:60664, ipnet:153.92.174.0/24, country:DE]; MIME_TRACE(0.00)[0:+] X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.29 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: Sun, 08 Sep 2019 14:45:31 -0000 Hi, here's a patch to remove a conditional branch (and more) from http://sources.freebsd.org/releng/12.0/lib/msun/i387/e_exp.S plus a patch to shave some bytes (immediate operands) from http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_finite.S stay tuned Stefan Kanthak --- -/releng/12.0/lib/msun/i387/e_exp.S +++ +/releng/12.0/lib/msun/i387/e_exp.S @@ -45,7 +45,25 @@ movl 8(%esp),%eax - andl $0x7fffffff,%eax - cmpl $0x7ff00000,%eax - jae x_Inf_or_NaN + leal (%eax+%eax),%edx + cmpl $0xffe00000,%edx + jb finite + /* + * Return 0 if x is -Inf. Otherwise just return x; when x is Inf + * this gives Inf, and when x is a NaN this gives the same result + * as (x + x) (x quieted). + */ + cmpl 4(%esp),$0 + sbbl $0xfff00000,%eax + je minus_inf + +nan: fldl 4(%esp) + ret +minus_inf: + fldz + ret + +finite: + fldl 4(%esp) + @@ -80,19 +98,3 @@ ret - -x_Inf_or_NaN: - /* - * Return 0 if x is -Inf. Otherwise just return x; when x is Inf - * this gives Inf, and when x is a NaN this gives the same result - * as (x + x) (x quieted). - */ - cmpl $0xfff00000,8(%esp) - jne x_not_minus_Inf - cmpl $0,4(%esp) - jne x_not_minus_Inf - fldz - ret - -x_not_minus_Inf: - fldl 4(%esp) - ret END(exp) --- -/releng/12.0/lib/msun/i387/s_finite.S +++ +/releng/12.0/lib/msun/i387/s_finite.S @@ -39,8 +39,8 @@ ENTRY(finite) movl 8(%esp),%eax - andl $0x7ff00000, %eax - cmpl $0x7ff00000, %eax + addl %eax, %eax + cmpl $0xffe00000, %eax setneb %al - andl $0x000000ff, %eax + movzbl %al, %eax ret END(finite)