Fix PR gcov-profile/55734 by using methods from hwint.c instead of builtins...
authorTeresa Johnson <tejohnson@google.com>
Thu, 20 Dec 2012 14:31:09 +0000 (14:31 +0000)
committerTeresa Johnson <tejohnson@gcc.gnu.org>
Thu, 20 Dec 2012 14:31:09 +0000 (14:31 +0000)
commitd5ae0ba6636d9d5e8b24b0859b860365aa4d943c
treee5a6383c98a0438b7479e18dbadac925bec0cc5a
parent63f2ff0f23d633aad769997ec617ce2177c311ec
Fix PR gcov-profile/55734 by using methods from hwint.c instead of builtins...

Fix PR gcov-profile/55734 by using methods from hwint.c instead of
builtins, to handle non-GCC and older versions of GCC. When building
libgcov.a, however, hwint.c is not available, but we are always using
the bootstrapped compiler and can therefore use the builtins.

Use __builtin_popcount instead of __builtin_popcountll, since we
are operating on an int.

Use floor_log2 directly, instead of clz_hwi for the non-libgcov case,
and handle situations where the size of the gcov_type is bigger than
HOST_WIDE_INT. Verified that the various cases compiled by forcing
different HOST_BITS_PER_WIDE_INT values.

2012-12-20  Teresa Johnson  <tejohnson@google.com>
            Jakub Jelinek  <jakub@redhat.com>

        PR gcov-profile/55734
* gcov-io.c (gcov_read_summary): Use __builtin_popcount instead
        of __builtin_popcountll when building libgcov.a, otherwise use
        popcount_hwi.
(gcov_histo_index): When not building libgcov.a, use floor_log2
        instead of __builtin_clzll.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r194634
gcc/ChangeLog
gcc/gcov-io.c