Project

General

Profile

Actions

Bug #1770

closed

Patch for i386 to use bsrl for libc fls().

Added by vsrinivas almost 14 years ago. Updated almost 14 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Hi,

A patch to libc to use bsr for ffs.

Thanks,
-- vs


Files

Actions #1

Updated by vsrinivas almost 14 years ago

Also, let's pretend I didn't make a silly mistake.

The jz 1 and label 1: should become jz L1 and L1:

Jumping to the address 0x1 is silly.

Actions #2

Updated by TGEN almost 14 years ago

On 05/25/2010 16:15, Venkatesh Srinivas (via DragonFly issue tracker) wrote:

Also, let's pretend I didn't make a silly mistake.
The jz 1 and label 1: should become jz L1 and L1:

Jumping to the address 0x1 is silly.

You can keep the label as 1: and use jz 1f instead (the f is for
'forward', as opposed to b, 'backward').

Cheers,
--
Thomas E. Spanjaard

Actions #3

Updated by vsrinivas almost 14 years ago

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

Actions #4

Updated by vsrinivas almost 14 years ago

I just tested the i386 fls against its C equivalent on every input, to see that
it produces the same output; it passed. Running the C version, optimized by
gcc, took 49 sec on my hardware, the assembler version 10sec.

The x86_64 version is tested on a few test inputs, but not in the Dfly libc,
only as standalone .S files.

Actions #5

Updated by vsrinivas almost 14 years ago

Correct a whilespace issue when patch is used.

Actions #6

Updated by vsrinivas almost 14 years ago

x86_64 doesn't have DEFS.h.

Actions #7

Updated by dillon almost 14 years ago

:
:Venkatesh Srinivas <> added the comment:
:
:x86_64 doesn't have DEFS.h.

Vekatesh, could you roll up all these patches and throw them into
you git repo? It's easier to bring them in and test them that way.
-Matt
Actions #8

Updated by vsrinivas almost 14 years ago

Okay - its in my git tree on leaf, branch libc-asm.

-- vs

Actions #9

Updated by vsrinivas almost 14 years ago

Resolved by commit 6cb1335d825070c7c4f5f0267d2b4c4b7dfd86be.

Actions

Also available in: Atom PDF