# wasm: Implement \`@ctz\` for bitsize \<= 64 · gitcafe/zig

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

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

Visibility: public

Requested revision: 2c40b37f79b1b40b5f22e13131064bcab2191f64

Requested commit: 2c40b37f79b1b40b5f22e13131064bcab2191f64

Commit: 2c40b37f79b1b40b5f22e13131064bcab2191f64

Tree: e6cec6c137fde02857b8ced426a4e725641ae707

Author: Luuk de Gram

Committer: Luuk de Gram

## Message

```
wasm: Implement `@ctz` for bitsize <= 64

Implements the `ctz` AIR instruction for integers with bitsize <= 64.
When the bitsize of the integer does not match the bitsize of a wasm type,
we first XOR the value with the value of (1<<bitsize) to set the right bits
and ensure we will only count the trailing zeroes of the integer with the correct bitsize.

```

## Parents

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

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