From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/15123 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 more x86-family lrint functions to C Date: Sat, 11 Jan 2020 11:22:34 -0500 Message-ID: <20200111162234.GE30412@brightrain.aerifal.cx> References: <20200111152354.5743-1-amonakov@ispras.ru> <20200111160701.GC30412@brightrain.aerifal.cx> 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="28820"; 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-15139-gllmg-musl=m.gmane-mx.org@lists.openwall.com Sat Jan 11 17:23:58 2020 Return-path: Envelope-to: gllmg-musl@m.gmane-mx.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.89) (envelope-from ) id 1iqJXG-0010jo-92 for gllmg-musl@m.gmane-mx.org; Sat, 11 Jan 2020 17:22:50 +0100 Original-Received: (qmail 25954 invoked by uid 550); 11 Jan 2020 16:22:46 -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 25933 invoked from network); 11 Jan 2020 16:22:46 -0000 Content-Disposition: inline In-Reply-To: <20200111160701.GC30412@brightrain.aerifal.cx> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:15123 Archived-At: On Sat, Jan 11, 2020 at 11:07:01AM -0500, Rich Felker wrote: > On Sat, Jan 11, 2020 at 06:23:54PM +0300, Alexander Monakov wrote: > > --- > > It was news to me that GCC inline asm conventions allow to specify > > effect on x87 register stack. Here a clobber tells the compiler > > that the asm pops the topmost element off the stack. > > Is this documented/reliable/supported by other compilers (clang, pcc, > old gcc)? It looks very nice and I hope we can do it; otherwise it > looks like a gratuitous instruction would be needed. But I want to > make sure it's safe. OK, I see it documented at the end of the page here: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html under 6.47.2.9 x86 Floating-Point asm Operands. So if other compilers don't honor this they're not implementing it as documented. I noticed also there (bullet point 5) that, if inline asm pushes anything to x87 stack, it needs appropriate clobbers so the compiler can ensure the stack is not full on entry. This would be easy to miss because the stack will be empty in standalone functions, and it would only come up if they get inlined via LTO. Rich