This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Dump probability for edges a frequency for BBs


On Wed, Nov 23, 2016 at 10:36 PM, Jeff Law <law@redhat.com> wrote:
> On 11/11/2016 06:59 AM, Martin Liška wrote:
>>
>> Hello.
>>
>> I spent quite time during this stage1 playing with predictors and we found
>> with Honza multiple situations where a prediction was oddly calculated.
>> Thus, we're suggesting to enhance default dump format to show BB
>> frequencies
>> and edge probabilities, as follows:
>>
>> main (int a)
>> {
>>   int _1;
>>
>>   <bb 2> [100.0%]:
>>   if (a_2(D) == 123)
>>     goto <bb 5> (<L18>); [18.8%]
>>   else
>>     goto <bb 3> (sparta); [81.2%]
>>
>> sparta [81.2%]:
>>   switch (a_2(D)) <default: <L5> [33.3%], case 1 ... 2: <L18> [66.7%]>
>>
>> <L5> [27.1%]:
>>
>>   # _1 = PHI <2(2), 3(4), a_2(D)(3)>
>> <L18> [100.0%]:
>>   return _1;
>>
>> }
>>
>> That would exhibit these numbers to people, which would eventually report
>> strange numbers seen in dump files.
>> I was quite surprised that the patch does not break many scanning tests.
>> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>>
>> Thoughts?
>> Martin
>>
>>
>> 0001-Dump-probability-for-edges-a-frequency-for-BBs.patch
>>
>>
>> From 5b7d8393564a0111698b58989ac74b45cf019701 Mon Sep 17 00:00:00 2001
>> From: marxin <mliska@suse.cz>
>> Date: Wed, 9 Nov 2016 14:11:48 +0100
>> Subject: [PATCH] Dump probability for edges a frequency for BBs
>>
>> gcc/ChangeLog:
>>
>> 2016-11-11  Martin Liska  <mliska@suse.cz>
>>
>>         * gimple-pretty-print.c (dump_edge_probability): New function.
>>         (dump_gimple_switch): Dump label edge probabilities.
>>         (dump_gimple_cond): Likewise.
>>         (dump_gimple_label): Dump
>>         (dump_gimple_bb_header): Dump basic block frequency.
>>         (pp_cfg_jump): Replace e->dest argument with e.
>>         (dump_implicit_edges): Likewise.
>>         * tree-ssa-loop-ivopts.c (get_scaled_computation_cost_at):
>>         Use gimple_bb (at) instead of at->bb.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2016-11-11  Martin Liska  <mliska@suse.cz>
>>
>>         * gcc.dg/builtin-unreachable-6.c: Update test to not to scan
>>         parts for frequencies/probabilities.
>>         * gcc.dg/pr34027-1.c: Likewise.
>>         * gcc.dg/strict-overflow-2.c: Likewise.
>>         * gcc.dg/tree-ssa/20040703-1.c: Likewise.
>>         * gcc.dg/tree-ssa/builtin-sprintf-2.c: Likewise.
>>         * gcc.dg/tree-ssa/pr32044.c: Likewise.
>>         * gcc.dg/tree-ssa/vector-3.c: Likewise.
>>         * gcc.dg/tree-ssa/vrp101.c: Likewise.
>>         * gcc.dg/tree-ssa/dump-2.c: New test.
>
> LGTM.  While I've often found a way to get this stuff when looking at
> probability updating code, having it in the standard dumps seems like a good
> enhancement.

Please guard with ! TDF_GIMPLE, otherwise the output will not be parseable
with the GIMPLE FE.

RIchard.

> jeff
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]