Skip to content

Native U32.log2 retains the Base bit search in numeric folds #1710

Closed

Description

@oxura

On e5527d5, U32.log2 has no C intrinsic. Numeric folds keep the Base bit search instead of using the backend's existing CLZ operation. #1688/#1682 are the JS-specific work.

The native expression is 31 - CLZ(x | 1), so log2(0) stays 0 and there is no undefined zero-input CLZ. Base's Nat-valued result and checked definition stay unchanged.

Real behavior proof: the shared fixture in #1708 returns 29999970 in both arms for one million changing U32 values. Nine alternating CPU runs measured medians 2.825 ms before and 1.579 ms after. The permanent C/JS program checks zero, adjacent small powers, 2^31-1, 2^31 and 2^32-1.

Patch: oxura@ba5a8b1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions