[libc-commits] [PATCH] D136488: [libc.search] [PATCH 2/6] add ctz/clz for unsigned short

Guillaume Chatelet via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Oct 25 03:28:35 PDT 2022


gchatelet added a comment.

In D136488#3880100 <https://reviews.llvm.org/D136488#3880100>, @SchrodingerZhu wrote:

> @gchatelet Hi, this is intended to be used in https://reviews.llvm.org/D136490. SSE2 movemask operations on byte vectors will give 16-bit masks and we want to use that to locate available bucket slot in hash table.

I see, thx for the context.

I would like to get some tests as well.

Also `__has_builtin` only exists from gcc 10.0 on. You first need to check that it is defined first <https://github.com/llvm/llvm-project/blob/3d9bf8ce7bdf96f8b3cd9ed8b5ec696f537cc8de/libc/src/__support/CPP/bit.h#L14-L18>.



================
Comment at: libc/src/__support/builtin_wrappers.h:34
+  return __builtin_clz(static_cast<unsigned int>(val)) -
+         8 * (sizeof<unsigned int> - sizeof<unsigned short>);
+#endif
----------------
`sizeof` is a function not a template, these should be parentheses and not brackets.


================
Comment at: libc/src/__support/builtin_wrappers.h:52
+#else
+  return __builtin_ctzs(static_cast<unsigned int>(val));
+#endif
----------------
This is supposed to be `__builtin_ctz` right?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136488/new/

https://reviews.llvm.org/D136488



More information about the libc-commits mailing list