DragonFly BSD
DragonFly submit List (threaded) for 2010-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

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


From: "Venkatesh Srinivas \(via DragonFly issue tracker\)" <sinknull@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 26 May 2010 05:14:01 +0000

Venkatesh Srinivas <me@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@lists.dragonflybsd.org>
<http://bugs.dragonflybsd.org/issue1770>
_____________________________________________________

Attachment: 0001-libc-Add-assembler-ffs-fls-ffsl-flsl-to-i386-and.patch
Description: Binary data



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]