This is an automated email from the git hooks/post-receive script.

ppm-guest pushed a commit to annotated tag v0.36
in repository libmath-prime-util-perl.

commit ea60ec1ae91f07aee3960cf30edf3c9341e82ec2
Author: Dana Jacobsen <d...@acm.org>
Date:   Mon Dec 23 11:35:49 2013 -0800

    Don't use GCC's builting popcount unless we have asm.  It can generate 
awful code.
---
 lmo.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/lmo.c b/lmo.c
index 2591cf7..518876f 100644
--- a/lmo.c
+++ b/lmo.c
@@ -86,9 +86,12 @@ typedef UV sword_t;
 #define SWORD_MASKBIT(bits)  (UVCONST(1) << ((bits) % SWORD_BITS))
 #define SWORD_CLEAR(s,bits)  s[bits/SWORD_BITS] &= ~SWORD_MASKBIT(bits)
 
-/* Compile with -march=native to get a very large speedup on new processors */
+/* GCC 3.4-4.1 has broken 64-bit popcount.  4.2+ can generate awful code when
+ * it doesn't have asm.  4.8 seems to generate similar code to the below.
+ * Hence, only use the builtin when we have asm.
+ * Compile with -march=native to get a big speedup on newer processors. */
 #if SWORD_BITS == 64
- #if defined(__GNUC__) && (__GNUC__> 4 || (__GNUC__== 4 && __GNUC_MINOR__> 1))
+ #if defined(__POPCNT__) && defined(__GNUC__) && (__GNUC__> 4 || (__GNUC__== 4 
&& __GNUC_MINOR__> 1))
    #define bitcount(b)  __builtin_popcountll(b)
  #else
    static sword_t bitcount(sword_t b) {
@@ -590,13 +593,14 @@ UV _XS_LMO_pi(UV n)
      * phi(n / (x*primes[k+1]), k).  The inner for loop can be parallelized. */
     for (; k < step7_max; k++) {
       remove_primes(k, k, &ss, primes);
-      if (ss.prime_index[k] >= k+2) {
+      j = ss.prime_index[k];
+      if (j >= k+2) {
         UV pk = primes[k+1];
-        UV endj = ss.prime_index[k];
+        UV endj = j;
         while (endj > 7 && endj-7 >= k+2 && pk*primes[endj-7] > least_divisor) 
endj -= 8;
         while (            endj   >= k+2 && pk*primes[endj  ] > least_divisor) 
endj--;
         /* Now that we know how far to go, do the summations */
-        for (j = ss.prime_index[k]; j > endj; j--)
+        for ( ; j > endj; j--)
           sum1 += sieve_phi(n / (pk*primes[j]));
         ss.prime_index[k] = endj;
       }

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to