[PATCH] D86547: [compiler-rt][builtins] Use c[tl]zsi macro instead of __builtin_c[tl]z
Ayke via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 17 05:13:06 PST 2022
aykevl added inline comments.
Comment at: compiler-rt/lib/builtins/fp_extend.h:32-39
#if defined __LP64__
if (a & REP_C(0xffffffff00000000))
- return __builtin_clz(a >> 32);
+ return clzsi(a >> 32);
+ return 32 + clzsi(a & REP_C(0xffffffff));
> Perhaps more reliable would be the following:
> #if ULONG_MAX == 0xFFFFFFFFFFFFFFFF
> return __builtin_clzl(a);
> #elif ULLONG_MAX == 0xFFFFFFFFFFFFFFFF
> return __builtin_clzll(a);
> #error Unsupported platform
> This is what I've also used in int_types.h to detect clzsi etc. It probably would need to be tested on some more architectures though (32 and 64 bit).
In fact, it might be possible to use `__builtin_clzll` for all platforms (it maps to 'long long', which I think is 64-bit practically everywhere).
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
More information about the cfe-commits