Repository navigation
Conversation
|
Tagging subscribers to this area: @BrzVlad |
| MINT_IN_BREAK; | ||
| } | ||
| MINT_IN_CASE(MINT_INTRINS_BITOPS_LOG2_32) { | ||
| sp [-1].data.i = 31 ^ (gint32)__builtin_clz ((guint32)sp [-1].data.i | 1); |
There was a problem hiding this comment.
__builtin_clz uses bsr since we don't set -march=native or -mattr+ https://godbolt.org/z/bMqcM5
lzcnt makes it even faster.
There was a problem hiding this comment.
This might need an ifdef gcc or something.
There was a problem hiding this comment.
@vargaz works fine on clang and should be correctly expanded for Arm
There was a problem hiding this comment.
With MSVC, we can use _BitScan{Forward,Reverse} with this conversion. (can be wrapped in a macro?)
There was a problem hiding this comment.
@EgorBo you could extract sgen_clz out of sgen into utils and reuse it here. We have the logic there to use _BitScan on msvc
It's used in NumberFormatter, Array.Sort and SpanHelpers.
e.g. the following code uses it under the hood:
235235235325.ToString("X")^ For Mono-Wasm:
before: 18.4 ms (in a loop)
after: 15.2 ms