lkml.org 
[lkml]   [2018]   [Jun]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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

\
 
 \ /
  Last update: 2018-06-08 14:07    [W:0.172 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site