Skip to content

Native Map.msb.u walks the bits of each U32 query #1709

Closed

Description

@oxura

The C backend on e5527d5 still runs Map.msb.u's recursive Base body: shift until zero or fuel exhaustion. #1703/#1682 cover the JS backend, not this one.

The native patch computes the U32 width with CLZ and limits it by the original Nat fuel. Zero input and zero fuel both return zero; fuel is not narrowed to U32. No change to Base or the checker.

Real behavior proof: the shared reproducer in #1708 runs one million data-dependent queries. Both builds returned 18575001; nine alternating runs measured median 31.207 ms before and 2.371 ms after. Compiled C and JS boundary programs also agree at fuel 0/1/31/32/99 and U32 values 0/1/2^31/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