From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,LOTS_OF_MONEY,MAILING_LIST_MULTI,MONEY_NOHTML, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5334 invoked from network); 7 Aug 2021 13:26:18 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 7 Aug 2021 13:26:18 -0000 Received: (qmail 15725 invoked by uid 550); 7 Aug 2021 13:26:12 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 15704 invoked from network); 7 Aug 2021 13:26:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexgo.de; s=vfde-smtpout-mb-15sep; t=1628342692; bh=ue81Uvdyy0/aC77pwNCpA1FGz4lAJ/ezchbSFBceBr0=; h=From:To:Cc:References:In-Reply-To:Subject:Date; b=UFyijSfRCbWj6Iy7bZQyCBbHCnB54Q+IPDnu4nW+lOER+hFg8KHGJ1Vxlj/s9F/o0 wkVUJ1Nk9Ik8xoDMK/uk7c35UJJcUW1uC+bz4s07B1jbw//ykyCj8Rhziy7p2X0gi+ AbxpNvpT9MZ44BL7lnP4YiJE9xMijDTs73lbr2Tk= Message-ID: From: "Stefan Kanthak" To: "Rich Felker" Cc: "Alexander Monakov" , "Szabolcs Nagy" , References: <04BD4026EE364FF7AFBAF8C593E9A2E7@H270> <20210803202735.GA37904@port70.net> <6C4DCCC86B014B68877D73C798F54180@H270> <20210806142702.GV13220@brightrain.aerifal.cx> <35E4CF2B08294E46B0451043F46D2C7C@H270> <20210807005558.GX13220@brightrain.aerifal.cx> In-Reply-To: <20210807005558.GX13220@brightrain.aerifal.cx> Date: Sat, 7 Aug 2021 15:12:14 +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-purgate-type: clean X-purgate-Ad: Categorized by eleven eXpurgate (R) http://www.eleven.de X-purgate: This mail is considered clean (visit http://www.eleven.de for further information) X-purgate: clean X-purgate-size: 2117 X-purgate-ID: 155817::1628342691-00003C24-C7955977/0/0 Subject: Re: [musl] [Patch] src/math/i386/remquo.s: remove conditional branch, shorter bit twiddling Rich Felker wrote: > On Fri, Aug 06, 2021 at 07:23:19PM +0200, Stefan Kanthak wrote: >> Rich Felker wrote: >> > The path forward for all the math asm is moving it to inline asm in C >> > files, with no flow control or bit/register shuffling in the asm, only >> > using asm for the single instructions. I'd even go a step further and put all those short functions into header files to give the compiler a chance to properly them in context. And then get rid of all the __builtin_* bloat GCC unfortunately carries with it... >> > I haven't read the mul trick here in detail but I believe it should be >> > duplicable with plain C * operator. >> >> It is. > > Great! Does it improve the code generation? Of course: the same 3 instructions Alexander showed here: remquol: fldt 16(%esp) fldt 4(%esp) .L2: #APP # 19 "remquol.c" 1 fprem1; fnstsw %ax # 0 "" 2 #NO_APP testb $4, %ah jne .L2 fstp %st(1) andl $17152, %eax # movzbl 15(%esp), %ecx # this should be movb 15(%esp), %cl imull $9502720, %eax, %eax # shrl $29, %eax # movl %eax, %edx negl %edx xorb 27(%esp), %cl cmovs %edx, %eax movl 28(%esp), %edx movl %eax, (%edx) ret The code to flip the sign is but not as short as in the assembly version I posted; the following change may give shorter code: int sign = (*cx^*cy) >> 7; qbits += sign; qbits ^= sign; >> > I really do not want to review/merge asm changes that keep this kind >> > of complex logic in asm when there's no strong motivation for it (like >> > fixing an actual bug, vs just reducing size or improving speed). The >> > risk to reward ratio is just not reasonable. >> >> Final patch attached! > > Thanks. I don't mind making any final tweaks needed, if necessary. Do so as you will and wish: I don't mind^W^Wappreciate if someone can improve code I've written. Stefan