aykevl added inline comments.

================
Comment at: compiler-rt/lib/builtins/fp_extend.h:32-39
 #if defined __LP64__
   return __builtin_clzl(a);
 #else
   if (a & REP_C(0xffffffff00000000))
-    return __builtin_clz(a >> 32);
+    return clzsi(a >> 32);
   else
+    return 32 + clzsi(a & REP_C(0xffffffff));
----------------
aykevl wrote:
> Perhaps more reliable would be the following:
> 
> ```
> #if ULONG_MAX == 0xFFFFFFFFFFFFFFFF
>   return __builtin_clzl(a);
> #elif ULLONG_MAX == 0xFFFFFFFFFFFFFFFF
>   return __builtin_clzll(a);
> #else
>   #error Unsupported platform
> #endif
> ```
> 
> 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).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86547

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to