Bug 15018 - [PATCH] Use x86 BSR instruction in Log2 functions
Summary: [PATCH] Use x86 BSR instruction in Log2 functions
Status: RESOLVED FIXED
Alias: None
Product: xorg
Classification: Unclassified
Component: Driver/Radeon (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: xf86-video-ati maintainers
QA Contact: Xorg Project Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-14 19:19 UTC by Matt Turner
Modified: 2008-03-19 15:18 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Enable BSR in Log2 functions (961 bytes, patch)
2008-03-14 19:19 UTC, Matt Turner
no flags Details | Splinter Review

Description Matt Turner 2008-03-14 19:19:30 UTC
Created attachment 15133 [details] [review]
Enable BSR in Log2 functions

This patch edits RADEONLog2 and ATILog2 to use the x86 BSR instruction instead of looping through bits. It should provide a somewhat of a speed increase in this function on x86 and AMD64 architectures.

Note: the BSR instruction was added with the 80386 CPU and is therefore not compatible with earlier CPUs, though I highly doubt it's even possible to use a 286 in conjunction with a Radeon.

The inline assembly also works with Intel's compiler (icc).

Assembly output for current RADEONLog2:
RADEONLog2:
        testl   %edi, %edi
        movl    $-1, %eax
        je      .L4
        xorl    %eax, %eax
        .p2align 4,,7
.L5:
        addl    $1, %eax
        sarl    %edi
        jne     .L5
        subl    $1, %eax
.L4:
        rep ; ret

Assembly output for BSR-enabled RADEONLog2:
RADEONLog2:
        movl    %edi, %ecx
        bsrl    %ecx, %eax
        ret
Comment 1 Alex Deucher 2008-03-19 15:18:31 UTC
committed: 17cd42ed31814ba329a6a68edd0d75390a7da40e

Thanks


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.