# wasm: Implement \`@clz\` · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/bd27fe2bf58d72dd0cdef73dd4040f2747215b78)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: bd27fe2bf58d72dd0cdef73dd4040f2747215b78

Requested commit: bd27fe2bf58d72dd0cdef73dd4040f2747215b78

Commit: bd27fe2bf58d72dd0cdef73dd4040f2747215b78

Tree: 1eb058d93436940069ae6bf578207b3c1b1d7f67

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Implement `@clz`

Implements the `clz` AIR instruction for integers with bitsize <= 64.
When the bitsize of the integer is not the same as wasm's bitsize,
we substract the difference in bits as those will always be 0 for the integer, but should
not be counted towards the end result. We also wrap the result to ensure it fits
in the result type as documented in the language reference.

```

## Parents

- [5ba03369ee11b6b57dcad99ab7ed8ce3b08c7456](https://git.cafe/gitcafe/zig/commit/5ba03369ee11b6b57dcad99ab7ed8ce3b08c7456?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/bd27fe2bf58d72dd0cdef73dd4040f2747215b78?format=markdown)
