* cntlzw @ 2008-06-03 20:06 Kevin Diggs 2008-06-03 20:11 ` cntlzw Scott Wood 0 siblings, 1 reply; 3+ messages in thread From: Kevin Diggs @ 2008-06-03 20:06 UTC (permalink / raw) To: linuxppc-dev 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? kevin ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cntlzw 2008-06-03 20:06 cntlzw Kevin Diggs @ 2008-06-03 20:11 ` Scott Wood 2008-06-06 9:53 ` cntlzw Matt Sealey 0 siblings, 1 reply; 3+ messages in thread From: Scott Wood @ 2008-06-03 20:11 UTC (permalink / raw) To: Kevin Diggs; +Cc: linuxppc-dev 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: cntlzw 2008-06-03 20:11 ` cntlzw Scott Wood @ 2008-06-06 9:53 ` Matt Sealey 0 siblings, 0 replies; 3+ messages in thread From: Matt Sealey @ 2008-06-06 9:53 UTC (permalink / raw) To: Scott Wood; +Cc: linuxppc-dev, Kevin Diggs 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 <matt@genesi-usa.com> 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 ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-06-06 9:53 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-06-03 20:06 cntlzw Kevin Diggs 2008-06-03 20:11 ` cntlzw Scott Wood 2008-06-06 9:53 ` cntlzw Matt Sealey
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).