Skip to content

<bit>: Concern about lzcnt used as bsr correctness #1103

@AlexGuteniev

Description

@AlexGuteniev

@statementreply asks:

I’m concerned about the correctness of our x86/x64 implementation of countl_zero, on CPUs without LZCNT support.

// We use lzcnt (actually bsr if lzcnt is not supported)

bsr(x) == integer_width - 1 - lzcnt(x) when x != 0, so the fallback won’t work.
I currently don’t have access to a computer with pre-AVX2 CPU. Could someone help testing this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions