[issue1770] Patch for i386 to use bsrl for libc fls().

Venkatesh Srinivas (via DragonFly issue tracker) sinknull at leaf.dragonflybsd.org
Tue May 25 22:14:57 PDT 2010


Venkatesh Srinivas <me at acm.jhu.edu> added the comment:

Hi,

This is an improved version of the patch that corrects my silly jz mistake and 
adds ffsl and flsl. It also implements both for x86_64. The x86-64 version is 
branchless, using cmov.

This alternate snippet may be better and would allow for a branchless f?f(l) on 
i386, except bsr and bsf are defined differently on Intel and AMD x86 machines. 
It may be better on x86_64 than the cmov-based version:
        xorl    %eax, %eax
        xorl    %ecx, %ecx
        bsrl    4(%esp), %eax
        setnz   %cl
        addl    %ecx, %eax
        ret

Thanks,
-- vs

_____________________________________________________
DragonFly issue tracker <bugs at lists.dragonflybsd.org>
<http://bugs.dragonflybsd.org/issue1770>
_____________________________________________________Attachment:
0001-libc-Add-assembler-ffs-fls-ffsl-flsl-to-i386-and.patch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bin00000.bin
Type: application/octet-stream
Size: 13061 bytes
Desc: "Description: Binary data"
URL: <http://lists.dragonflybsd.org/pipermail/submit/attachments/20100525/3b840426/attachment-0014.bin>


More information about the Submit mailing list