]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
factor: tweak gcd_odd performance
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 26 Sep 2024 00:42:13 +0000 (17:42 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 28 Sep 2024 00:42:58 +0000 (17:42 -0700)
* src/factor.c (gcd_odd): Use stdc_trailing_zeros instead of
counting zeros by hand.

src/factor.c

index 0e9e703df45e989fda8b7b08855192a15fde27c8..13fb92f8de4dd5d6f63bb40e0cb9b3725dae3cc7 100644 (file)
@@ -413,8 +413,8 @@ gcd_odd (uintmax_t a, uintmax_t b)
       uintmax_t t;
       uintmax_t bgta;
 
-      while ((a & 1) == 0)
-        a >>= 1;
+      assume (a);
+      a >>= stdc_trailing_zeros (a);
       a >>= 1;
 
       t = a - b;