public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Enhance dump_probability function.
@ 2017-06-13  8:15 Martin Liška
  2017-06-14  2:02 ` Paul Hua
  2017-06-16 11:38 ` Jan Hubicka
  0 siblings, 2 replies; 7+ messages in thread
From: Martin Liška @ 2017-06-13  8:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]

Hi.

This is pre-approved patch that displays edge counts in dump files:

...
  _85 = _83 + _84;
  len_86 = SQRT (_85);
  if (_85 u>= 0.0)
    goto <bb 6>; [99.00%] [count: 778568]
  else
    goto <bb 5>; [1.00%] [count: 7864]

  <bb 5> [0.01%] [count: 7864]:
  sqrt (_85);
...

That makes it possible to understand why a profile mismatch happens.
Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Martin

gcc/ChangeLog:

2017-06-12  Martin Liska  <mliska@suse.cz>

	* gimple-pretty-print.c (dump_probability): Add new argument.
	(dump_edge_probability): Dump both probability and count.
	(dump_gimple_label): Likewise.
	(dump_gimple_bb_header): Likewise.

gcc/testsuite/ChangeLog:

2017-06-12  Martin Liska  <mliska@suse.cz>

	* gcc.dg/tree-ssa/builtin-sprintf-2.c: Adjust scanned pattern.
	* gcc.dg/tree-ssa/dump-2.c: Likewise.
	* gcc.dg/tree-ssa/vrp101.c: Likewise.
---
 gcc/gimple-pretty-print.c                         | 22 ++++++++++++++--------
 gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c |  4 ++--
 gcc/testsuite/gcc.dg/tree-ssa/dump-2.c            |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/vrp101.c            |  2 +-
 4 files changed, 18 insertions(+), 12 deletions(-)



[-- Attachment #2: 0001-Enhance-dump_probability-function.patch --]
[-- Type: text/x-patch, Size: 4271 bytes --]

diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index 5ff63a167a1..447921be036 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -80,17 +80,22 @@ debug_gimple_stmt (gimple *gs)
    by xstrdup_for_dump.  */
 
 static const char *
-dump_probability (int value)
+dump_probability (int frequency, profile_count &count)
 {
   float minimum = 0.01f;
 
-  gcc_assert (0 <= value && value <= REG_BR_PROB_BASE);
-  float fvalue = value * 100.0f / REG_BR_PROB_BASE;
-  if (fvalue < minimum && value > 0)
+  gcc_assert (0 <= frequency && frequency <= REG_BR_PROB_BASE);
+  float fvalue = frequency * 100.0f / REG_BR_PROB_BASE;
+  if (fvalue < minimum && frequency > 0)
     return "[0.01%]";
 
   char *buf;
-  asprintf (&buf, "[%.2f%%]", fvalue);
+  if (count.initialized_p ())
+    asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
+	      count.to_gcov_type ());
+  else
+    asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
+
   const char *ret = xstrdup_for_dump (buf);
   free (buf);
 
@@ -102,7 +107,7 @@ dump_probability (int value)
 static void
 dump_edge_probability (pretty_printer *buffer, edge e)
 {
-  pp_scalar (buffer, " %s", dump_probability (e->probability));
+  pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
 }
 
 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
@@ -1085,7 +1090,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
       dump_generic_node (buffer, label, spc, flags, false);
       basic_block bb = gimple_bb (gs);
       if (bb && !(flags & TDF_GIMPLE))
-	pp_scalar (buffer, " %s", dump_probability (bb->frequency));
+	pp_scalar (buffer, " %s", dump_probability (bb->frequency, bb->count));
       pp_colon (buffer);
     }
   if (flags & TDF_GIMPLE)
@@ -2665,7 +2670,8 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
 	    fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
 	  else
 	    fprintf (outf, "%*s<bb %d> %s:\n",
-		     indent, "", bb->index, dump_probability (bb->frequency));
+		     indent, "", bb->index, dump_probability (bb->frequency,
+							      bb->count));
 	}
     }
 }
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
index 8a13f33d2a1..e15d88b7341 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
@@ -290,7 +290,7 @@ RNG (0,  6,   8, "%s%ls", "1", L"2");
 
 /*  Only conditional calls to must_not_eliminate must be made (with
     any probability):
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
     No unconditional calls to abort should be made:
     { dg-final { scan-tree-dump-not ";\n *must_not_eliminate" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c b/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
index 8a63af4e0ef..6ae2ef5bf39 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
@@ -6,4 +6,4 @@ int f(void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\]:" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\] \\\[count: INV\\\]:" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
index bf4109f7156..e7cad289763 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
@@ -10,4 +10,4 @@ int main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\]:\[\n\r \]*return 0;" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Enhance dump_probability function.
  2017-06-13  8:15 [PATCH] Enhance dump_probability function Martin Liška
@ 2017-06-14  2:02 ` Paul Hua
  2017-06-14  5:53   ` Rainer Orth
  2017-06-16 11:38 ` Jan Hubicka
  1 sibling, 1 reply; 7+ messages in thread
From: Paul Hua @ 2017-06-14  2:02 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

New "ERROR: (DejaGnu)" on mips64el target.

my DejaGnu version is 1.5.1.

1)
make check-gcc RUNTESTFLAGS="tree-ssa.exp=builtin-sprintf-2.c"
...
ERROR: (DejaGnu) proc "^:\\" does not exist.
The error code is TCL LOOKUP COMMAND ^:\\
The info on the error is:
invalid command name "^:\"
    while executing
"::tcl_unknown ^:\\"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::tcl_unknown $args"
...

2)
make check-gcc RUNTESTFLAGS="tree-ssa.exp=vrp101.c"
...
ERROR: (DejaGnu) proc "^:\\" does not exist.
The error code is TCL LOOKUP COMMAND ^:\\
The info on the error is:
invalid command name "^:\"
    while executing
"::tcl_unknown ^:\\"
    ("uplevel" body line 1)
    invoked from within
"uplevel 1 ::tcl_unknown $args"
...

I don't known how to debug this, any advice ?

Paul.


On Tue, Jun 13, 2017 at 4:14 PM, Martin Liška <mliska@suse.cz> wrote:
> Hi.
>
> This is pre-approved patch that displays edge counts in dump files:
>
> ...
>   _85 = _83 + _84;
>   len_86 = SQRT (_85);
>   if (_85 u>= 0.0)
>     goto <bb 6>; [99.00%] [count: 778568]
>   else
>     goto <bb 5>; [1.00%] [count: 7864]
>
>   <bb 5> [0.01%] [count: 7864]:
>   sqrt (_85);
> ...
>
> That makes it possible to understand why a profile mismatch happens.
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Martin
>
> gcc/ChangeLog:
>
> 2017-06-12  Martin Liska  <mliska@suse.cz>
>
>         * gimple-pretty-print.c (dump_probability): Add new argument.
>         (dump_edge_probability): Dump both probability and count.
>         (dump_gimple_label): Likewise.
>         (dump_gimple_bb_header): Likewise.
>
> gcc/testsuite/ChangeLog:
>
> 2017-06-12  Martin Liska  <mliska@suse.cz>
>
>         * gcc.dg/tree-ssa/builtin-sprintf-2.c: Adjust scanned pattern.
>         * gcc.dg/tree-ssa/dump-2.c: Likewise.
>         * gcc.dg/tree-ssa/vrp101.c: Likewise.
> ---
>  gcc/gimple-pretty-print.c                         | 22 ++++++++++++++--------
>  gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c |  4 ++--
>  gcc/testsuite/gcc.dg/tree-ssa/dump-2.c            |  2 +-
>  gcc/testsuite/gcc.dg/tree-ssa/vrp101.c            |  2 +-
>  4 files changed, 18 insertions(+), 12 deletions(-)
>
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Enhance dump_probability function.
  2017-06-14  2:02 ` Paul Hua
@ 2017-06-14  5:53   ` Rainer Orth
  2017-06-14  6:31     ` Jakub Jelinek
  2017-06-14  7:18     ` Andreas Schwab
  0 siblings, 2 replies; 7+ messages in thread
From: Rainer Orth @ 2017-06-14  5:53 UTC (permalink / raw)
  To: Paul Hua; +Cc: Martin Liška, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1308 bytes --]

Hi Paul,

> New "ERROR: (DejaGnu)" on mips64el target.
>
> my DejaGnu version is 1.5.1.
>
> 1)
> make check-gcc RUNTESTFLAGS="tree-ssa.exp=builtin-sprintf-2.c"
> ...
> ERROR: (DejaGnu) proc "^:\\" does not exist.
> The error code is TCL LOOKUP COMMAND ^:\\
> The info on the error is:
> invalid command name "^:\"
>     while executing
> "::tcl_unknown ^:\\"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel 1 ::tcl_unknown $args"
> ...
>
> 2)
> make check-gcc RUNTESTFLAGS="tree-ssa.exp=vrp101.c"
> ...
> ERROR: (DejaGnu) proc "^:\\" does not exist.
> The error code is TCL LOOKUP COMMAND ^:\\
> The info on the error is:
> invalid command name "^:\"
>     while executing
> "::tcl_unknown ^:\\"
>     ("uplevel" body line 1)
>     invoked from within
> "uplevel 1 ::tcl_unknown $args"
> ...
>
> I don't known how to debug this, any advice ?

both revised scan-tree-dump patterns got the quoting wrong, leading to
attempts to run unknown procs ^\\: instead of matching [^:] ;-(

This totally broke make check-gcc: the affected partial test runs
aborted at that point, leading to gcc.{sum,log} files that make
contrib/dg-extract-results.py choke, producing empty combined
gcc.{sum,log} files.  No idea how this was tested (probably not at all).

The following patch fixes the syntax error


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: ts.patch --]
[-- Type: text/x-patch, Size: 1658 bytes --]

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
--- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
@@ -290,7 +290,7 @@ RNG (0,  6,   8, "%s%ls", "1", L"2");
 
 /*  Only conditional calls to must_not_eliminate must be made (with
     any probability):
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
     No unconditional calls to abort should be made:
     { dg-final { scan-tree-dump-not ";\n *must_not_eliminate" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
--- a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
@@ -10,4 +10,4 @@ int main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */

[-- Attachment #3: Type: text/plain, Size: 581 bytes --]


but both tests still come out as FAIL:

+FAIL: gcc.dg/tree-ssa/builtin-sprintf-2.c scan-tree-dump-times optimized "> \\\
\[[0-9.]+%\\\\]\\\\ \\\\[count:\\\\[^:\\\\]*\\\\]:\\n *must_not_eliminate" 127

+FAIL: gcc.dg/tree-ssa/vrp101.c scan-tree-dump optimized "<bb 2> \\\\[[0-9.]+%\\
\\] \\\\[count: \\\\[^:\\\\]*\\\\]:[\\n\\r ]*return 0;"

Martin should check what he really meant to match here and fix the
patterns accordingly.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Enhance dump_probability function.
  2017-06-14  5:53   ` Rainer Orth
@ 2017-06-14  6:31     ` Jakub Jelinek
  2017-06-14  7:14       ` Martin Liška
  2017-06-14  7:18     ` Andreas Schwab
  1 sibling, 1 reply; 7+ messages in thread
From: Jakub Jelinek @ 2017-06-14  6:31 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Paul Hua, Martin Liška, gcc-patches

On Wed, Jun 14, 2017 at 07:52:10AM +0200, Rainer Orth wrote:
> both revised scan-tree-dump patterns got the quoting wrong, leading to
> attempts to run unknown procs ^\\: instead of matching [^:] ;-(
> 
> This totally broke make check-gcc: the affected partial test runs
> aborted at that point, leading to gcc.{sum,log} files that make
> contrib/dg-extract-results.py choke, producing empty combined
> gcc.{sum,log} files.  No idea how this was tested (probably not at all).
> 
> The following patch fixes the syntax error
> 

> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
> --- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
> @@ -290,7 +290,7 @@ RNG (0,  6,   8, "%s%ls", "1", L"2");
>  
>  /*  Only conditional calls to must_not_eliminate must be made (with
>      any probability):
> -    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
> -    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
> +    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
> +    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
>      No unconditional calls to abort should be made:
>      { dg-final { scan-tree-dump-not ";\n *must_not_eliminate" "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
> --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
> @@ -10,4 +10,4 @@ int main ()
>    return 0;
>  }
>  
> -/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */
> +/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */

> 
> but both tests still come out as FAIL:
> 
> +FAIL: gcc.dg/tree-ssa/builtin-sprintf-2.c scan-tree-dump-times optimized "> \\\
> \[[0-9.]+%\\\\]\\\\ \\\\[count:\\\\[^:\\\\]*\\\\]:\\n *must_not_eliminate" 127
> 
> +FAIL: gcc.dg/tree-ssa/vrp101.c scan-tree-dump optimized "<bb 2> \\\\[[0-9.]+%\\
> \\] \\\\[count: \\\\[^:\\\\]*\\\\]:[\\n\\r ]*return 0;"
> 
> Martin should check what he really meant to match here and fix the
> patterns accordingly.

I've looked at the patch and committed following change that makes
both tests pass.  Scanning for [^:]* is weird, it would make more sense
to scan for [^]]*, but as only [0-9INV]* can appear there, I think it
doesn't hurt to be more precise.

2017-06-14  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/tree-ssa/vrp101.c: Fix scan-tree-dump regex.
	* gcc.dg/tree-ssa/builtin-sprintf-2.c: Likewise.  Adjust comment.

--- gcc/testsuite/gcc.dg/tree-ssa/vrp101.c.jj	2017-06-13 22:01:36.000000000 +0200
+++ gcc/testsuite/gcc.dg/tree-ssa/vrp101.c	2017-06-14 08:22:36.296814015 +0200
@@ -10,4 +10,4 @@ int main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \[0-9INV\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */
--- gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c.jj	2017-06-13 22:01:36.000000000 +0200
+++ gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c	2017-06-14 08:22:10.055149125 +0200
@@ -279,18 +279,18 @@ RNG (0,  6,   8, "%s%ls", "1", L"2");
    <bb 2>:
    result_3 = __builtin_sprintf (&MEM[(void *)&buf8k + 8192B], "%c", 32);
    if (result_3 != 0)
-     goto <bb 3>; [50.0%]
+     goto <bb 3>; [50.0%] [count: INV]
    else
-     goto <bb 4>; [50.0%]
+     goto <bb 4>; [50.0%] [count: INV]
 
-   <bb 3>[50.0%]:
+   <bb 3>[50.0%] [count: INV]:
    must_not_eliminate ();
 
 */
 
 /*  Only conditional calls to must_not_eliminate must be made (with
     any probability):
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
-    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\] \\\[count: \[0-9INV\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
+    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\] \\\[count: \[0-9INV\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
     No unconditional calls to abort should be made:
     { dg-final { scan-tree-dump-not ";\n *must_not_eliminate" "optimized" } } */


	Jakub

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Enhance dump_probability function.
  2017-06-14  6:31     ` Jakub Jelinek
@ 2017-06-14  7:14       ` Martin Liška
  0 siblings, 0 replies; 7+ messages in thread
From: Martin Liška @ 2017-06-14  7:14 UTC (permalink / raw)
  To: Jakub Jelinek, Rainer Orth; +Cc: Paul Hua, gcc-patches

On 06/14/2017 08:31 AM, Jakub Jelinek wrote:
> I've looked at the patch and committed following change that makes
> both tests pass.  Scanning for [^:]* is weird, it would make more sense
> to scan for [^]]*, but as only [0-9INV]* can appear there, I think it
> doesn't hurt to be more precise.

Yes, we can be more precise. Thanks for the fix.

Martin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Enhance dump_probability function.
  2017-06-14  5:53   ` Rainer Orth
  2017-06-14  6:31     ` Jakub Jelinek
@ 2017-06-14  7:18     ` Andreas Schwab
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Schwab @ 2017-06-14  7:18 UTC (permalink / raw)
  To: Rainer Orth; +Cc: Paul Hua, Martin Liška, gcc-patches

On Jun 14 2017, Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> wrote:

> +    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
> +    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }

It would be much easier to handle if the regex were enclosed in { }.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] Enhance dump_probability function.
  2017-06-13  8:15 [PATCH] Enhance dump_probability function Martin Liška
  2017-06-14  2:02 ` Paul Hua
@ 2017-06-16 11:38 ` Jan Hubicka
  1 sibling, 0 replies; 7+ messages in thread
From: Jan Hubicka @ 2017-06-16 11:38 UTC (permalink / raw)
  To: Martin Liška; +Cc: gcc-patches

> Hi.
> 
> This is pre-approved patch that displays edge counts in dump files:
> 
> ...
>   _85 = _83 + _84;
>   len_86 = SQRT (_85);
>   if (_85 u>= 0.0)
>     goto <bb 6>; [99.00%] [count: 778568]
>   else
>     goto <bb 5>; [1.00%] [count: 7864]
> 
>   <bb 5> [0.01%] [count: 7864]:
>   sqrt (_85);
> ...
> 
> That makes it possible to understand why a profile mismatch happens.
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
> 
> Martin
> 
> gcc/ChangeLog:
> 
> 2017-06-12  Martin Liska  <mliska@suse.cz>
> 
> 	* gimple-pretty-print.c (dump_probability): Add new argument.
> 	(dump_edge_probability): Dump both probability and count.
> 	(dump_gimple_label): Likewise.
> 	(dump_gimple_bb_header): Likewise.
> 
> gcc/testsuite/ChangeLog:
> 
> 2017-06-12  Martin Liska  <mliska@suse.cz>
> 
> 	* gcc.dg/tree-ssa/builtin-sprintf-2.c: Adjust scanned pattern.
> 	* gcc.dg/tree-ssa/dump-2.c: Likewise.
> 	* gcc.dg/tree-ssa/vrp101.c: Likewise.

OK 
Honza
> ---
>  gcc/gimple-pretty-print.c                         | 22 ++++++++++++++--------
>  gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c |  4 ++--
>  gcc/testsuite/gcc.dg/tree-ssa/dump-2.c            |  2 +-
>  gcc/testsuite/gcc.dg/tree-ssa/vrp101.c            |  2 +-
>  4 files changed, 18 insertions(+), 12 deletions(-)
> 
> 

> diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
> index 5ff63a167a1..447921be036 100644
> --- a/gcc/gimple-pretty-print.c
> +++ b/gcc/gimple-pretty-print.c
> @@ -80,17 +80,22 @@ debug_gimple_stmt (gimple *gs)
>     by xstrdup_for_dump.  */
>  
>  static const char *
> -dump_probability (int value)
> +dump_probability (int frequency, profile_count &count)
>  {
>    float minimum = 0.01f;
>  
> -  gcc_assert (0 <= value && value <= REG_BR_PROB_BASE);
> -  float fvalue = value * 100.0f / REG_BR_PROB_BASE;
> -  if (fvalue < minimum && value > 0)
> +  gcc_assert (0 <= frequency && frequency <= REG_BR_PROB_BASE);
> +  float fvalue = frequency * 100.0f / REG_BR_PROB_BASE;
> +  if (fvalue < minimum && frequency > 0)
>      return "[0.01%]";
>  
>    char *buf;
> -  asprintf (&buf, "[%.2f%%]", fvalue);
> +  if (count.initialized_p ())
> +    asprintf (&buf, "[%.2f%%] [count: %" PRId64 "]", fvalue,
> +	      count.to_gcov_type ());
> +  else
> +    asprintf (&buf, "[%.2f%%] [count: INV]", fvalue);
> +
>    const char *ret = xstrdup_for_dump (buf);
>    free (buf);
>  
> @@ -102,7 +107,7 @@ dump_probability (int value)
>  static void
>  dump_edge_probability (pretty_printer *buffer, edge e)
>  {
> -  pp_scalar (buffer, " %s", dump_probability (e->probability));
> +  pp_scalar (buffer, " %s", dump_probability (e->probability, e->count));
>  }
>  
>  /* Print GIMPLE statement G to FILE using SPC indentation spaces and
> @@ -1085,7 +1090,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc,
>        dump_generic_node (buffer, label, spc, flags, false);
>        basic_block bb = gimple_bb (gs);
>        if (bb && !(flags & TDF_GIMPLE))
> -	pp_scalar (buffer, " %s", dump_probability (bb->frequency));
> +	pp_scalar (buffer, " %s", dump_probability (bb->frequency, bb->count));
>        pp_colon (buffer);
>      }
>    if (flags & TDF_GIMPLE)
> @@ -2665,7 +2670,8 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
>  	    fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
>  	  else
>  	    fprintf (outf, "%*s<bb %d> %s:\n",
> -		     indent, "", bb->index, dump_probability (bb->frequency));
> +		     indent, "", bb->index, dump_probability (bb->frequency,
> +							      bb->count));
>  	}
>      }
>  }
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
> index 8a13f33d2a1..e15d88b7341 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-2.c
> @@ -290,7 +290,7 @@ RNG (0,  6,   8, "%s%ls", "1", L"2");
>  
>  /*  Only conditional calls to must_not_eliminate must be made (with
>      any probability):
> -    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
> -    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
> +    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 127 "optimized" { target { ilp32 || lp64 } } } }
> +    { dg-final { scan-tree-dump-times "> \\\[\[0-9.\]+%\\\]\\ \\\[count:\\[^:\\]*\\\]:\n *must_not_eliminate" 96 "optimized" { target { { ! ilp32 } && { ! lp64 } } } } }
>      No unconditional calls to abort should be made:
>      { dg-final { scan-tree-dump-not ";\n *must_not_eliminate" "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c b/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
> index 8a63af4e0ef..6ae2ef5bf39 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/dump-2.c
> @@ -6,4 +6,4 @@ int f(void)
>    return 0;
>  }
>  
> -/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\]:" "optimized" } } */
> +/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\] \\\[count: INV\\\]:" "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
> index bf4109f7156..e7cad289763 100644
> --- a/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp101.c
> @@ -10,4 +10,4 @@ int main ()
>    return 0;
>  }
>  
> -/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\]:\[\n\r \]*return 0;" "optimized" } } */
> +/* { dg-final { scan-tree-dump "<bb 2> \\\[\[0-9.\]+%\\\] \\\[count: \\[^:\\]*\\\]:\[\n\r \]*return 0;" "optimized" } } */
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-06-16 11:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-13  8:15 [PATCH] Enhance dump_probability function Martin Liška
2017-06-14  2:02 ` Paul Hua
2017-06-14  5:53   ` Rainer Orth
2017-06-14  6:31     ` Jakub Jelinek
2017-06-14  7:14       ` Martin Liška
2017-06-14  7:18     ` Andreas Schwab
2017-06-16 11:38 ` Jan Hubicka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).