From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gv-out-0910.google.com (gv-out-0910.google.com [216.239.58.189]) by ozlabs.org (Postfix) with ESMTP id 28794DDFC6 for ; Fri, 6 Jun 2008 19:53:26 +1000 (EST) Received: by gv-out-0910.google.com with SMTP id y18so321517gvf.14 for ; Fri, 06 Jun 2008 02:53:17 -0700 (PDT) Message-ID: <48490909.4020901@genesi-usa.com> Date: Fri, 06 Jun 2008 10:53:13 +0100 From: Matt Sealey MIME-Version: 1.0 To: Scott Wood Subject: Re: cntlzw References: <4845A44D.20404@hypersurf.com> <4845A55E.2030503@freescale.com> In-Reply-To: <4845A55E.2030503@freescale.com> Content-Type: text/plain; charset=UTF-8; format=flowed Sender: Matt Sealey Cc: linuxppc-dev@ozlabs.org, Kevin Diggs List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , It's in the Compiler Writer's Guide with explanation; section 5-10. http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF7785256996007558C6 There are lots of clever examples in there, it's definitely recommended reading (I should make a cheat sheet of chapter 5 though so I can pin it to my wall) -- Matt Sealey Genesi, Manager, Developer Relations Scott Wood wrote: > Kevin Diggs wrote: >> Hi, >> >> x86 has bsf and bsr. PPC has cntlzw which I think is equivalent to >> bsr. Anyone know of a sneaky algorithm to do bsf? > > wordsize - 1 - cntlzw(x & ~(x - 1)); > > -Scott > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev