From: Martin Liska Date: Tue, 9 Aug 2016 20:57:39 +0000 (+0200) Subject: Fix usage of POW2 histogram X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab50a2153e0602a0d4384b0de390fb7322676479;p=gcc.git Fix usage of POW2 histogram * value-prof.c (gimple_divmod_values_to_profile): Do not instrument MOD histogram if a value is not a SSA name. * gcc.dg/tree-prof/val-prof-9.c: New test. From-SVN: r239305 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index dc14d6f10e7..2b1d5ffb00e 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2016-08-09 Martin Liska + + * value-prof.c (gimple_divmod_values_to_profile): Do not + instrument MOD histogram if a value is not a SSA name. + 2016-08-09 Martin Liska * value-prof.c (dump_histogram_value): Swap pow2 and non-pow2 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 927f1e31a32..55ff0819c0d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-08-09 Martin Liska + + * gcc.dg/tree-prof/val-prof-9.c: New test. + 2016-08-09 Martin Liska * gcc.dg/tree-prof/val-prof-8.c: New test. diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-9.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-9.c new file mode 100644 index 00000000000..8fc23015938 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-9.c @@ -0,0 +1,18 @@ +/* { dg-options "-O0 -fdump-tree-optimized" } */ + +int +main (int argc, char **argv) +{ + unsigned u = (argc - 1); + int counter = 0; + + for (unsigned i = 0; i < 100; i++) + { + counter += u % 16; + } + + return counter; +} + +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-tree-dump-times "__gcov_pow2_profiler" 0 "optimized" } } */ diff --git a/gcc/value-prof.c b/gcc/value-prof.c index 0527c2cc738..a4653aa8ee9 100644 --- a/gcc/value-prof.c +++ b/gcc/value-prof.c @@ -1950,7 +1950,8 @@ gimple_divmod_values_to_profile (gimple *stmt, histogram_values *values) /* For mod, check whether it is not often a noop (or replaceable by a few subtractions). */ if (gimple_assign_rhs_code (stmt) == TRUNC_MOD_EXPR - && TYPE_UNSIGNED (type)) + && TYPE_UNSIGNED (type) + && TREE_CODE (divisor) == SSA_NAME) { tree val; /* Check for a special case where the divisor is power of 2. */