From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7880) id 78D0C3858C2B; Tue, 22 Nov 2022 13:13:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78D0C3858C2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669122830; bh=FPQ/MUeZYgrJXNu5Vq1pSmPPL7FAvauO+rS1lYQ47OY=; h=From:To:Subject:Date:From; b=H6Srr0eC+7beCEXdlzh2HS4OWkVwmdOF8WvCP2TFCJXOULJhcDupYROLZ0+LVw7Ez 3gyQH/tbsbnfGmTasQ1NL6nyD+FEnqk6exLblGpc+DDOa3TF61Lp14rTZbm7j3YtUx tovLN0VOrYwNbZW4LuREclILLARNPGtN3BxIdzfs= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ondrej Kubanek To: gcc-cvs@gcc.gnu.org Subject: [gcc(refs/users/kubaneko/heads/histogram)] temporary log fix X-Act-Checkin: gcc X-Git-Author: kubaneko X-Git-Refname: refs/users/kubaneko/heads/histogram X-Git-Oldrev: 8627e4f45ad51e346755b8a0aa81a96111459399 X-Git-Newrev: 2233c2e840936a801cee3c9c8c613edf39c52fdf Message-Id: <20221122131350.78D0C3858C2B@sourceware.org> Date: Tue, 22 Nov 2022 13:13:50 +0000 (GMT) List-Id: https://gcc.gnu.org/g:2233c2e840936a801cee3c9c8c613edf39c52fdf commit 2233c2e840936a801cee3c9c8c613edf39c52fdf Author: kubaneko Date: Tue Nov 1 19:36:38 2022 +0000 temporary log fix Diff: --- libgcc/libgcov-profiler.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c index 8088f3d647a..b5912f53917 100644 --- a/libgcc/libgcov-profiler.c +++ b/libgcc/libgcov-profiler.c @@ -53,7 +53,6 @@ floor_log2 (gcov_type x) return 63 - clz_hwi (x); } - void __gcov_histogram_profiler (gcov_type *counters, gcov_type value) { @@ -64,7 +63,6 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value) int pow2=floor_log2(value); counters[pow2+5]++; } - printf("\n %d %d \n", floor_log2(value), value); } #endif @@ -77,6 +75,28 @@ __gcov_histogram_profiler (gcov_type *counters, gcov_type value) * otherwise we take its logarithm and increment corresponding counter */ +/* For convenience, define 0 -> word_size. */ +static inline int +clz_hwi2 (gcov_type x) +{ + if (x == 0) + return 64; +# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG + return __builtin_clzl (x); +# elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG + return __builtin_clzll (x); +# else + return __builtin_clz (x); +# endif +} + +static inline int +floor_log2_2 (gcov_type x) +{ + return 63 - clz_hwi2 (x); +} + + void __gcov_histogram_profiler_atomic (gcov_type *counters, gcov_type value) { @@ -84,7 +104,7 @@ __gcov_histogram_profiler_atomic (gcov_type *counters, gcov_type value) __atomic_fetch_add (&counters[value], 1, __ATOMIC_RELAXED); }else{ gcc_assert(value>0); - int pow2=floor_log2(value); + int pow2=floor_log2_2(value); __atomic_fetch_add (&counters[pow2+5], 1, __ATOMIC_RELAXED); } }