From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15089 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] math: move x86_64 fabs, fabsf to C with inline asm Date: Sun, 5 Jan 2020 15:05:41 -0500 Message-ID: <20200105200541.GM30412@brightrain.aerifal.cx> References: <20200105163639.25963-1-amonakov@ispras.ru> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="151189"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-15105-gllmg-musl=m.gmane.org@lists.openwall.com Sun Jan 05 21:05:59 2020 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1ioC9u-000dDK-QN for gllmg-musl@m.gmane.org; Sun, 05 Jan 2020 21:05:58 +0100 Original-Received: (qmail 28342 invoked by uid 550); 5 Jan 2020 20:05:56 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 28324 invoked from network); 5 Jan 2020 20:05:55 -0000 Content-Disposition: inline In-Reply-To: <20200105163639.25963-1-amonakov@ispras.ru> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:15089 Archived-At: On Sun, Jan 05, 2020 at 07:36:39PM +0300, Alexander Monakov wrote: > --- > > Questions: > > Why are there amd64-specific fabs implementations in the first place? > (Only) because GCC generated poor code for the generic C version? I think so. It generates: 0000000000000000 : 0: 66 48 0f 7e c0 movq %xmm0,%rax 5: 48 ba ff ff ff ff ff movabs $0x7fffffffffffffff,%rdx c: ff ff 7f f: 48 21 d0 and %rdx,%rax 12: 48 89 44 24 f8 mov %rax,-0x8(%rsp) 17: f2 0f 10 44 24 f8 movsd -0x8(%rsp),%xmm0 1d: c3 retq > Do annotations for mask manipulation in the patch help? Any way to make > them less ambiguous? I think so. I like how you did individual asm statements with dependency relationship between them so compiler could even schedule them if it likes. I wonder if you could just write 0x7fffffffffffffff as an operand and have the compiler load it, though. Rich