public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/kubaneko/heads/histogram)] temporary log fix
@ 2023-02-16 16:28 Ondrej Kubanek
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-16 16:28 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d483867021b5a939c95a1e4da8ac322457ba800f

commit d483867021b5a939c95a1e4da8ac322457ba800f
Author: kubaneko <kubanek0ondrej@gmail.com>
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);
   }
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/kubaneko/heads/histogram)] temporary log fix
@ 2023-02-23 23:22 Ondrej Kubanek
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2023-02-23 23:22 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:ef357765f596c358b223b7374f4a1574b7483a64

commit ef357765f596c358b223b7374f4a1574b7483a64
Author: kubaneko <kubanek0ondrej@gmail.com>
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 03ee8f6abc1..5469276f8a7 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);
   }
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [gcc(refs/users/kubaneko/heads/histogram)] temporary log fix
@ 2022-11-22 13:13 Ondrej Kubanek
  0 siblings, 0 replies; 3+ messages in thread
From: Ondrej Kubanek @ 2022-11-22 13:13 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2233c2e840936a801cee3c9c8c613edf39c52fdf

commit 2233c2e840936a801cee3c9c8c613edf39c52fdf
Author: kubaneko <kubanek0ondrej@gmail.com>
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);
   }
 }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-23 23:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-16 16:28 [gcc(refs/users/kubaneko/heads/histogram)] temporary log fix Ondrej Kubanek
  -- strict thread matches above, loose matches on Subject: below --
2023-02-23 23:22 Ondrej Kubanek
2022-11-22 13:13 Ondrej Kubanek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).