cntlzw
From: Kevin Diggs <hidden>
Date: 2008-06-03 20:07:10
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
3 messages, 3 authors, 2008-06-06 · open the first message on its own page
From: Kevin Diggs <hidden>
Date: 2008-06-03 20:07:10
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
From: Scott Wood <hidden>
Date: 2008-06-03 20:11:27
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
From: Matt Sealey <hidden>
Date: 2008-06-06 09:53:26
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 [off-list ref] Genesi, Manager, Developer Relations Scott Wood wrote:
Kevin Diggs wrote:quoted
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