Fix POW2 histogram

* 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
This commit is contained in:
Martin Liska 2016-08-09 22:57:14 +02:00 committed by Martin Liska
parent 54b367dbd2
commit dcb1e1379e
6 changed files with 36 additions and 3 deletions

View 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

View 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

View File

@ -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" } } */

View 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;

View 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.

View 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]++;