tree-optimization/95495 - use SLP_TREE_REPRESENTATIVE in assertion
[gcc.git] / gcc / gimple-pretty-print.c
index f1abf5c4aea522d0d41a4676a3c5a19eff4e88e8..62cbf499ca025d3b844e72a7b08cf8f3e4760bff 100644 (file)
@@ -1,5 +1,5 @@
 /* Pretty formatting of GIMPLE statements and expressions.
-   Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   Copyright (C) 2001-2020 Free Software Foundation, Inc.
    Contributed by Aldy Hernandez <aldyh@redhat.com> and
    Diego Novillo <dnovillo@google.com>
 
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "backend.h"
 #include "tree.h"
 #include "gimple.h"
@@ -36,6 +37,18 @@ along with GCC; see the file COPYING3.  If not see
 #include "dumpfile.h"  /* for dump_flags */
 #include "value-prof.h"
 #include "trans-mem.h"
+#include "cfganal.h"
+#include "stringpool.h"
+#include "attribs.h"
+#include "asan.h"
+#include "cfgloop.h"
+
+/* Disable warnings about quoting issues in the pp_xxx calls below
+   that (intentionally) don't follow GCC diagnostic conventions.  */
+#if __GNUC__ >= 10
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wformat-diag"
+#endif
 
 #define INDENT(SPACE)                                                  \
   do { int i; for (i = 0; i < SPACE; i++) pp_space (buffer); } while (0)
@@ -46,7 +59,7 @@ along with GCC; see the file COPYING3.  If not see
    gimple statement GS.  */
 
 static void
-do_niy (pretty_printer *buffer, gimple *gs)
+do_niy (pretty_printer *buffer, const gimple *gs)
 {
   pp_printf (buffer, "<<< Unknown GIMPLE statement: %s >>>\n",
             gimple_code_name[(int) gimple_code (gs)]);
@@ -72,11 +85,71 @@ debug_gimple_stmt (gimple *gs)
 }
 
 
+/* 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_profile (profile_count &count)
+{
+  char *buf = NULL;
+  if (!count.initialized_p ())
+    return "";
+  if (count.ipa_p ())
+    buf = xasprintf ("[count: %" PRId64 "]",
+                    count.to_gcov_type ());
+  else if (count.initialized_p ())
+    buf = xasprintf ("[local count: %" PRId64 "]",
+                    count.to_gcov_type ());
+
+  const char *ret = xstrdup_for_dump (buf);
+  free (buf);
+
+  return ret;
+}
+
+/* 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 (profile_probability probability)
+{
+  float minimum = 0.01f;
+  float fvalue = -1;
+
+  if (probability.initialized_p ())
+    {
+      fvalue = probability.to_reg_br_prob_base () * 100.0f / REG_BR_PROB_BASE;
+      if (fvalue < minimum && probability.to_reg_br_prob_base ())
+       fvalue = minimum;
+    }
+
+  char *buf;
+  if (probability.initialized_p ())
+    buf = xasprintf ("[%.2f%%]", fvalue);
+  else
+    buf = xasprintf ("[INV]");
+
+  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, " %s", dump_probability (e->probability));
+}
+
 /* Print GIMPLE statement G to FILE using SPC indentation spaces and
    FLAGS as in pp_gimple_stmt_1.  */
 
 void
-print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
+print_gimple_stmt (FILE *file, gimple *g, int spc, dump_flags_t flags)
 {
   pretty_printer buffer;
   pp_needs_newline (&buffer) = true;
@@ -88,7 +161,7 @@ print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
 DEBUG_FUNCTION void
 debug (gimple &ref)
 {
-  print_gimple_stmt (stderr, &ref, 0, 0);
+  print_gimple_stmt (stderr, &ref, 0, TDF_NONE);
 }
 
 DEBUG_FUNCTION void
@@ -106,7 +179,7 @@ debug (gimple *ptr)
    of the statement.  */
 
 void
-print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
+print_gimple_expr (FILE *file, gimple *g, int spc, dump_flags_t flags)
 {
   flags |= TDF_RHS_ONLY;
   pretty_printer buffer;
@@ -123,7 +196,8 @@ print_gimple_expr (FILE *file, gimple *g, int spc, int flags)
    the pretty printer.  */
 
 static void
-dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
+dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc,
+                dump_flags_t flags)
 {
   gimple_stmt_iterator i;
 
@@ -142,7 +216,7 @@ dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
    FLAGS as in pp_gimple_stmt_1.  */
 
 void
-print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
+print_gimple_seq (FILE *file, gimple_seq seq, int spc, dump_flags_t flags)
 {
   pretty_printer buffer;
   pp_needs_newline (&buffer) = true;
@@ -174,7 +248,7 @@ debug_gimple_seq (gimple_seq seq)
      '-' - decreases indent by 2 then outputs a newline.   */
 
 static void
-dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
+dump_gimple_fmt (pretty_printer *buffer, int spc, dump_flags_t flags,
                  const char *fmt, ...)
 {
   va_list args;
@@ -253,7 +327,8 @@ dump_gimple_fmt (pretty_printer *buffer, int spc, int flags,
    assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
+dump_unary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
+               dump_flags_t flags)
 {
   enum tree_code rhs_code = gimple_assign_rhs_code (gs);
   tree lhs = gimple_assign_lhs (gs);
@@ -291,9 +366,20 @@ dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
       break;
 
     case ABS_EXPR:
-      pp_string (buffer, "ABS_EXPR <");
-      dump_generic_node (buffer, rhs, spc, flags, false);
-      pp_greater (buffer);
+    case ABSU_EXPR:
+      if (flags & TDF_GIMPLE)
+       {
+         pp_string (buffer,
+                    rhs_code == ABS_EXPR ? "__ABS " : "__ABSU ");
+         dump_generic_node (buffer, rhs, spc, flags, false);
+       }
+      else
+       {
+         pp_string (buffer,
+                    rhs_code == ABS_EXPR ? "ABS_EXPR <" : "ABSU_EXPR <");
+         dump_generic_node (buffer, rhs, spc, flags, false);
+         pp_greater (buffer);
+       }
       break;
 
     default:
@@ -337,15 +423,29 @@ dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
    assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
+dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
+                dump_flags_t flags)
 {
   const char *p;
   enum tree_code code = gimple_assign_rhs_code (gs);
   switch (code)
     {
-    case COMPLEX_EXPR:
     case MIN_EXPR:
     case MAX_EXPR:
+      if (flags & TDF_GIMPLE)
+       {
+         pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX (");
+         dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
+                            false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
+                            false);
+         pp_string (buffer, ")");
+         break;
+       }
+      else
+       gcc_fallthrough ();
+    case COMPLEX_EXPR:
     case VEC_WIDEN_MULT_HI_EXPR:
     case VEC_WIDEN_MULT_LO_EXPR:
     case VEC_WIDEN_MULT_EVEN_EXPR:
@@ -353,8 +453,10 @@ dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
     case VEC_PACK_TRUNC_EXPR:
     case VEC_PACK_SAT_EXPR:
     case VEC_PACK_FIX_TRUNC_EXPR:
+    case VEC_PACK_FLOAT_EXPR:
     case VEC_WIDEN_LSHIFT_HI_EXPR:
     case VEC_WIDEN_LSHIFT_LO_EXPR:
+    case VEC_SERIES_EXPR:
       for (p = get_tree_code_name (code); *p; p++)
        pp_character (buffer, TOUPPER (*p));
       pp_string (buffer, " <");
@@ -393,7 +495,8 @@ dump_binary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
    assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
+dump_ternary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
+                 dump_flags_t flags)
 {
   const char *p;
   enum tree_code code = gimple_assign_rhs_code (gs);
@@ -412,14 +515,6 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
       pp_greater (buffer);
       break;
 
-    case FMA_EXPR:
-      dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
-      pp_string (buffer, " * ");
-      dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
-      pp_string (buffer, " + ");
-      dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
-      break;
-
     case DOT_PROD_EXPR:
       pp_string (buffer, "DOT_PROD_EXPR <");
       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
@@ -441,13 +536,19 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
       break;
     
     case VEC_PERM_EXPR:
-      pp_string (buffer, "VEC_PERM_EXPR <");
+      if (flags & TDF_GIMPLE)
+       pp_string (buffer, "__VEC_PERM (");
+      else
+       pp_string (buffer, "VEC_PERM_EXPR <");
       dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
       pp_string (buffer, ", ");
       dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags, false);
       pp_string (buffer, ", ");
       dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc, flags, false);
-      pp_greater (buffer);
+      if (flags & TDF_GIMPLE)
+       pp_right_paren (buffer);
+      else
+       pp_greater (buffer);
       break;
 
     case REALIGN_LOAD_EXPR:
@@ -478,6 +579,42 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
       pp_greater (buffer);
       break;
 
+    case BIT_INSERT_EXPR:
+      if (flags & TDF_GIMPLE)
+       {
+         pp_string (buffer, "__BIT_INSERT (");
+         dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc,
+                            flags | TDF_SLIM, false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc,
+                            flags | TDF_SLIM, false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs3 (gs), spc,
+                            flags | TDF_SLIM, false);
+         pp_right_paren (buffer);
+       }
+      else
+       {
+         pp_string (buffer, "BIT_INSERT_EXPR <");
+         dump_generic_node (buffer, gimple_assign_rhs1 (gs),
+                            spc, flags, false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs2 (gs),
+                            spc, flags, false);
+         pp_string (buffer, ", ");
+         dump_generic_node (buffer, gimple_assign_rhs3 (gs),
+                            spc, flags, false);
+         if (INTEGRAL_TYPE_P (TREE_TYPE (gimple_assign_rhs2 (gs))))
+           {
+             pp_string (buffer, " (");
+             pp_decimal_int (buffer, TYPE_PRECISION
+                             (TREE_TYPE (gimple_assign_rhs2 (gs))));
+             pp_string (buffer, " bits)");
+           }
+         pp_greater (buffer);
+       }
+      break;
+
     default:
       gcc_unreachable ();
     }
@@ -488,7 +625,8 @@ dump_ternary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
+dump_gimple_assign (pretty_printer *buffer, const gassign *gs, int spc,
+                   dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -499,8 +637,10 @@ dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
        {
        case 4:
          arg3 = gimple_assign_rhs3 (gs);
+         /* FALLTHRU */
        case 3:
          arg2 = gimple_assign_rhs2 (gs);
+         /* FALLTHRU */
        case 2:
          arg1 = gimple_assign_rhs1 (gs);
          break;
@@ -547,14 +687,14 @@ dump_gimple_assign (pretty_printer *buffer, gassign *gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
+dump_gimple_return (pretty_printer *buffer, const greturn *gs, int spc,
+                   dump_flags_t flags)
 {
-  tree t, t2;
+  tree t;
 
   t = gimple_return_retval (gs);
-  t2 = gimple_return_retbnd (gs);
   if (flags & TDF_RAW)
-    dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
+    dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
   else
     {
       pp_string (buffer, "return");
@@ -563,11 +703,6 @@ dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
          pp_space (buffer);
          dump_generic_node (buffer, t, spc, flags, false);
        }
-      if (t2)
-       {
-         pp_string (buffer, ", ");
-         dump_generic_node (buffer, t2, spc, flags, false);
-       }
       pp_semicolon (buffer);
     }
 }
@@ -577,24 +712,82 @@ dump_gimple_return (pretty_printer *buffer, greturn *gs, int spc, int flags)
    dump_gimple_call.  */
 
 static void
-dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
+dump_gimple_call_args (pretty_printer *buffer, const gcall *gs,
+                      dump_flags_t flags)
 {
-  size_t i;
+  size_t i = 0;
 
-  for (i = 0; i < gimple_call_num_args (gs); i++)
+  /* Pretty print first arg to certain internal fns.  */
+  if (gimple_call_internal_p (gs))
     {
-      dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
-      if (i < gimple_call_num_args (gs) - 1)
+      const char *const *enums = NULL;
+      unsigned limit = 0;
+
+      switch (gimple_call_internal_fn (gs))
+       {
+       case IFN_UNIQUE:
+#define DEF(X) #X
+         static const char *const unique_args[] = {IFN_UNIQUE_CODES};
+#undef DEF
+         enums = unique_args;
+         
+         limit = ARRAY_SIZE (unique_args);
+         break;
+         
+       case IFN_GOACC_LOOP:
+#define DEF(X) #X
+         static const char *const loop_args[] = {IFN_GOACC_LOOP_CODES};
+#undef DEF
+         enums = loop_args;
+         limit = ARRAY_SIZE (loop_args);
+         break;
+
+       case IFN_GOACC_REDUCTION:
+#define DEF(X) #X
+         static const char *const reduction_args[]
+           = {IFN_GOACC_REDUCTION_CODES};
+#undef DEF
+         enums = reduction_args;
+         limit = ARRAY_SIZE (reduction_args);
+         break;
+
+       case IFN_ASAN_MARK:
+#define DEF(X) #X
+         static const char *const asan_mark_args[] = {IFN_ASAN_MARK_FLAGS};
+#undef DEF
+         enums = asan_mark_args;
+         limit = ARRAY_SIZE (asan_mark_args);
+         break;
+
+       default:
+         break;
+       }
+      if (limit)
+       {
+         tree arg0 = gimple_call_arg (gs, 0);
+         HOST_WIDE_INT v;
+
+         if (TREE_CODE (arg0) == INTEGER_CST
+             && tree_fits_shwi_p (arg0)
+             && (v = tree_to_shwi (arg0)) >= 0 && v < limit)
+           {
+             i++;
+             pp_string (buffer, enums[v]);
+           }
+       }
+    }
+
+  for (; i < gimple_call_num_args (gs); i++)
+    {
+      if (i)
        pp_string (buffer, ", ");
+      dump_generic_node (buffer, gimple_call_arg (gs, i), 0, flags, false);
     }
 
   if (gimple_call_va_arg_pack_p (gs))
     {
-      if (gimple_call_num_args (gs) > 0)
-        {
-          pp_comma (buffer);
-          pp_space (buffer);
-        }
+      if (i)
+       pp_string (buffer, ", ");
 
       pp_string (buffer, "__builtin_va_arg_pack ()");
     }
@@ -603,7 +796,7 @@ dump_gimple_call_args (pretty_printer *buffer, gcall *gs, int flags)
 /* Dump the points-to solution *PT to BUFFER.  */
 
 static void
-pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
+pp_points_to_solution (pretty_printer *buffer, const pt_solution *pt)
 {
   if (pt->anything)
     {
@@ -632,17 +825,43 @@ pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
        }
       pp_right_brace (buffer);
       if (pt->vars_contains_nonlocal
-         && pt->vars_contains_escaped_heap)
-       pp_string (buffer, " (nonlocal, escaped heap)");
-      else if (pt->vars_contains_nonlocal
-              && pt->vars_contains_escaped)
-       pp_string (buffer, " (nonlocal, escaped)");
-      else if (pt->vars_contains_nonlocal)
-       pp_string (buffer, " (nonlocal)");
-      else if (pt->vars_contains_escaped_heap)
-       pp_string (buffer, " (escaped heap)");
-      else if (pt->vars_contains_escaped)
-       pp_string (buffer, " (escaped)");
+         || pt->vars_contains_escaped
+         || pt->vars_contains_escaped_heap
+         || pt->vars_contains_restrict)
+       {
+         const char *comma = "";
+         pp_string (buffer, " (");
+         if (pt->vars_contains_nonlocal)
+           {
+             pp_string (buffer, "nonlocal");
+             comma = ", ";
+           }
+         if (pt->vars_contains_escaped)
+           {
+             pp_string (buffer, comma);
+             pp_string (buffer, "escaped");
+             comma = ", ";
+           }
+         if (pt->vars_contains_escaped_heap)
+           {
+             pp_string (buffer, comma);
+             pp_string (buffer, "escaped heap");
+             comma = ", ";
+           }
+         if (pt->vars_contains_restrict)
+           {
+             pp_string (buffer, comma);
+             pp_string (buffer, "restrict");
+             comma = ", ";
+           }
+         if (pt->vars_contains_interposable)
+           {
+             pp_string (buffer, comma);
+             pp_string (buffer, "interposable");
+           }
+         pp_string (buffer, ")");
+       }
+
     }
 }
 
@@ -650,14 +869,15 @@ pp_points_to_solution (pretty_printer *buffer, struct pt_solution *pt)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
+dump_gimple_call (pretty_printer *buffer, const gcall *gs, int spc,
+                 dump_flags_t flags)
 {
   tree lhs = gimple_call_lhs (gs);
   tree fn = gimple_call_fn (gs);
 
   if (flags & TDF_ALIAS)
     {
-      struct pt_solution *pt;
+      const pt_solution *pt;
       pt = gimple_call_use_set (gs);
       if (!pt_solution_empty_p (pt))
        {
@@ -677,7 +897,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
   if (flags & TDF_RAW)
     {
       if (gimple_call_internal_p (gs))
-       dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T", gs,
+       dump_gimple_fmt (buffer, spc, flags, "%G <.%s, %T", gs,
                         internal_fn_name (gimple_call_internal_fn (gs)), lhs);
       else
        dump_gimple_fmt (buffer, spc, flags, "%G <%T, %T", gs, fn, lhs);
@@ -701,7 +921,10 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
          pp_space (buffer);
         }
       if (gimple_call_internal_p (gs))
-       pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
+       {
+         pp_dot (buffer);
+         pp_string (buffer, internal_fn_name (gimple_call_internal_fn (gs)));
+       }
       else
        print_call_name (buffer, fn, flags);
       pp_string (buffer, " (");
@@ -722,6 +945,8 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
     pp_string (buffer, " [return slot optimization]");
   if (gimple_call_tail_p (gs))
     pp_string (buffer, " [tail call]");
+  if (gimple_call_must_tail_p (gs))
+    pp_string (buffer, " [must tail call]");
 
   if (fn == NULL)
     return;
@@ -732,8 +957,7 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
   if (TREE_CODE (fn) == FUNCTION_DECL && decl_is_tm_clone (fn))
     pp_string (buffer, " [tm-clone]");
   if (TREE_CODE (fn) == FUNCTION_DECL
-      && DECL_BUILT_IN_CLASS (fn) == BUILT_IN_NORMAL
-      && DECL_FUNCTION_CODE (fn) == BUILT_IN_TM_START
+      && fndecl_built_in_p (fn, BUILT_IN_TM_START)
       && gimple_call_num_args (gs) > 0)
     {
       tree t = gimple_call_arg (gs, 0);
@@ -783,8 +1007,8 @@ dump_gimple_call (pretty_printer *buffer, gcall *gs, int spc, int flags)
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
-                   int flags)
+dump_gimple_switch (pretty_printer *buffer, const gswitch *gs, int spc,
+                   dump_flags_t flags)
 {
   unsigned int i;
 
@@ -796,7 +1020,10 @@ dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
     {
       pp_string (buffer, "switch (");
       dump_generic_node (buffer, gimple_switch_index (gs), spc, flags, true);
-      pp_string (buffer, ") <");
+      if (flags & TDF_GIMPLE)
+       pp_string (buffer, ") {");
+      else
+       pp_string (buffer, ") <");
     }
 
   for (i = 0; i < gimple_switch_num_labels (gs); i++)
@@ -805,11 +1032,32 @@ dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
       gcc_checking_assert (case_label != NULL_TREE);
       dump_generic_node (buffer, case_label, spc, flags, false);
       pp_space (buffer);
-      dump_generic_node (buffer, CASE_LABEL (case_label), spc, flags, false);
+      tree label = CASE_LABEL (case_label);
+      dump_generic_node (buffer, label, spc, flags, false);
+
+      if (cfun && cfun->cfg)
+       {
+         basic_block dest = label_to_block (cfun, label);
+         if (dest)
+           {
+             edge label_edge = find_edge (gimple_bb (gs), dest);
+             if (label_edge && !(flags & TDF_GIMPLE))
+               dump_edge_probability (buffer, label_edge);
+           }
+       }
+
       if (i < gimple_switch_num_labels (gs) - 1)
-        pp_string (buffer, ", ");
+       {
+         if (flags & TDF_GIMPLE)
+           pp_string (buffer, "; ");
+         else
+           pp_string (buffer, ", ");
+       }
     }
-  pp_greater (buffer);
+  if (flags & TDF_GIMPLE)
+    pp_string (buffer, "; }");
+  else
+    pp_greater (buffer);
 }
 
 
@@ -817,7 +1065,8 @@ dump_gimple_switch (pretty_printer *buffer, gswitch *gs, int spc,
    pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
+dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
+                 dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%s, %T, %T, %T, %T>", gs,
@@ -835,6 +1084,23 @@ dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
       dump_generic_node (buffer, gimple_cond_rhs (gs), spc, flags, false);
       if (!(flags & TDF_RHS_ONLY))
        {
+         edge_iterator ei;
+         edge e, true_edge = NULL, false_edge = NULL;
+         basic_block bb = gimple_bb (gs);
+
+         if (bb)
+           {
+             FOR_EACH_EDGE (e, ei, bb->succs)
+               {
+                 if (e->flags & EDGE_TRUE_VALUE)
+                   true_edge = e;
+                 else if (e->flags & EDGE_FALSE_VALUE)
+                   false_edge = e;
+               }
+           }
+
+         bool has_edge_info = true_edge != NULL && false_edge != NULL;
+
          pp_right_paren (buffer);
 
          if (gimple_cond_true_label (gs))
@@ -842,6 +1108,8 @@ dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
              pp_string (buffer, " goto ");
              dump_generic_node (buffer, gimple_cond_true_label (gs),
                                 spc, flags, false);
+             if (has_edge_info && !(flags & TDF_GIMPLE))
+               dump_edge_probability (buffer, true_edge);
              pp_semicolon (buffer);
            }
          if (gimple_cond_false_label (gs))
@@ -849,6 +1117,9 @@ dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
              pp_string (buffer, " else goto ");
              dump_generic_node (buffer, gimple_cond_false_label (gs),
                                 spc, flags, false);
+             if (has_edge_info && !(flags & TDF_GIMPLE))
+               dump_edge_probability (buffer, false_edge);
+
              pp_semicolon (buffer);
            }
        }
@@ -861,16 +1132,19 @@ dump_gimple_cond (pretty_printer *buffer, gcond *gs, int spc, int flags)
    TDF_* in dumpfils.h).  */
 
 static void
-dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
+dump_gimple_label (pretty_printer *buffer, const glabel *gs, int spc,
+                  dump_flags_t flags)
 {
   tree label = gimple_label_label (gs);
   if (flags & TDF_RAW)
-      dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
+    dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, label);
   else
     {
       dump_generic_node (buffer, label, spc, flags, false);
       pp_colon (buffer);
     }
+  if (flags & TDF_GIMPLE)
+    return;
   if (DECL_NONLOCAL (label))
     pp_string (buffer, " [non-local]");
   if ((flags & TDF_EH) && EH_LANDING_PAD_NR (label))
@@ -882,7 +1156,8 @@ dump_gimple_label (pretty_printer *buffer, glabel *gs, int spc, int flags)
    TDF_* in dumpfile.h).  */
 
 static void
-dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
+dump_gimple_goto (pretty_printer *buffer, const ggoto *gs, int spc,
+                 dump_flags_t flags)
 {
   tree label = gimple_goto_dest (gs);
   if (flags & TDF_RAW)
@@ -897,7 +1172,8 @@ dump_gimple_goto (pretty_printer *buffer, ggoto *gs, int spc, int flags)
    TDF_* in dumpfile.h).  */
 
 static void
-dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
+dump_gimple_bind (pretty_printer *buffer, const gbind *gs, int spc,
+                 dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <", gs);
@@ -930,7 +1206,8 @@ dump_gimple_bind (pretty_printer *buffer, gbind *gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
+dump_gimple_try (pretty_printer *buffer, const gtry *gs, int spc,
+                dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -956,6 +1233,8 @@ dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
       newline_and_indent (buffer, spc + 2);
       pp_right_brace (buffer);
 
+      gimple_seq seq = gimple_try_cleanup (gs);
+
       if (gimple_try_kind (gs) == GIMPLE_TRY_CATCH)
        {
          newline_and_indent (buffer, spc);
@@ -969,12 +1248,28 @@ dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
          pp_string (buffer, "finally");
          newline_and_indent (buffer, spc + 2);
          pp_left_brace (buffer);
+
+         if (seq && is_a <geh_else *> (gimple_seq_first_stmt (seq))
+             && gimple_seq_nondebug_singleton_p (seq))
+           {
+             geh_else *stmt = as_a <geh_else *> (gimple_seq_first_stmt (seq));
+             seq = gimple_eh_else_n_body (stmt);
+             pp_newline (buffer);
+             dump_gimple_seq (buffer, seq, spc + 4, flags);
+             newline_and_indent (buffer, spc + 2);
+             pp_right_brace (buffer);
+             seq = gimple_eh_else_e_body (stmt);
+             newline_and_indent (buffer, spc);
+             pp_string (buffer, "else");
+             newline_and_indent (buffer, spc + 2);
+             pp_left_brace (buffer);
+           }
        }
       else
        pp_string (buffer, " <UNKNOWN GIMPLE_TRY> {");
 
       pp_newline (buffer);
-      dump_gimple_seq (buffer, gimple_try_cleanup (gs), spc + 4, flags);
+      dump_gimple_seq (buffer, seq, spc + 4, flags);
       newline_and_indent (buffer, spc + 2);
       pp_right_brace (buffer);
     }
@@ -986,7 +1281,8 @@ dump_gimple_try (pretty_printer *buffer, gtry *gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
+dump_gimple_catch (pretty_printer *buffer, const gcatch *gs, int spc,
+                  dump_flags_t flags)
 {
   if (flags & TDF_RAW)
       dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+CATCH <%S>%->", gs,
@@ -1002,8 +1298,8 @@ dump_gimple_catch (pretty_printer *buffer, gcatch *gs, int spc, int flags)
    dumpfile.h).  */
 
 static void
-dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
-                      int flags)
+dump_gimple_eh_filter (pretty_printer *buffer, const geh_filter *gs, int spc,
+                      dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%T, %+FAILURE <%S>%->", gs,
@@ -1020,7 +1316,7 @@ dump_gimple_eh_filter (pretty_printer *buffer, geh_filter *gs, int spc,
 
 static void
 dump_gimple_eh_must_not_throw (pretty_printer *buffer,
-                              geh_mnt *gs, int spc, int flags)
+                              const geh_mnt *gs, int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs,
@@ -1036,8 +1332,8 @@ dump_gimple_eh_must_not_throw (pretty_printer *buffer,
    dumpfile.h).  */
 
 static void
-dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
-                    int flags)
+dump_gimple_eh_else (pretty_printer *buffer, const geh_else *gs, int spc,
+                    dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags,
@@ -1055,7 +1351,8 @@ dump_gimple_eh_else (pretty_printer *buffer, geh_else *gs, int spc,
    dumpfile.h).  */
 
 static void
-dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
+dump_gimple_resx (pretty_printer *buffer, const gresx *gs, int spc,
+                 dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
@@ -1067,7 +1364,8 @@ dump_gimple_resx (pretty_printer *buffer, gresx *gs, int spc, int flags)
 /* Dump a GIMPLE_EH_DISPATCH tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int flags)
+dump_gimple_eh_dispatch (pretty_printer *buffer, const geh_dispatch *gs,
+                        int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%d>", gs,
@@ -1082,7 +1380,8 @@ dump_gimple_eh_dispatch (pretty_printer *buffer, geh_dispatch *gs, int spc, int
    in dumpfile.h).  */
 
 static void
-dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
+dump_gimple_debug (pretty_printer *buffer, const gdebug *gs, int spc,
+                  dump_flags_t flags)
 {
   switch (gs->subcode)
     {
@@ -1108,6 +1407,26 @@ dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
                         gimple_debug_source_bind_get_value (gs));
       break;
 
+    case GIMPLE_DEBUG_BEGIN_STMT:
+      if (flags & TDF_RAW)
+       dump_gimple_fmt (buffer, spc, flags, "%G BEGIN_STMT", gs);
+      else
+       dump_gimple_fmt (buffer, spc, flags, "# DEBUG BEGIN_STMT");
+      break;
+
+    case GIMPLE_DEBUG_INLINE_ENTRY:
+      if (flags & TDF_RAW)
+       dump_gimple_fmt (buffer, spc, flags, "%G INLINE_ENTRY %T", gs,
+                        gimple_block (gs)
+                        ? block_ultimate_origin (gimple_block (gs))
+                        : NULL_TREE);
+      else
+       dump_gimple_fmt (buffer, spc, flags, "# DEBUG INLINE_ENTRY %T",
+                        gimple_block (gs)
+                        ? block_ultimate_origin (gimple_block (gs))
+                        : NULL_TREE);
+      break;
+
     default:
       gcc_unreachable ();
     }
@@ -1115,7 +1434,8 @@ dump_gimple_debug (pretty_printer *buffer, gdebug *gs, int spc, int flags)
 
 /* Dump a GIMPLE_OMP_FOR tuple on the pretty_printer BUFFER.  */
 static void
-dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
+dump_gimple_omp_for (pretty_printer *buffer, const gomp_for *gs, int spc,
+                    dump_flags_t flags)
 {
   size_t i;
 
@@ -1133,18 +1453,12 @@ dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
        case GF_OMP_FOR_KIND_TASKLOOP:
          kind = " taskloop";
          break;
-       case GF_OMP_FOR_KIND_CILKFOR:
-         kind = " _Cilk_for";
-         break;
        case GF_OMP_FOR_KIND_OACC_LOOP:
          kind = " oacc_loop";
          break;
        case GF_OMP_FOR_KIND_SIMD:
          kind = " simd";
          break;
-       case GF_OMP_FOR_KIND_CILKSIMD:
-         kind = " cilksimd";
-         break;
        default:
          gcc_unreachable ();
        }
@@ -1176,33 +1490,25 @@ dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
        case GF_OMP_FOR_KIND_TASKLOOP:
          pp_string (buffer, "#pragma omp taskloop");
          break;
-       case GF_OMP_FOR_KIND_CILKFOR:
-         break;
        case GF_OMP_FOR_KIND_OACC_LOOP:
          pp_string (buffer, "#pragma acc loop");
          break;
        case GF_OMP_FOR_KIND_SIMD:
          pp_string (buffer, "#pragma omp simd");
          break;
-       case GF_OMP_FOR_KIND_CILKSIMD:
-         pp_string (buffer, "#pragma simd");
+       case GF_OMP_FOR_KIND_GRID_LOOP:
+         pp_string (buffer, "#pragma omp for grid_loop");
          break;
        default:
          gcc_unreachable ();
        }
-      if (gimple_omp_for_kind (gs) != GF_OMP_FOR_KIND_CILKFOR)
-       dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
+      dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
       for (i = 0; i < gimple_omp_for_collapse (gs); i++)
        {
          if (i)
            spc += 2;
-         if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
-           pp_string (buffer, "_Cilk_for (");
-         else
-           {
-             newline_and_indent (buffer, spc);
-             pp_string (buffer, "for (");
-           }
+         newline_and_indent (buffer, spc);
+         pp_string (buffer, "for (");
          dump_generic_node (buffer, gimple_omp_for_index (gs, i), spc,
                             flags, false);
          pp_string (buffer, " = ");
@@ -1248,8 +1554,6 @@ dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
 
       if (!gimple_seq_empty_p (gimple_omp_body (gs)))
        {
-         if (gimple_omp_for_kind (gs) == GF_OMP_FOR_KIND_CILKFOR)
-           dump_omp_clauses (buffer, gimple_omp_for_clauses (gs), spc, flags);
          newline_and_indent (buffer, spc + 2);
          pp_left_brace (buffer);
          pp_newline (buffer);
@@ -1263,8 +1567,8 @@ dump_gimple_omp_for (pretty_printer *buffer, gomp_for *gs, int spc, int flags)
 /* Dump a GIMPLE_OMP_CONTINUE tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
-                         int spc, int flags)
+dump_gimple_omp_continue (pretty_printer *buffer, const gomp_continue *gs,
+                         int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -1288,8 +1592,8 @@ dump_gimple_omp_continue (pretty_printer *buffer, gomp_continue *gs,
 /* Dump a GIMPLE_OMP_SINGLE tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
-                       int spc, int flags)
+dump_gimple_omp_single (pretty_printer *buffer, const gomp_single *gs,
+                       int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -1314,11 +1618,40 @@ dump_gimple_omp_single (pretty_printer *buffer, gomp_single *gs,
     }
 }
 
+/* Dump a GIMPLE_OMP_TASKGROUP tuple on the pretty_printer BUFFER.  */
+
+static void
+dump_gimple_omp_taskgroup (pretty_printer *buffer, const gimple *gs,
+                          int spc, dump_flags_t flags)
+{
+  if (flags & TDF_RAW)
+    {
+      dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S>%nCLAUSES <", gs,
+                      gimple_omp_body (gs));
+      dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
+      dump_gimple_fmt (buffer, spc, flags, " >");
+    }
+  else
+    {
+      pp_string (buffer, "#pragma omp taskgroup");
+      dump_omp_clauses (buffer, gimple_omp_taskgroup_clauses (gs), spc, flags);
+      if (!gimple_seq_empty_p (gimple_omp_body (gs)))
+       {
+         newline_and_indent (buffer, spc + 2);
+         pp_left_brace (buffer);
+         pp_newline (buffer);
+         dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+         newline_and_indent (buffer, spc + 2);
+         pp_right_brace (buffer);
+       }
+    }
+}
+
 /* Dump a GIMPLE_OMP_TARGET tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
-                       int spc, int flags)
+dump_gimple_omp_target (pretty_printer *buffer, const gomp_target *gs,
+                       int spc, dump_flags_t flags)
 {
   const char *kind;
   switch (gimple_omp_target_kind (gs))
@@ -1344,6 +1677,9 @@ dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
     case GF_OMP_TARGET_KIND_OACC_PARALLEL:
       kind = " oacc_parallel";
       break;
+    case GF_OMP_TARGET_KIND_OACC_SERIAL:
+      kind = " oacc_serial";
+      break;
     case GF_OMP_TARGET_KIND_OACC_DATA:
       kind = " oacc_data";
       break;
@@ -1410,8 +1746,8 @@ dump_gimple_omp_target (pretty_printer *buffer, gomp_target *gs,
 /* Dump a GIMPLE_OMP_TEAMS tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
-                      int flags)
+dump_gimple_omp_teams (pretty_printer *buffer, const gomp_teams *gs, int spc,
+                      dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -1439,8 +1775,8 @@ dump_gimple_omp_teams (pretty_printer *buffer, gomp_teams *gs, int spc,
 /* Dump a GIMPLE_OMP_SECTIONS tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
-                         int spc, int flags)
+dump_gimple_omp_sections (pretty_printer *buffer, const gomp_sections *gs,
+                         int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -1472,11 +1808,12 @@ dump_gimple_omp_sections (pretty_printer *buffer, gomp_sections *gs,
     }
 }
 
-/* Dump a GIMPLE_OMP_{MASTER,TASKGROUP,ORDERED,SECTION} tuple on the
+/* Dump a GIMPLE_OMP_{MASTER,ORDERED,SECTION} tuple on the
    pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
+dump_gimple_omp_block (pretty_printer *buffer, const gimple *gs, int spc,
+                      dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
@@ -1488,12 +1825,12 @@ dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
        case GIMPLE_OMP_MASTER:
          pp_string (buffer, "#pragma omp master");
          break;
-       case GIMPLE_OMP_TASKGROUP:
-         pp_string (buffer, "#pragma omp taskgroup");
-         break;
        case GIMPLE_OMP_SECTION:
          pp_string (buffer, "#pragma omp section");
          break;
+       case GIMPLE_OMP_GRID_BODY:
+         pp_string (buffer, "#pragma omp gridified body");
+         break;
        default:
          gcc_unreachable ();
        }
@@ -1512,8 +1849,8 @@ dump_gimple_omp_block (pretty_printer *buffer, gimple *gs, int spc, int flags)
 /* Dump a GIMPLE_OMP_CRITICAL tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
-                         int spc, int flags)
+dump_gimple_omp_critical (pretty_printer *buffer, const gomp_critical *gs,
+                         int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
@@ -1544,8 +1881,8 @@ dump_gimple_omp_critical (pretty_printer *buffer, gomp_critical *gs,
 /* Dump a GIMPLE_OMP_ORDERED tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
-                        int spc, int flags)
+dump_gimple_omp_ordered (pretty_printer *buffer, const gomp_ordered *gs,
+                        int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
@@ -1566,10 +1903,39 @@ dump_gimple_omp_ordered (pretty_printer *buffer, gomp_ordered *gs,
     }
 }
 
+/* Dump a GIMPLE_OMP_SCAN tuple on the pretty_printer BUFFER.  */
+
+static void
+dump_gimple_omp_scan (pretty_printer *buffer, const gomp_scan *gs,
+                     int spc, dump_flags_t flags)
+{
+  if (flags & TDF_RAW)
+    dump_gimple_fmt (buffer, spc, flags, "%G <%+BODY <%S> >", gs,
+                    gimple_omp_body (gs));
+  else
+    {
+      if (gimple_omp_scan_clauses (gs))
+       {
+         pp_string (buffer, "#pragma omp scan");
+         dump_omp_clauses (buffer, gimple_omp_scan_clauses (gs), spc, flags);
+       }
+      if (!gimple_seq_empty_p (gimple_omp_body (gs)))
+       {
+         newline_and_indent (buffer, spc + 2);
+         pp_left_brace (buffer);
+         pp_newline (buffer);
+         dump_gimple_seq (buffer, gimple_omp_body (gs), spc + 4, flags);
+         newline_and_indent (buffer, spc + 2);
+         pp_right_brace (buffer);
+       }
+    }
+}
+
 /* Dump a GIMPLE_OMP_RETURN tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
+dump_gimple_omp_return (pretty_printer *buffer, const gimple *gs, int spc,
+                       dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -1599,16 +1965,19 @@ dump_gimple_omp_return (pretty_printer *buffer, gimple *gs, int spc, int flags)
 /* Dump a GIMPLE_TRANSACTION tuple on the pretty_printer BUFFER.  */
 
 static void
-dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
-                        int spc, int flags)
+dump_gimple_transaction (pretty_printer *buffer, const gtransaction *gs,
+                        int spc, dump_flags_t flags)
 {
   unsigned subcode = gimple_transaction_subcode (gs);
 
   if (flags & TDF_RAW)
     {
       dump_gimple_fmt (buffer, spc, flags,
-                      "%G [SUBCODE=%x,LABEL=%T] <%+BODY <%S> >",
-                      gs, subcode, gimple_transaction_label (gs),
+                      "%G [SUBCODE=%x,NORM=%T,UNINST=%T,OVER=%T] "
+                      "<%+BODY <%S> >",
+                      gs, subcode, gimple_transaction_label_norm (gs),
+                      gimple_transaction_label_uninst (gs),
+                      gimple_transaction_label_over (gs),
                       gimple_transaction_body (gs));
     }
   else
@@ -1621,13 +1990,35 @@ dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
        pp_string (buffer, "__transaction_atomic");
       subcode &= ~GTMA_DECLARATION_MASK;
 
-      if (subcode || gimple_transaction_label (gs))
+      if (gimple_transaction_body (gs))
+       {
+         newline_and_indent (buffer, spc + 2);
+         pp_left_brace (buffer);
+         pp_newline (buffer);
+         dump_gimple_seq (buffer, gimple_transaction_body (gs),
+                          spc + 4, flags);
+         newline_and_indent (buffer, spc + 2);
+         pp_right_brace (buffer);
+       }
+      else
        {
          pp_string (buffer, "  //");
-         if (gimple_transaction_label (gs))
+         if (gimple_transaction_label_norm (gs))
+           {
+             pp_string (buffer, " NORM=");
+             dump_generic_node (buffer, gimple_transaction_label_norm (gs),
+                                spc, flags, false);
+           }
+         if (gimple_transaction_label_uninst (gs))
            {
-             pp_string (buffer, " LABEL=");
-             dump_generic_node (buffer, gimple_transaction_label (gs),
+             pp_string (buffer, " UNINST=");
+             dump_generic_node (buffer, gimple_transaction_label_uninst (gs),
+                                spc, flags, false);
+           }
+         if (gimple_transaction_label_over (gs))
+           {
+             pp_string (buffer, " OVER=");
+             dump_generic_node (buffer, gimple_transaction_label_over (gs),
                                 spc, flags, false);
            }
          if (subcode)
@@ -1668,17 +2059,6 @@ dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
              pp_right_bracket (buffer);
            }
        }
-
-      if (!gimple_seq_empty_p (gimple_transaction_body (gs)))
-       {
-         newline_and_indent (buffer, spc + 2);
-         pp_left_brace (buffer);
-         pp_newline (buffer);
-         dump_gimple_seq (buffer, gimple_transaction_body (gs),
-                          spc + 4, flags);
-         newline_and_indent (buffer, spc + 2);
-         pp_right_brace (buffer);
-       }
     }
 }
 
@@ -1687,7 +2067,8 @@ dump_gimple_transaction (pretty_printer *buffer, gtransaction *gs,
    dumpfile.h).  */
 
 static void
-dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
+dump_gimple_asm (pretty_printer *buffer, const gasm *gs, int spc,
+                dump_flags_t flags)
 {
   unsigned int i, n, f, fields;
 
@@ -1760,6 +2141,8 @@ dump_gimple_asm (pretty_printer *buffer, gasm *gs, int spc, int flags)
       pp_string (buffer, "__asm__");
       if (gimple_asm_volatile_p (gs))
        pp_string (buffer, " __volatile__");
+      if (gimple_asm_inline_p (gs))
+       pp_string (buffer, " __inline__");
       if (gimple_asm_nlabels (gs))
        pp_string (buffer, " goto");
       pp_string (buffer, "(\"");
@@ -1864,7 +2247,7 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
       && SSA_NAME_RANGE_INFO (node))
     {
       wide_int min, max, nonzero_bits;
-      value_range_type range_type = get_range_info (node, &min, &max);
+      value_range_kind range_type = get_range_info (node, &min, &max);
 
       if (range_type == VR_VARYING)
        pp_printf (buffer, "# RANGE VR_VARYING");
@@ -1887,14 +2270,25 @@ dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
     }
 }
 
+/* As dump_ssaname_info, but dump to FILE.  */
+
+void
+dump_ssaname_info_to_file (FILE *file, tree node, int spc)
+{
+  pretty_printer buffer;
+  pp_needs_newline (&buffer) = true;
+  buffer.buffer->stream = file;
+  dump_ssaname_info (&buffer, node, spc);
+  pp_flush (&buffer);
+}
 
 /* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
    The caller is responsible for calling pp_flush on BUFFER to finalize
    pretty printer.  If COMMENT is true, print this after #.  */
 
 static void
-dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
-                int flags)
+dump_gimple_phi (pretty_printer *buffer, const gphi *phi, int spc, bool comment,
+                dump_flags_t flags)
 {
   size_t i;
   tree lhs = gimple_phi_result (phi);
@@ -1911,21 +2305,37 @@ dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
   else
     {
       dump_generic_node (buffer, lhs, spc, flags, false);
-      pp_string (buffer, " = PHI <");
+      if (flags & TDF_GIMPLE)
+       pp_string (buffer, " = __PHI (");
+      else
+       pp_string (buffer, " = PHI <");
     }
   for (i = 0; i < gimple_phi_num_args (phi); i++)
     {
       if ((flags & TDF_LINENO) && gimple_phi_arg_has_location (phi, i))
        dump_location (buffer, gimple_phi_arg_location (phi, i));
+      basic_block src = gimple_phi_arg_edge (phi, i)->src;
+      if (flags & TDF_GIMPLE)
+       {
+         pp_string (buffer, "__BB");
+         pp_decimal_int (buffer, src->index);
+         pp_string (buffer, ": ");
+       }
       dump_generic_node (buffer, gimple_phi_arg_def (phi, i), spc, flags,
                         false);
-      pp_left_paren (buffer);
-      pp_decimal_int (buffer, gimple_phi_arg_edge (phi, i)->src->index);
-      pp_right_paren (buffer);
+      if (! (flags & TDF_GIMPLE))
+       {
+         pp_left_paren (buffer);
+         pp_decimal_int (buffer, src->index);
+         pp_right_paren (buffer);
+       }
       if (i < gimple_phi_num_args (phi) - 1)
        pp_string (buffer, ", ");
     }
-  pp_greater (buffer);
+  if (flags & TDF_GIMPLE)
+    pp_string (buffer, ");");
+  else
+    pp_greater (buffer);
 }
 
 
@@ -1934,8 +2344,8 @@ dump_gimple_phi (pretty_printer *buffer, gphi *phi, int spc, bool comment,
    dumpfile.h).  */
 
 static void
-dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
-                         int spc, int flags)
+dump_gimple_omp_parallel (pretty_printer *buffer, const gomp_parallel *gs,
+                         int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -1988,8 +2398,8 @@ dump_gimple_omp_parallel (pretty_printer *buffer, gomp_parallel *gs,
    dumpfile.h).  */
 
 static void
-dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
-                     int flags)
+dump_gimple_omp_task (pretty_printer *buffer, const gomp_task *gs, int spc,
+                     dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2008,6 +2418,8 @@ dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
       gimple_seq body;
       if (gimple_omp_task_taskloop_p (gs))
        pp_string (buffer, "#pragma omp taskloop");
+      else if (gimple_omp_task_taskwait_p (gs))
+       pp_string (buffer, "#pragma omp taskwait");
       else
        pp_string (buffer, "#pragma omp task");
       dump_omp_clauses (buffer, gimple_omp_task_clauses (gs), spc, flags);
@@ -2048,8 +2460,8 @@ dump_gimple_omp_task (pretty_printer *buffer, gomp_task *gs, int spc,
    in dumpfile.h).  */
 
 static void
-dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
-                            int spc, int flags)
+dump_gimple_omp_atomic_load (pretty_printer *buffer, const gomp_atomic_load *gs,
+                            int spc, dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2060,8 +2472,8 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
   else
     {
       pp_string (buffer, "#pragma omp atomic_load");
-      if (gimple_omp_atomic_seq_cst_p (gs))
-       pp_string (buffer, " seq_cst");
+      dump_omp_atomic_memory_order (buffer,
+                                   gimple_omp_atomic_memory_order (gs));
       if (gimple_omp_atomic_need_value_p (gs))
        pp_string (buffer, " [needed]");
       newline_and_indent (buffer, spc + 2);
@@ -2082,7 +2494,8 @@ dump_gimple_omp_atomic_load (pretty_printer *buffer, gomp_atomic_load *gs,
 
 static void
 dump_gimple_omp_atomic_store (pretty_printer *buffer,
-                             gomp_atomic_store *gs, int spc, int flags)
+                             const gomp_atomic_store *gs, int spc,
+                             dump_flags_t flags)
 {
   if (flags & TDF_RAW)
     {
@@ -2091,9 +2504,10 @@ dump_gimple_omp_atomic_store (pretty_printer *buffer,
     }
   else
     {
-      pp_string (buffer, "#pragma omp atomic_store ");
-      if (gimple_omp_atomic_seq_cst_p (gs))
-       pp_string (buffer, "seq_cst ");
+      pp_string (buffer, "#pragma omp atomic_store");
+      dump_omp_atomic_memory_order (buffer,
+                                   gimple_omp_atomic_memory_order (gs));
+      pp_space (buffer);
       if (gimple_omp_atomic_need_value_p (gs))
        pp_string (buffer, "[needed] ");
       pp_left_paren (buffer);
@@ -2108,7 +2522,8 @@ dump_gimple_omp_atomic_store (pretty_printer *buffer,
    FLAGS are as in pp_gimple_stmt_1.  */
 
 static void
-dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
+dump_gimple_mem_ops (pretty_printer *buffer, const gimple *gs, int spc,
+                    dump_flags_t flags)
 {
   tree vdef = gimple_vdef (gs);
   tree vuse = gimple_vuse (gs);
@@ -2138,13 +2553,14 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimple *gs, int spc, int flags)
    pp_flush on BUFFER to finalize the pretty printer.  */
 
 void
-pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
+pp_gimple_stmt_1 (pretty_printer *buffer, const gimple *gs, int spc,
+                 dump_flags_t flags)
 {
   if (!gs)
     return;
 
   if (flags & TDF_STMTADDR)
-    pp_printf (buffer, "<&%p> ", (void *) gs);
+    pp_printf (buffer, "<&%p> ", (const void *) gs);
 
   if ((flags & TDF_LINENO) && gimple_has_location (gs))
     dump_location (buffer, gimple_location (gs));
@@ -2169,31 +2585,31 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
   switch (gimple_code (gs))
     {
     case GIMPLE_ASM:
-      dump_gimple_asm (buffer, as_a <gasm *> (gs), spc, flags);
+      dump_gimple_asm (buffer, as_a <const gasm *> (gs), spc, flags);
       break;
 
     case GIMPLE_ASSIGN:
-      dump_gimple_assign (buffer, as_a <gassign *> (gs), spc, flags);
+      dump_gimple_assign (buffer, as_a <const gassign *> (gs), spc, flags);
       break;
 
     case GIMPLE_BIND:
-      dump_gimple_bind (buffer, as_a <gbind *> (gs), spc, flags);
+      dump_gimple_bind (buffer, as_a <const gbind *> (gs), spc, flags);
       break;
 
     case GIMPLE_CALL:
-      dump_gimple_call (buffer, as_a <gcall *> (gs), spc, flags);
+      dump_gimple_call (buffer, as_a <const gcall *> (gs), spc, flags);
       break;
 
     case GIMPLE_COND:
-      dump_gimple_cond (buffer, as_a <gcond *> (gs), spc, flags);
+      dump_gimple_cond (buffer, as_a <const gcond *> (gs), spc, flags);
       break;
 
     case GIMPLE_LABEL:
-      dump_gimple_label (buffer, as_a <glabel *> (gs), spc, flags);
+      dump_gimple_label (buffer, as_a <const glabel *> (gs), spc, flags);
       break;
 
     case GIMPLE_GOTO:
-      dump_gimple_goto (buffer, as_a <ggoto *> (gs), spc, flags);
+      dump_gimple_goto (buffer, as_a <const ggoto *> (gs), spc, flags);
       break;
 
     case GIMPLE_NOP:
@@ -2201,62 +2617,62 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
       break;
 
     case GIMPLE_RETURN:
-      dump_gimple_return (buffer, as_a <greturn *> (gs), spc, flags);
+      dump_gimple_return (buffer, as_a <const greturn *> (gs), spc, flags);
       break;
 
     case GIMPLE_SWITCH:
-      dump_gimple_switch (buffer, as_a <gswitch *> (gs), spc, flags);
+      dump_gimple_switch (buffer, as_a <const gswitch *> (gs), spc, flags);
       break;
 
     case GIMPLE_TRY:
-      dump_gimple_try (buffer, as_a <gtry *> (gs), spc, flags);
+      dump_gimple_try (buffer, as_a <const gtry *> (gs), spc, flags);
       break;
 
     case GIMPLE_PHI:
-      dump_gimple_phi (buffer, as_a <gphi *> (gs), spc, false, flags);
+      dump_gimple_phi (buffer, as_a <const gphi *> (gs), spc, false, flags);
       break;
 
     case GIMPLE_OMP_PARALLEL:
-      dump_gimple_omp_parallel (buffer, as_a <gomp_parallel *> (gs), spc,
+      dump_gimple_omp_parallel (buffer, as_a <const gomp_parallel *> (gs), spc,
                                flags);
       break;
 
     case GIMPLE_OMP_TASK:
-      dump_gimple_omp_task (buffer, as_a <gomp_task *> (gs), spc, flags);
+      dump_gimple_omp_task (buffer, as_a <const gomp_task *> (gs), spc, flags);
       break;
 
     case GIMPLE_OMP_ATOMIC_LOAD:
-      dump_gimple_omp_atomic_load (buffer, as_a <gomp_atomic_load *> (gs),
+      dump_gimple_omp_atomic_load (buffer, as_a <const gomp_atomic_load *> (gs),
                                   spc, flags);
       break;
 
     case GIMPLE_OMP_ATOMIC_STORE:
       dump_gimple_omp_atomic_store (buffer,
-                                   as_a <gomp_atomic_store *> (gs),
+                                   as_a <const gomp_atomic_store *> (gs),
                                    spc, flags);
       break;
 
     case GIMPLE_OMP_FOR:
-      dump_gimple_omp_for (buffer, as_a <gomp_for *> (gs), spc, flags);
+      dump_gimple_omp_for (buffer, as_a <const gomp_for *> (gs), spc, flags);
       break;
 
     case GIMPLE_OMP_CONTINUE:
-      dump_gimple_omp_continue (buffer, as_a <gomp_continue *> (gs), spc,
+      dump_gimple_omp_continue (buffer, as_a <const gomp_continue *> (gs), spc,
                                flags);
       break;
 
     case GIMPLE_OMP_SINGLE:
-      dump_gimple_omp_single (buffer, as_a <gomp_single *> (gs), spc,
+      dump_gimple_omp_single (buffer, as_a <const gomp_single *> (gs), spc,
                              flags);
       break;
 
     case GIMPLE_OMP_TARGET:
-      dump_gimple_omp_target (buffer, as_a <gomp_target *> (gs), spc,
+      dump_gimple_omp_target (buffer, as_a <const gomp_target *> (gs), spc,
                              flags);
       break;
 
     case GIMPLE_OMP_TEAMS:
-      dump_gimple_omp_teams (buffer, as_a <gomp_teams *> (gs), spc,
+      dump_gimple_omp_teams (buffer, as_a <const gomp_teams *> (gs), spc,
                             flags);
       break;
 
@@ -2265,7 +2681,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
       break;
 
     case GIMPLE_OMP_SECTIONS:
-      dump_gimple_omp_sections (buffer, as_a <gomp_sections *> (gs),
+      dump_gimple_omp_sections (buffer, as_a <const gomp_sections *> (gs),
                                spc, flags);
       break;
 
@@ -2273,51 +2689,61 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
       pp_string (buffer, "GIMPLE_SECTIONS_SWITCH");
       break;
 
-    case GIMPLE_OMP_MASTER:
     case GIMPLE_OMP_TASKGROUP:
+      dump_gimple_omp_taskgroup (buffer, gs, spc, flags);
+      break;
+
+    case GIMPLE_OMP_MASTER:
     case GIMPLE_OMP_SECTION:
+    case GIMPLE_OMP_GRID_BODY:
       dump_gimple_omp_block (buffer, gs, spc, flags);
       break;
 
     case GIMPLE_OMP_ORDERED:
-      dump_gimple_omp_ordered (buffer, as_a <gomp_ordered *> (gs), spc,
+      dump_gimple_omp_ordered (buffer, as_a <const gomp_ordered *> (gs), spc,
                               flags);
       break;
 
+    case GIMPLE_OMP_SCAN:
+      dump_gimple_omp_scan (buffer, as_a <const gomp_scan *> (gs), spc,
+                           flags);
+      break;
+
     case GIMPLE_OMP_CRITICAL:
-      dump_gimple_omp_critical (buffer, as_a <gomp_critical *> (gs), spc,
+      dump_gimple_omp_critical (buffer, as_a <const gomp_critical *> (gs), spc,
                                flags);
       break;
 
     case GIMPLE_CATCH:
-      dump_gimple_catch (buffer, as_a <gcatch *> (gs), spc, flags);
+      dump_gimple_catch (buffer, as_a <const gcatch *> (gs), spc, flags);
       break;
 
     case GIMPLE_EH_FILTER:
-      dump_gimple_eh_filter (buffer, as_a <geh_filter *> (gs), spc, flags);
+      dump_gimple_eh_filter (buffer, as_a <const geh_filter *> (gs), spc,
+                            flags);
       break;
 
     case GIMPLE_EH_MUST_NOT_THROW:
       dump_gimple_eh_must_not_throw (buffer,
-                                    as_a <geh_mnt *> (gs),
+                                    as_a <const geh_mnt *> (gs),
                                     spc, flags);
       break;
 
     case GIMPLE_EH_ELSE:
-      dump_gimple_eh_else (buffer, as_a <geh_else *> (gs), spc, flags);
+      dump_gimple_eh_else (buffer, as_a <const geh_else *> (gs), spc, flags);
       break;
 
     case GIMPLE_RESX:
-      dump_gimple_resx (buffer, as_a <gresx *> (gs), spc, flags);
+      dump_gimple_resx (buffer, as_a <const gresx *> (gs), spc, flags);
       break;
 
     case GIMPLE_EH_DISPATCH:
-      dump_gimple_eh_dispatch (buffer, as_a <geh_dispatch *> (gs), spc,
+      dump_gimple_eh_dispatch (buffer, as_a <const geh_dispatch *> (gs), spc,
                               flags);
       break;
 
     case GIMPLE_DEBUG:
-      dump_gimple_debug (buffer, as_a <gdebug *> (gs), spc, flags);
+      dump_gimple_debug (buffer, as_a <const gdebug *> (gs), spc, flags);
       break;
 
     case GIMPLE_PREDICT:
@@ -2331,7 +2757,7 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
       break;
 
     case GIMPLE_TRANSACTION:
-      dump_gimple_transaction (buffer, as_a <gtransaction *> (gs), spc,
+      dump_gimple_transaction (buffer, as_a <const gtransaction *> (gs), spc,
                               flags);
       break;
 
@@ -2345,7 +2771,8 @@ pp_gimple_stmt_1 (pretty_printer *buffer, gimple *gs, int spc, int flags)
    spaces and details described by flags.  */
 
 static void
-dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
+dump_gimple_bb_header (FILE *outf, basic_block bb, int indent,
+                      dump_flags_t flags)
 {
   if (flags & TDF_BLOCKS)
     {
@@ -2353,8 +2780,7 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
        {
          gimple_stmt_iterator gsi;
 
-         if (flags & TDF_COMMENT)
-           fputs (";; ", outf);
+         fputs (";; ", outf);
 
          for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
            if (!is_gimple_debug (gsi_stmt (gsi))
@@ -2371,9 +2797,20 @@ dump_gimple_bb_header (FILE *outf, basic_block bb, int indent, int flags)
     }
   else
     {
-      gimple *stmt = first_stmt (bb);
-      if (!stmt || gimple_code (stmt) != GIMPLE_LABEL)
-       fprintf (outf, "%*s<bb %d>:\n", indent, "", bb->index);
+      if (flags & TDF_GIMPLE)
+       {
+         fprintf (outf, "%*s__BB(%d", indent, "", bb->index);
+         if (bb->loop_father->header == bb)
+           fprintf (outf, ",loop_header(%d)", bb->loop_father->num);
+         if (bb->count.initialized_p ())
+           fprintf (outf, ",%s(%d)",
+                    profile_quality_as_string (bb->count.quality ()),
+                    bb->count.value ());
+         fprintf (outf, "):\n");
+       }
+      else
+       fprintf (outf, "%*s<bb %d> %s:\n",
+                indent, "", bb->index, dump_profile (bb->count));
     }
 }
 
@@ -2385,7 +2822,7 @@ static void
 dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
                       basic_block bb ATTRIBUTE_UNUSED,
                       int indent ATTRIBUTE_UNUSED,
-                      int flags ATTRIBUTE_UNUSED)
+                      dump_flags_t flags ATTRIBUTE_UNUSED)
 {
   /* There is currently no GIMPLE-specific basic block info to dump.  */
   return;
@@ -2396,7 +2833,8 @@ dump_gimple_bb_footer (FILE *outf ATTRIBUTE_UNUSED,
    by FLAGS and indented by INDENT spaces.  */
 
 static void
-dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
+dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent,
+               dump_flags_t flags)
 {
   gphi_iterator i;
 
@@ -2406,7 +2844,8 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
       if (!virtual_operand_p (gimple_phi_result (phi)) || (flags & TDF_VOPS))
         {
           INDENT (indent);
-         dump_gimple_phi (buffer, phi, indent, true, flags);
+         dump_gimple_phi (buffer, phi, indent,
+                          (flags & TDF_GIMPLE) ? false : true, flags);
           pp_newline (buffer);
         }
     }
@@ -2417,26 +2856,32 @@ dump_phi_nodes (pretty_printer *buffer, basic_block bb, int indent, int flags)
    to BUFFER.  */
 
 static void
-pp_cfg_jump (pretty_printer *buffer, basic_block bb)
+pp_cfg_jump (pretty_printer *buffer, edge e, dump_flags_t flags)
 {
-  gimple *stmt;
-
-  stmt = first_stmt (bb);
-
-  pp_string (buffer, "goto <bb ");
-  pp_decimal_int (buffer, bb->index);
-  pp_greater (buffer);
-  if (stmt && gimple_code (stmt) == GIMPLE_LABEL)
+  if (flags & TDF_GIMPLE)
     {
-      pp_string (buffer, " (");
-      dump_generic_node (buffer,
-                        gimple_label_label (as_a <glabel *> (stmt)),
-                        0, 0, false);
-      pp_right_paren (buffer);
+      pp_string (buffer, "goto __BB");
+      pp_decimal_int (buffer, e->dest->index);
+      if (e->probability.initialized_p ())
+       {
+         pp_string (buffer, "(");
+         pp_string (buffer,
+                    profile_quality_as_string (e->probability.quality ()));
+         pp_string (buffer, "(");
+         pp_decimal_int (buffer, e->probability.value ());
+         pp_string (buffer, "))");
+       }
       pp_semicolon (buffer);
     }
   else
-    pp_semicolon (buffer);
+    {
+      pp_string (buffer, "goto <bb ");
+      pp_decimal_int (buffer, e->dest->index);
+      pp_greater (buffer);
+      pp_semicolon (buffer);
+
+      dump_edge_probability (buffer, e);
+    }
 }
 
 
@@ -2445,7 +2890,7 @@ pp_cfg_jump (pretty_printer *buffer, basic_block bb)
 
 static void
 dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
-                    int flags)
+                    dump_flags_t flags)
 {
   edge e;
   gimple *stmt;
@@ -2464,11 +2909,11 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
       extract_true_false_edges_from_block (bb, &true_edge, &false_edge);
 
       INDENT (indent + 2);
-      pp_cfg_jump (buffer, true_edge->dest);
+      pp_cfg_jump (buffer, true_edge, flags);
       newline_and_indent (buffer, indent);
       pp_string (buffer, "else");
       newline_and_indent (buffer, indent + 2);
-      pp_cfg_jump (buffer, false_edge->dest);
+      pp_cfg_jump (buffer, false_edge, flags);
       pp_newline (buffer);
       return;
     }
@@ -2477,7 +2922,7 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
      goto to the dump.  */
   e = find_fallthru_edge (bb->succs);
 
-  if (e && e->dest != bb->next_bb)
+  if (e && (e->dest != bb->next_bb || (flags & TDF_GIMPLE)))
     {
       INDENT (indent);
 
@@ -2485,7 +2930,7 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
          && e->goto_locus != UNKNOWN_LOCATION)
        dump_location (buffer, e->goto_locus);
 
-      pp_cfg_jump (buffer, e->dest);
+      pp_cfg_jump (buffer, e, flags);
       pp_newline (buffer);
     }
 }
@@ -2496,7 +2941,7 @@ dump_implicit_edges (pretty_printer *buffer, basic_block bb, int indent,
 
 static void
 gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
-                    int flags)
+                    dump_flags_t flags)
 {
   gimple_stmt_iterator gsi;
   gimple *stmt;
@@ -2532,7 +2977,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic_block bb, int indent,
    indented by INDENT spaces.  */
 
 void
-gimple_dump_bb (FILE *file, basic_block bb, int indent, int flags)
+gimple_dump_bb (FILE *file, basic_block bb, int indent, dump_flags_t flags)
 {
   dump_gimple_bb_header (file, bb, indent, flags);
   if (bb->index >= NUM_FIXED_BLOCKS)
@@ -2586,3 +3031,23 @@ gimple_dump_bb_for_graph (pretty_printer *pp, basic_block bb)
   pp_write_text_as_dot_label_to_stream (pp, /*for_record=*/true);
 }
 
+
+/* Handle the %G format for TEXT.  Same as %K in handle_K_format in
+   tree-pretty-print.c but with a Gimple statement as an argument.  */
+
+void
+percent_G_format (text_info *text)
+{
+  gimple *stmt = va_arg (*text->args_ptr, gimple*);
+
+  /* Fall back on the rich location if the statement doesn't have one.  */
+  location_t loc = gimple_location (stmt);
+  if (loc == UNKNOWN_LOCATION)
+    loc = text->m_richloc->get_loc ();
+  tree block = gimple_block (stmt);
+  percent_K_format (text, loc, block);
+}
+
+#if __GNUC__ >= 10
+#  pragma GCC diagnostic pop
+#endif