]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix POW2 histogram
authorMartin Liska <mliska@suse.cz>
Tue, 9 Aug 2016 20:57:14 +0000 (22:57 +0200)
committerMartin Liska <marxin@gcc.gnu.org>
Tue, 9 Aug 2016 20:57:14 +0000 (20:57 +0000)
* gcc.dg/tree-prof/val-prof-8.c: New test.
* value-prof.c (dump_histogram_value): Swap pow2 and non-pow2
values.
* libgcov-profiler.c (__gcov_pow2_profiler): Consider 0 as not
power of two.

From-SVN: r239304

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-prof/val-prof-8.c [new file with mode: 0644]
gcc/value-prof.c
libgcc/ChangeLog
libgcc/libgcov-profiler.c

index 40537cba7e70c6da1ca5ee1e92d6eee59b1cdad5..dc14d6f10e709a50a30fc487092e78bade490b6e 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-09  Martin Liska  <mliska@suse.cz>
+
+       * value-prof.c (dump_histogram_value): Swap pow2 and non-pow2
+       values.
+
 2016-08-09  Renlin Li  <renlin.li@arm.com>
 
        PR middle-end/64971
index 34834693309a09e40a00b7884e0f2fb290e6b5e1..927f1e31a3218bb417e17f32275c3da4b423be37 100644 (file)
@@ -1,3 +1,7 @@
+2016-08-09  Martin Liska  <mliska@suse.cz>
+
+       * gcc.dg/tree-prof/val-prof-8.c: New test.
+
 2016-08-09  Martin Jambor  <mjambor@suse.cz>
 
         PR ipa/71981
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-8.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-8.c
new file mode 100644 (file)
index 0000000..2c505e3
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-options "-O0 -fdump-ipa-profile" } */
+
+int
+main (int argc, char **argv)
+{
+  unsigned u = (argc - 1);
+  int counter = 0;
+
+  for (unsigned i = 0; i < 100; i++)
+  {
+    unsigned x = i < 10 ? 16 : 15;
+    counter += u % x;
+  }
+
+  return counter;
+}
+
+/* autofdo does not do value profiling so far */
+/* { dg-final-use-not-autofdo { scan-ipa-dump "Pow2 counter pow2:10 nonpow2:90." "profile" } } */
index 2976a86c7941b3cbb21452354fc2357f9dbf9084..0527c2cc73851b5cb8acd33ad7fd91de7c0bc172 100644 (file)
@@ -264,8 +264,8 @@ dump_histogram_value (FILE *dump_file, histogram_value hist)
        {
           fprintf (dump_file, "pow2:%" PRId64
                    " nonpow2:%" PRId64,
-                   (int64_t) hist->hvalue.counters[0],
-                   (int64_t) hist->hvalue.counters[1]);
+                   (int64_t) hist->hvalue.counters[1],
+                   (int64_t) hist->hvalue.counters[0]);
        }
       fprintf (dump_file, ".\n");
       break;
index aa9400d3d19801e0d2a2daa0253c6c67a28046d8..5b05a7cac7dd306ae77dab8c0b900626d2fc51dd 100644 (file)
@@ -1,3 +1,8 @@
+2016-08-09  Martin Liska  <mliska@suse.cz>
+
+       * libgcov-profiler.c (__gcov_pow2_profiler): Consider 0 as not
+       power of two.
+
 2016-07-29  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>
 
        * config/rs6000/_divkc3.c: Add copyright/license boilerplate.
index e94718834e7120748f88fb2d1e3960a16ff3fba8..6da8a940660926b8a60e6b047c98e6e50bf1454d 100644 (file)
@@ -53,7 +53,7 @@ __gcov_interval_profiler (gcov_type *counters, gcov_type value,
 void
 __gcov_pow2_profiler (gcov_type *counters, gcov_type value)
 {
-  if (value & (value - 1))
+  if (value == 0 || (value & (value - 1)))
     counters[0]++;
   else
     counters[1]++;