All of lore.kernel.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Gabriel Paubert <paubert@iram.es>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>,
	wei.guo.simon@gmail.com, linux-kernel@vger.kernel.org,
	Paul Mackerras <paulus@samba.org>,
	linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH v4 3/4] powerpc/lib: implement strlen() in assembly
Date: Fri, 8 Jun 2018 07:05:32 -0500	[thread overview]
Message-ID: <20180608120532.GD17342@gate.crashing.org> (raw)
In-Reply-To: <20180608114513.gtgg7o4ejcqrjiz4@lt-gp.iram.es>

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

  reply	other threads:[~2018-06-08 12:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 10:20 [PATCH v4 1/4] selftests/powerpc: add test for 32 bits memcmp Christophe Leroy
2018-06-08 10:26 ` Christophe Leroy
2018-06-08 10:20 ` [PATCH v4 2/4] selftests/powerpc: Add test for strlen() Christophe Leroy
2018-06-08 10:20 ` [PATCH v4 3/4] powerpc/lib: implement strlen() in assembly Christophe Leroy
2018-06-08 11:45   ` Gabriel Paubert
2018-06-08 12:05     ` Segher Boessenkool [this message]
2018-06-08 10:20 ` [PATCH v4 4/4] selftests/powerpc: update strlen() test to test the new assembly function Christophe Leroy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180608120532.GD17342@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=christophe.leroy@c-s.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=paubert@iram.es \
    --cc=paulus@samba.org \
    --cc=wei.guo.simon@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.