]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - sysdeps/x86_64/ffsll.c
x86_64: Optimize ffsll function code size.
[thirdparty/glibc.git] / sysdeps / x86_64 / ffsll.c
index 1caf6ac15514c4031e5199485c33b0452adc32fe..ef686da5ca7c2340cedda782b2dbfd4ed6ff0e89 100644 (file)
@@ -27,13 +27,13 @@ int
 ffsll (long long int x)
 {
   long long int cnt;
-  long long int tmp;
 
-  asm ("bsfq %2,%0\n"          /* Count low bits in X and store in %1.  */
-       "cmoveq %1,%0\n"                /* If number was zero, use -1 as result.  */
-       : "=&r" (cnt), "=r" (tmp) : "rm" (x), "1" (-1));
+  asm ("mov $-1,%k0\n" /* Initialize cnt to -1.  */
+       "bsf %1,%0\n"   /* Count low bits in x and store in cnt.  */
+       "inc %k0\n"     /* Increment cnt by 1.  */
+       : "=&r" (cnt) : "r" (x));
 
-  return cnt + 1;
+  return cnt;
 }
 
 #ifndef __ILP32__