]> git.ipfire.org Git - thirdparty/gcc.git/commit
Improve dumping of profile_count
authorJan Hubicka <jh@suse.cz>
Sun, 9 Jul 2023 13:14:54 +0000 (15:14 +0200)
committerJan Hubicka <jh@suse.cz>
Sun, 9 Jul 2023 13:14:54 +0000 (15:14 +0200)
commitd6c1d7c4009bfe759719675ce3bc03ca503b9bf4
tree0e054a53897d69c35a7f773012bf6752b6380250
parent95b712928b479f7a65910cf1c550ed67b8976617
Improve dumping of profile_count

Dumps of profile_counts are quite hard to interpret since they are 64bit fixed point
values.  In many cases one looks at a single function and it is better to think of
basic block frequency, that is how many times it is executed each invocatoin. This
patch makes CFG dumps to also print this info.

For example:
main()
{
for (int i = 0; i < 10; i++)
t();
}

the -fdump-tree-optimized-blocks-details now prints:
int main ()
{
  unsigned int ivtmp_1;
  unsigned int ivtmp_2;

;;   basic block 2, loop depth 0, count 97603128 (estimated locally, freq 1.0000), maybe hot
;;    prev block 0, next block 3, flags: (NEW, VISITED)
;;    pred:       ENTRY [always]  count:97603128 (estimated locally, freq 1.0000) (FALLTHRU,EXECUTABLE)
;;    succ:       3 [always]  count:97603128 (estimated locally, freq 1.0000) (FALLTHRU,EXECUTABLE)

;;   basic block 3, loop depth 1, count 976138697 (estimated locally, freq 10.0011), maybe hot
;;    prev block 2, next block 4, flags: (NEW, VISITED)
;;    pred:       3 [90.0% (guessed)]  count:878535568 (estimated locally, freq 9.0011) (TRUE_VALUE,EXECUTABLE)
;;                2 [always]  count:97603128 (estimated locally, freq 1.0000) (FALLTHRU,EXECUTABLE)
  # ivtmp_2 = PHI <ivtmp_1(3), 10(2)>
  t ();
  ivtmp_1 = ivtmp_2 + 4294967295;
  if (ivtmp_1 != 0)
    goto <bb 3>; [90.00%]
  else
    goto <bb 4>; [10.00%]
;;    succ:       3 [90.0% (guessed)]  count:878535568 (estimated locally, freq 9.0011) (TRUE_VALUE,EXECUTABLE)
;;                4 [10.0% (guessed)]  count:97603129 (estimated locally, freq 1.0000) (FALSE_VALUE,EXECUTABLE)

;;   basic block 4, loop depth 0, count 97603128 (estimated locally, freq 1.0000), maybe hot
;;    prev block 3, next block 1, flags: (NEW, VISITED)
;;    pred:       3 [10.0% (guessed)]  count:97603129 (estimated locally, freq 1.0000) (FALSE_VALUE,EXECUTABLE)
  return 0;
;;    succ:       EXIT [always]  count:97603128 (estimated locally, freq 1.0000) (EXECUTABLE)

}

Which makes it easier to see that the inner bb is executed 10 times per invocation

gcc/ChangeLog:

* cfg.cc (check_bb_profile): Dump counts with relative frequency.
(dump_edge_info): Likewise.
(dump_bb_info): Likewise.
* profile-count.cc (profile_count::dump): Add comma between quality and
freq.

gcc/testsuite/ChangeLog:

* gcc.dg/predict-22.c: Update template.
gcc/cfg.cc
gcc/profile-count.cc
gcc/testsuite/gcc.dg/predict-22.c