Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test performance with -mlzcnt #79

Open
theuni opened this issue Mar 31, 2023 · 1 comment
Open

Test performance with -mlzcnt #79

theuni opened this issue Mar 31, 2023 · 1 comment

Comments

@theuni
Copy link
Contributor

theuni commented Mar 31, 2023

At the moment the __builtin_clz* compile down to bsrq on x86_64. Compiling with -mlzcnt wires up the actual instruction.

CountBits<unsigned long long> without -mlzcnt:

_Z9CountBitsmi:
.LFB189:
    .cfi_startproc
    endbr64
    xorl    %eax, %eax
    testq   %rdi, %rdi
    je  .L1
    bsrq    %rdi, %rdi
    movl    $64, %eax
    xorq    $63, %rdi
    subl    %edi, %eax

CountBits<unsigned long long> with -mlzcnt:

_Z9CountBitsmi:
.LFB189:
    .cfi_startproc
    endbr64
    xorl    %eax, %eax
    testq   %rdi, %rdi
    je  .L1
    movl    $64, %eax
    lzcntq  %rdi, %rdi
    subl    %edi, %eax

I'm unable to test the significance of that because my CPU does not support the instruction. But I assume @sipa would probably know right away whether it's worth bothering.

@theuni theuni changed the title Test performance with -lzcnt Test performance with -mlzcnt Mar 31, 2023
@fanquake
Copy link
Contributor

Related to #80.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants