[libc-commits] [PATCH] D117584: [libc] Specialize portion of hypot for x86_64 CPUs.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jan 18 14:04:04 PST 2022


sivachandra added inline comments.


================
Comment at: libc/src/__support/x86_64/find_leading_one.h:20
+template <typename T>
+inline int __llvm_libc::internal::find_leading_one(T value) {
+  static_assert(
----------------
Nit: `msbit_pos` is probably a more appropriate name?


================
Comment at: libc/src/__support/x86_64/find_leading_one.h:28-31
+  __asm__("bsr %[value], %[value]"
+          : [value] "=r"(value)
+          : "0"(value)
+          : "flags"); // Clobbers ZF
----------------
It seems to me like one can use `__builtin_clz` and avoid target assembly? For example: https://godbolt.org/z/eY8n8P118


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117584



More information about the libc-commits mailing list