Bit scanning operations in emscripten. #17632
-
I've been trying to port some code that relies on vectorclass library to emscripten. While patching in proper includes and removing dynamic dispatching logic fixed most of compilation errors, there is one blocker remaining: bit scan forward/reverse functions. So are there any built-in analogues in emscripten compiler or should I fall back to less efficient C++ implementation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
There's no single instruction that has the same behavior, but you can use |
Beta Was this translation helpful? Give feedback.
There's no single instruction that has the same behavior, but you can use
__builtin_ctz
and__builtin_popcount
to emulate it and those should lower to a single Wasm instruction each. Emscripten is a thin wrapper around clang at compile time, so it supports everything normal clang supports.