From owner-freebsd-numerics@freebsd.org Fri Sep 6 10:54:45 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 A1351F0243 for ; Fri, 6 Sep 2019 10:54:45 +0000 (UTC) (envelope-from stefan.kanthak@nexgo.de) Received: from vsmx009.vodafonemail.xion.oxcs.net (vsmx009.vodafonemail.xion.oxcs.net [153.92.174.87]) (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 46PvZn2mgmz4C0v; Fri, 6 Sep 2019 10:54:40 +0000 (UTC) (envelope-from stefan.kanthak@nexgo.de) Received: from vsmx001.vodafonemail.xion.oxcs.net (unknown [192.168.75.191]) by mta-5-out.mta.xion.oxcs.net (Postfix) with ESMTP id 3057B15A6534; Fri, 6 Sep 2019 10:54:38 +0000 (UTC) Received: from H270 (unknown [93.230.223.140]) by mta-5-out.mta.xion.oxcs.net (Postfix) with ESMTPA id C621515A5D1E; Fri, 6 Sep 2019 10:54:33 +0000 (UTC) Message-ID: <582553CAF6B647A09A15C24F50B9A75E@H270> From: "Stefan Kanthak" To: Cc: Subject: Superfluous instructions in crufty old releng/12.0/lib/msun/i387/s_remquo.S, releng/12.0/lib/msun/amd64/s_remquo.S, ... Date: Fri, 6 Sep 2019 12:45: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: 46PvZn2mgmz4C0v 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.87 as permitted sender) smtp.mailfrom=stefan.kanthak@nexgo.de X-Spamd-Result: default: False [-2.24 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-0.94)[-0.935,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]; MIME_TRACE(0.00)[0:+]; 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)[]; NEURAL_HAM_LONG(-1.00)[-0.998,0]; RCPT_COUNT_TWO(0.00)[2]; HAS_X_PRIO_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.40)[-0.402,0]; IP_SCORE(-0.00)[country: DE(-0.01)]; FROM_EQ_ENVFROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[87.174.92.153.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:60664, ipnet:153.92.174.0/24, country:DE]; MID_RHS_NOT_FQDN(0.50)[]; RECEIVED_SPAMHAUS_PBL(0.00)[140.223.230.93.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.10] 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: Fri, 06 Sep 2019 10:54:45 -0000 Hi, although I doubt that this FPU code might still be used, here's a patch to shave 2 superfluous instructions from http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_remquo.S http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_remquof.S http://sources.freebsd.org/releng/12.0/lib/msun/i387/s_remquol.S http://sources.freebsd.org/releng/12.0/lib/msun/amd64/s_remquo.S http://sources.freebsd.org/releng/12.0/lib/msun/amd64/s_remquof.S http://sources.freebsd.org/releng/12.0/lib/msun/amd64/s_remquol.S regards Stefan Kanthak --- -/releng/12.0/lib/msun/i387/s_remquo.S +++ +/releng/12.0/lib/msun/i387/s_remquo.S @@ -51,8 +51,6 @@ /* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */ movl 16(%esp),%ecx xorl 8(%esp),%ecx - sarl $16,%ecx - sarl $16,%ecx + sarl $31,%ecx xorl %ecx,%eax - andl $1,%ecx - addl %ecx,%eax + subl %ecx,%eax --- -/releng/12.0/lib/msun/i387/s_remquof.S +++ +/releng/12.0/lib/msun/i387/s_remquof.S @@ -51,8 +51,6 @@ /* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */ movl 8(%esp),%ecx xorl 4(%esp),%ecx - sarl $16,%ecx - sarl $16,%ecx + sarl $31,%ecx xorl %ecx,%eax - andl $1,%ecx - addl %ecx,%eax + subl %ecx,%eax --- -/releng/12.0/lib/msun/i387/s_remquol.S +++ +/releng/12.0/lib/msun/i387/s_remquol.S @@ -51,9 +51,7 @@ /* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */ movl 24(%esp),%ecx xorl 12(%esp),%ecx movsx %cx,%ecx sarl $16,%ecx - sarl $16,%ecx xorl %ecx,%eax - andl $1,%ecx - addl %ecx,%eax + subl %ecx,%eax --- -/releng/12.0/lib/msun/amd64/s_remquo.S --- +/releng/12.0/lib/msun/amd64/s_remquo.S @@ -53,8 +53,6 @@ /* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */ movl -12(%rsp),%ecx xorl -4(%rsp),%ecx - sarl $16,%ecx - sarl $16,%ecx + sarl $31,%ecx xorl %ecx,%eax - andl $1,%ecx - addl %ecx,%eax + subl %ecx,%eax --- -/releng/12.0/lib/msun/amd64/s_remquof.S --- +/releng/12.0/lib/msun/amd64/s_remquof.S @@ -53,8 +53,6 @@ /* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */ movl -8(%rsp),%ecx xorl -4(%rsp),%ecx - sarl $16,%ecx - sarl $16,%ecx + sarl $31,%ecx xorl %ecx,%eax - andl $1,%ecx - addl %ecx,%eax + subl %ecx,%eax --- -/releng/12.0/lib/msun/amd64/s_remquol.S --- +/releng/12.0/lib/msun/amd64/s_remquol.S @@ -51,9 +51,6 @@ /* Negate the quotient bits if x*y<0. Avoid using an unpredictable branch. */ movl 32(%rsp),%ecx xorl 16(%rsp),%ecx movsx %cx,%ecx sarl $16,%ecx - sarl $16,%ecx xorl %ecx,%eax - andl $1,%ecx - addl %ecx,%eax + subl %ecx,%eax