+2024-05-13 Paul Eggert <eggert@cs.ucla.edu>
+
+ stdbit: redo clzll without lookcup table
+ * lib/stdbit.c (__gl_stdbit_clztab):
+ * lib/stdbit.in.h (__gl_stdbit_clzll):
+ [!_GL_STDBIT_HAS_BUILTIN_CLZ && !_MSC_VER]: Rewrite to avoid the
+ need for a lookup table in memory, and remove the lookup table.
+ Do this by shrinking the table to 64 bits and puttiung in a 64-bit
+ constant. Although this needs another round of shifts, it avoids
+ the need for a multiplication and memory access a la de Bruijn,
+ and is probably a win.
+
2024-05-13 Bruno Haible <bruno@clisp.org>
stdbit tests: Adhere better to Gnulib naming conventions.
#define _GL_STDBIT_INLINE _GL_EXTERN_INLINE
#include <stdbit.h>
-#if !defined _GL_STDBIT_HAS_BUILTIN_CLZ && !_MSC_VER
-/* __gl_stdbit_clztab[B] is the number of leading zeros in
- the 8-bit byte with value B. */
-char const __gl_stdbit_clztab[256] =
- {
- 8,
- 7,
- 6, 6,
- 5, 5, 5, 5,
- 4, 4, 4, 4, 4, 4, 4, 4,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
-
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
-
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
-
- /* The rest is zero. */
- };
-#endif
-
#if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64)
signed char __gl_stdbit_popcount_support;
#endif