[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20180608120532.GD17342@gate.crashing.org>
Date: Fri, 8 Jun 2018 07:05:32 -0500
From: Segher Boessenkool <segher@...nel.crashing.org>
To: Gabriel Paubert <paubert@...m.es>
Cc: Christophe Leroy <christophe.leroy@....fr>,
wei.guo.simon@...il.com, linux-kernel@...r.kernel.org,
Paul Mackerras <paulus@...ba.org>,
linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH v4 3/4] powerpc/lib: implement strlen() in assembly
On Fri, Jun 08, 2018 at 01:45:13PM +0200, Gabriel Paubert wrote:
> On Fri, Jun 08, 2018 at 10:20:41AM +0000, Christophe Leroy wrote:
> > + rlwinm. r8, r9, 0, 0xff000000
> > + beq 20f
> > + rlwinm. r8, r9, 0, 0x00ff0000
> > + beq 21f
> > + rlwinm. r8, r9, 0, 0x0000ff00
> > + beq 22f
> > +23: subf r3, r3, r10
>
> Actually these rlwinm. can likely be replaced by a single
> cntlzw /cntlzd; for 32 bit something like:
>
> cntlzw r8,r9
> subf r3,r3,r10
> srwi r8,r8,3
> add r3,r3,r8
> blr
The code is finding the first zero byte in the word, not how many leading
zero bytes there are.
Segher
Powered by blists - more mailing lists