Print 2 digits after decimal delimiter for BB frequencies
authorMartin Liska <mliska@suse.cz>
Wed, 14 Dec 2016 10:33:10 +0000 (11:33 +0100)
committerMartin Liska <marxin@gcc.gnu.org>
Wed, 14 Dec 2016 10:33:10 +0000 (10:33 +0000)
* gimple-pretty-print.c (dump_probability): New function.
(dump_edge_probability): Use the function.
(dump_gimple_label): Likewise.
(dump_gimple_bb_header): Likewise.
* gcc.dg/tree-ssa/20040703-1.c: Update scanned pattern.
* gcc.dg/tree-ssa/dump-2.c: Likewise.

From-SVN: r243643

gcc/ChangeLog
gcc/gimple-pretty-print.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/20040703-1.c
gcc/testsuite/gcc.dg/tree-ssa/dump-2.c

index 93235608438f6a4d2e995c8bd1895fb2a6ffb472..25c01dba75284e176344fc6fc61fa64e971855a5 100644 (file)
@@ -1,3 +1,10 @@
+2016-12-14  Martin Liska  <mliska@suse.cz>
+
+       * gimple-pretty-print.c (dump_probability): New function.
+       (dump_edge_probability): Use the function.
+       (dump_gimple_label): Likewise.
+       (dump_gimple_bb_header): Likewise.
+
 2016-12-14  Prathamesh Kulkarni  <prathamesh.kulkarni@linaro.org>
            Jakub Jelinek  <jakub@redhat.com>
 
index 1bd4cde03cf0e06f46e182503b9ef21f51c299d1..1a66953533bf54f0dcd047da07053112240783e7 100644 (file)
@@ -73,13 +73,35 @@ debug_gimple_stmt (gimple *gs)
   print_gimple_stmt (stderr, gs, 0, TDF_VOPS|TDF_MEMSYMS);
 }
 
+
+/* Return formatted string of a VALUE probability
+   (biased by REG_BR_PROB_BASE).  Returned string is allocated
+   by xstrdup_for_dump.  */
+
+static const char *
+dump_probability (int value)
+{
+  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)
+    return "[0.01%]";
+
+  char *buf;
+  asprintf (&buf, "[%.2f%%]", fvalue);
+  const char *ret = xstrdup_for_dump (buf);
+  free (buf);
+
+  return ret;
+}
+
 /* Dump E probability to BUFFER.  */
 
 static void
 dump_edge_probability (pretty_printer *buffer, edge e)
 {
-  pp_scalar (buffer, " [%.1f%%]",
-            e->probability * 100.0 / REG_BR_PROB_BASE);
+  pp_scalar (buffer, " %s", dump_probability (e->probability));
 }
 
 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
@@ -1032,8 +1054,7 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
       dump_generic_node (buffer, label, spc, flags, false);
       basic_block bb = gimple_bb (gs);
       if (bb && !(flags & TDF_GIMPLE))
-       pp_scalar (buffer, " [%.1f%%]",
-                  bb->frequency * 100.0 / REG_BR_PROB_BASE);
+       pp_scalar (buffer, " %s", dump_probability (bb->frequency));
       pp_colon (buffer);
     }
   if (flags & TDF_GIMPLE)
@@ -2599,8 +2620,8 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
          if (flags & TDF_GIMPLE)
            fprintf (outf, "%*sbb_%d:\n", indent, "", bb->index);
          else
-           fprintf (outf, "%*s<bb %d> [%.1f%%]:\n", indent, "", bb->index,
-                    bb->frequency * 100.0 / REG_BR_PROB_BASE);
+           fprintf (outf, "%*s<bb %d> %s:\n",
+                    indent, "", bb->index, dump_probability (bb->frequency));
        }
     }
 }
index 046aea62623c8ff1c84538e18e0a3f808fc90b82..43cf4900f5af3ac197f56d7f2a3dcf375fabb294 100644 (file)
@@ -1,3 +1,8 @@
+2016-12-14  Martin Liska  <mliska@suse.cz>
+
+       * gcc.dg/tree-ssa/20040703-1.c: Update scanned pattern.
+       * gcc.dg/tree-ssa/dump-2.c: Likewise.
+
 2016-12-14  Toma Tabacu  <toma.tabacu@imgtec.com>
 
        * gcc.target/mips/msa-builtins-err.c (dg-options): Add 
index 2980047685218042bf0ef72913844df6d5389edf..eb9fb5640f727fd7ec3eb50a808bda524e980d80 100644 (file)
@@ -9,4 +9,4 @@ float foo(float x)
 }
 
 /* We should *not* fold the arithmetic.  */
-/* { dg-final { scan-tree-dump-times "0\\.0\[^%\]" 0 "dom2"} } */
+/* { dg-final { scan-tree-dump-times "0\\.0\[^%0\]" 0 "dom2"} } */
index 11cde92a7e0f501e3f9b00316853b61ca67907cf..8a63af4e0efe656295dd553005edcdce79321e1d 100644 (file)
@@ -6,4 +6,4 @@ int f(void)
   return 0;
 }
 
-/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.0%\\\]:" "optimized" } } */
+/* { dg-final { scan-tree-dump "<bb \[0-9\]> \\\[100\\\.00%\\\]:" "optimized" } } */