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

Clint Caywood via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jan 19 08:13:43 PST 2022


cratonica added inline comments.


================
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
----------------
sivachandra wrote:
> cratonica wrote:
> > sivachandra wrote:
> > > It seems to me like one can use `__builtin_clz` and avoid target assembly? For example: https://godbolt.org/z/eY8n8P118
> > Nice, that also works for ARM: https://godbolt.org/z/bY9nfEd16
> > 
> > Are we OK using such builtins in this library ? If so, should we get rid of the original find_leading_one() function altogether and just call __builtin_clz ? Or should it still be specialized for each architecture and delegate at that level?
> Yes, it is OK to use compiler builtins for this use case. We can get rid of the original `find_leading_one`.
Sent https://reviews.llvm.org/D117684


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