public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Add option for dumping to stderr (issue6190057)
@ 2012-05-09  6:46 Sharad Singhai
  2012-05-09  6:52 ` Andrew Pinski
  2012-05-09  7:22 ` Gabriel Dos Reis
  0 siblings, 2 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-05-09  6:46 UTC (permalink / raw)
  To: reply, gcc-patches

In response to comments, I have updated the patch to support dumps in
user provided files via the option -fdump-xxx=<filename>. The
filenames stdout/stderr are treated specially, and are considered
standard streams.

Also updated documentation and a testcase. Okay for trunk?

Thanks,
Sharad

2012-05-08   Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for new option.
	* tree-dump.c (dump_stream_p): New function.
	(dump_files): Update for new field.
	(dump_switch_p_1): Handle user provided filenames.
	(dump_begin): Likewise.
	(get_dump_file_name): Likewise.
	(dump_enable_all): Add new parameter USER_FILENAME.
	All callers updated.
	(dump_end): Remove attribute.
	* tree-pass.h (enum tree_dump_index): Add new constant.
	(struct dump_file_info): Add new field USER_FILENAME.
	* testsuite/g++.dg/other/dump-userfile-1.C: New test.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 187265)
+++ doc/invoke.texi	(working copy)
@@ -5322,20 +5322,24 @@ Here are some examples showing uses of these optio
 
 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass}=@var{filename}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
 compiler.  The file names for most of the dumps are made by appending
 a pass number and a word to the @var{dumpname}, and the files are
-created in the directory of the output file.  Note that the pass
-number is computed statically as passes get registered into the pass
-manager.  Thus the numbering is not related to the dynamic order of
-execution of passes.  In particular, a pass installed by a plugin
-could have a number over 200 even if it executed quite early.
-@var{dumpname} is generated from the name of the output file, if
-explicitly specified and it is not an executable, otherwise it is the
-basename of the source file. These switches may have different effects
-when @option{-E} is used for preprocessing.
+created in the directory of the output file. If the
+@option{=@var{filename}} is appended to the longer form of the dump
+option then the dump is done on that file instead of numbered
+files. The filenames stdout and stderr are treated specially. Note
+that the pass number is computed statically as passes get registered
+into the pass manager.  Thus the numbering is not related to the
+dynamic order of execution of passes.  In particular, a pass installed
+by a plugin could have a number over 200 even if it executed quite
+early.  @var{dumpname} is generated from the name of the output file,
+if explicitly specified and it is not an executable, otherwise it is
+the basename of the source file. These switches may have different
+effects when @option{-E} is used for preprocessing.
 
 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
 @option{-d} option @var{letters}.  Here are the possible
@@ -5599,6 +5603,10 @@ These dumps are defined but always produce empty f
 @opindex fdump-rtl-all
 Produce all the dumps listed above.
 
+@item -fdump-rtl-all=stderr
+@opindex fdump-rtl-all=stderr
+Produce all RTL dumps on stderr.
+
 @item -dA
 @opindex dA
 Annotate the assembler output with miscellaneous debugging information.
@@ -5719,15 +5727,19 @@ counters for each function compiled.
 
 @item -fdump-tree-@var{switch}
 @itemx -fdump-tree-@var{switch}-@var{options}
+@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
-@samp{-@var{options}} form is used, @var{options} is a list of
-@samp{-} separated options which control the details of the dump.  Not
-all options are applicable to all dumps; those that are not
-meaningful are ignored.  The following options are available
+created in the same directory as the output file. In case of
+@option{=@var{filename}}, the dump output is on the given file. Note
+that the filenames stdout and stderr are treated specially and dumps
+are done on standard streams. If the @samp{-@var{options}} form is
+used, @var{options} is a list of @samp{-} separated options which
+control the details or location of the dump.  Not all options are
+applicable to all dumps; those that are not meaningful are ignored.
+The following options are available
 
 @table @samp
 @item address
@@ -5765,9 +5777,56 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item slim
+Inhibit dumping of members of a scope or body of a function merely
+because that scope has been reached.  Only dump such items when they
+are directly reachable by some other path.  When dumping pretty-printed
+trees, this option inhibits dumping the bodies of control structures.
+@item =@var{filename}
+Instead of using an auto generated name for a dump file, use the
+provided name. For example:
+
+@smallexample
+gcc -O2 -fdump-tree-pre=foobar.dump
+@end smallexample
+
+produces PRE dump in a file named foobar.dump. Similarly
+
+@smallexample
+gcc -O2 -fdump-tree-all=all.dump
+@end smallexample
+
+produces all tree dumps in a file named all.dump.
+
+Note that stdout and stderr are treated specially, and the dumps are
+done on standard streams. In case of any conflicts, the user provided
+filename takes precedence. For example:
+
+@smallexample
+gcc -O2 -fdump-tree-pre=stderr -fdump-tree-pre ...
+gcc -O2 -fdump-tree-pre -fdump-tree-pre=stderr ...
+@end smallexample
+
+Both invocations produce the PRE dump on stderr. Similarly, for the
+following
+
+@smallexample
+gcc -O2 -fdump-tree-all=stderr -fdump-tree-pre ...
+@end smallexample
+
+All the dumps are output on stderr. In the following example,
+
+@smallexample
+gcc -fdump-tree-all -fdump-tree-pre=stderr ...
+@end smallexample
+
+all the dumps are written into named files except the PRE dump, which
+is output on stderr, because @option{-fdump-tree-pre=stderr} takes
+precedence.
+
 @item all
-Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
-and @option{lineno}.
+Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
+@option{lineno}.
 @end table
 
 The following tree dumps are possible:
@@ -5913,6 +5972,10 @@ is made by appending @file{.vrp} to the source fil
 @item all
 @opindex fdump-tree-all
 Enable all the available tree dumps with the flags provided in this option.
+
+@item all=stderr
+@opindex fdump-tree-all=stderr
+Enable all the available tree dumps on the stderr.
 @end table
 
 @item -ftree-vectorizer-verbose=@var{n}
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 187265)
+++ tree-dump.c	(working copy)
@@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
    tree_dump_index enumeration in tree-pass.h.  */
 static struct dump_file_info dump_files[TDI_end] =
 {
-  {NULL, NULL, NULL, 0, 0, 0},
-  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
-  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
-  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
-  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
-  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
-  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
-  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
-  {".ads", "ada-spec", NULL, 0, 0, 7},
+  {NULL, NULL, NULL, NULL, 0, 0, 0},
+  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
+  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
+  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
+  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
+  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
+  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
+  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
+  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
 #define FIRST_AUTO_NUMBERED_DUMP 8
 
-  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
-  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
-  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
+  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
+  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
+  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
 };
 
 /* Dynamically registered tree dump files and switches.  */
@@ -802,7 +802,7 @@ struct dump_option_value_info
 };
 
 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in tree-pass.h */
 static const struct dump_option_value_info dump_options[] =
 {
   {"address", TDF_ADDRESS},
@@ -892,6 +892,9 @@ get_dump_file_name (int phase)
   if (dfi->state == 0)
     return NULL;
 
+  if (dfi->user_filename)
+    return xstrdup (dfi->user_filename);
+
   if (dfi->num < 0)
     dump_id[0] = '\0';
   else
@@ -911,6 +914,19 @@ get_dump_file_name (int phase)
   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }
 
+/* Return non-zero iff the USER_FILENAME corresponds to stdout or
+   stderr stream.  */
+
+static int
+dump_stream_p (const char *user_filename)
+{
+  if (user_filename)
+    return !strncmp ("stderr", user_filename, 6) ||
+      !strncmp ("stdout", user_filename, 6);
+  else
+    return 0;
+}
+
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
@@ -926,14 +942,28 @@ dump_begin (int phase, int *flag_ptr)
   if (phase == TDI_none || !dump_enabled_p (phase))
     return NULL;
 
-  name = get_dump_file_name (phase);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
-  if (!stream)
-    error ("could not open dump file %qs: %m", name);
+  if (dump_stream_p (dfi->user_filename))
+    {
+      if (!strncmp ("stderr", dfi->user_filename, 6))
+        stream = stderr;
+      else
+        if (!strncmp ("stdout", dfi->user_filename, 6))
+          stream = stdout;
+        else
+          error ("unknown stream: %qs: %m", dfi->user_filename);
+      dfi->state = 1;
+    }
   else
-    dfi->state = 1;
-  free (name);
+    {
+      name = get_dump_file_name (phase);
+      stream = fopen (name, dfi->state < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        dfi->state = 1;
+      free (name);
+    }
 
   if (flag_ptr)
     *flag_ptr = dfi->flags;
@@ -987,35 +1017,45 @@ dump_flag_name (int phase)
    dump_begin.  */
 
 void
-dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
+dump_end (int phase, FILE *stream)
 {
-  fclose (stream);
+  struct dump_file_info *dfi = get_dump_file_info (phase);
+  if (!dump_stream_p (dfi->user_filename))
+    fclose (stream);
 }
 
 /* Enable all tree dumps.  Return number of enabled tree dumps.  */
 
 static int
-dump_enable_all (int flags)
+dump_enable_all (int flags, const char *user_filename)
 {
   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;
 
   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_dump_type))
-      {
-        dump_files[i].state = -1;
-        dump_files[i].flags |= flags;
-        n++;
-      }
+    {
+      if ((dump_files[i].flags & ir_dump_type))
+        {
+          dump_files[i].state = -1;
+          dump_files[i].flags |= flags;
+          n++;
+        }
+      if (user_filename)
+        dump_files[i].user_filename = user_filename;
+    }
 
   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_dump_type))
-      {
-        extra_dump_files[i].state = -1;
-        extra_dump_files[i].flags |= flags;
-	n++;
-      }
+    {
+      if ((extra_dump_files[i].flags & ir_dump_type))
+        {
+          extra_dump_files[i].state = -1;
+          extra_dump_files[i].flags |= flags;
+          n++;
+        }
+      if (user_filename)
+        extra_dump_files[i].user_filename = user_filename;
+    }
 
   return n;
 }
@@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   if (!option_value)
     return 0;
 
-  if (*option_value && *option_value != '-')
+  if (*option_value && *option_value != '-' && *option_value != '=')
     return 0;
 
   ptr = option_value;
@@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
       while (*ptr == '-')
 	ptr++;
       end_ptr = strchr (ptr, '-');
+
       if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;
 
+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  The
+             user provided filename overrides generated dump names as
+             well as other command line filenames.  */
+          flags |= TDF_USER_FILENAME;
+          if (dfi->user_filename)
+            free (dfi->user_filename);
+          dfi->user_filename = xstrdup (ptr + 1);
+          break;
+        }
+
       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
-	  {
-	    flags |= option_ptr->value;
+          {
+            flags |= option_ptr->value;
 	    goto found;
-	  }
+          }
       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
 	       length, ptr, dfi->swtch);
     found:;
@@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
      known dumps.  */
   if (dfi->suffix == NULL)
-    dump_enable_all (dfi->flags);
+    dump_enable_all (dfi->flags, dfi->user_filename);
 
   return 1;
 }
@@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
 bool
 enable_rtl_dump_file (void)
 {
-  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
+  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
 }
Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 187265)
+++ tree-pass.h	(working copy)
@@ -84,8 +84,9 @@ enum tree_dump_index
 #define TDF_ENUMERATE_LOCALS (1 << 22)	/* Enumerate locals by uid.  */
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
+#define TDF_USER_FILENAME    (1 << 25)	/* Dump on user provided filename,
+                                           instead of constructing one. */
 
-
 /* In tree-dump.c */
 
 extern char *get_dump_file_name (int);
@@ -222,6 +223,8 @@ struct dump_file_info
   const char *suffix;           /* suffix to give output file.  */
   const char *swtch;            /* command line switch */
   const char *glob;             /* command line glob  */
+  const char *user_filename;    /* user provided filename instead of making
+                                   up one using dump_base_name + suffix.  */
   int flags;                    /* user flags */
   int state;                    /* state of play */
   int num;                      /* dump file number */
Index: testsuite/g++.dg/other/dump-userfile-1.C
===================================================================
--- testsuite/g++.dg/other/dump-userfile-1.C	(revision 0)
+++ testsuite/g++.dg/other/dump-userfile-1.C	(revision 0)
@@ -0,0 +1,11 @@
+// Test that the dump to a user-defined file works correctly.
+/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
+
+void test (int *b, int *e, int stride)
+  {
+    for (int *p = b; p != e; p += stride)
+      *p = 1;
+  }
+
+/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
+/* { dg-final { remove-build-file "foobar.dump" } } */

--
This patch is available for review at http://codereview.appspot.com/6190057

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-09  6:46 [PATCH] Add option for dumping to stderr (issue6190057) Sharad Singhai
@ 2012-05-09  6:52 ` Andrew Pinski
  2012-05-09  6:55   ` Gabriel Dos Reis
  2012-05-09  7:22 ` Gabriel Dos Reis
  1 sibling, 1 reply; 71+ messages in thread
From: Andrew Pinski @ 2012-05-09  6:52 UTC (permalink / raw)
  To: Sharad Singhai; +Cc: reply, gcc-patches

On Tue, May 8, 2012 at 11:46 PM, Sharad Singhai <singhai@google.com> wrote:
> In response to comments, I have updated the patch to support dumps in
> user provided files via the option -fdump-xxx=<filename>. The
> filenames stdout/stderr are treated specially, and are considered
> standard streams.

I think - should also be treated as special (or maybe the only one
which should be treated as special).

Thanks,
Andrew Pinski

>
> Also updated documentation and a testcase. Okay for trunk?
>
> Thanks,
> Sharad
>
> 2012-05-08   Sharad Singhai  <singhai@google.com>
>
>        * doc/invoke.texi: Add documentation for new option.
>        * tree-dump.c (dump_stream_p): New function.
>        (dump_files): Update for new field.
>        (dump_switch_p_1): Handle user provided filenames.
>        (dump_begin): Likewise.
>        (get_dump_file_name): Likewise.
>        (dump_enable_all): Add new parameter USER_FILENAME.
>        All callers updated.
>        (dump_end): Remove attribute.
>        * tree-pass.h (enum tree_dump_index): Add new constant.
>        (struct dump_file_info): Add new field USER_FILENAME.
>        * testsuite/g++.dg/other/dump-userfile-1.C: New test.
>
> Index: doc/invoke.texi
> ===================================================================
> --- doc/invoke.texi     (revision 187265)
> +++ doc/invoke.texi     (working copy)
> @@ -5322,20 +5322,24 @@ Here are some examples showing uses of these optio
>
>  @item -d@var{letters}
>  @itemx -fdump-rtl-@var{pass}
> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>  @opindex d
>  Says to make debugging dumps during compilation at times specified by
>  @var{letters}.  This is used for debugging the RTL-based passes of the
>  compiler.  The file names for most of the dumps are made by appending
>  a pass number and a word to the @var{dumpname}, and the files are
> -created in the directory of the output file.  Note that the pass
> -number is computed statically as passes get registered into the pass
> -manager.  Thus the numbering is not related to the dynamic order of
> -execution of passes.  In particular, a pass installed by a plugin
> -could have a number over 200 even if it executed quite early.
> -@var{dumpname} is generated from the name of the output file, if
> -explicitly specified and it is not an executable, otherwise it is the
> -basename of the source file. These switches may have different effects
> -when @option{-E} is used for preprocessing.
> +created in the directory of the output file. If the
> +@option{=@var{filename}} is appended to the longer form of the dump
> +option then the dump is done on that file instead of numbered
> +files. The filenames stdout and stderr are treated specially. Note
> +that the pass number is computed statically as passes get registered
> +into the pass manager.  Thus the numbering is not related to the
> +dynamic order of execution of passes.  In particular, a pass installed
> +by a plugin could have a number over 200 even if it executed quite
> +early.  @var{dumpname} is generated from the name of the output file,
> +if explicitly specified and it is not an executable, otherwise it is
> +the basename of the source file. These switches may have different
> +effects when @option{-E} is used for preprocessing.
>
>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>  @option{-d} option @var{letters}.  Here are the possible
> @@ -5599,6 +5603,10 @@ These dumps are defined but always produce empty f
>  @opindex fdump-rtl-all
>  Produce all the dumps listed above.
>
> +@item -fdump-rtl-all=stderr
> +@opindex fdump-rtl-all=stderr
> +Produce all RTL dumps on stderr.
> +
>  @item -dA
>  @opindex dA
>  Annotate the assembler output with miscellaneous debugging information.
> @@ -5719,15 +5727,19 @@ counters for each function compiled.
>
>  @item -fdump-tree-@var{switch}
>  @itemx -fdump-tree-@var{switch}-@var{options}
> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>  @opindex fdump-tree
>  Control the dumping at various stages of processing the intermediate
>  language tree to a file.  The file name is generated by appending a
>  switch specific suffix to the source file name, and the file is
> -created in the same directory as the output file.  If the
> -@samp{-@var{options}} form is used, @var{options} is a list of
> -@samp{-} separated options which control the details of the dump.  Not
> -all options are applicable to all dumps; those that are not
> -meaningful are ignored.  The following options are available
> +created in the same directory as the output file. In case of
> +@option{=@var{filename}}, the dump output is on the given file. Note
> +that the filenames stdout and stderr are treated specially and dumps
> +are done on standard streams. If the @samp{-@var{options}} form is
> +used, @var{options} is a list of @samp{-} separated options which
> +control the details or location of the dump.  Not all options are
> +applicable to all dumps; those that are not meaningful are ignored.
> +The following options are available
>
>  @table @samp
>  @item address
> @@ -5765,9 +5777,56 @@ Enable showing the tree dump for each statement.
>  Enable showing the EH region number holding each statement.
>  @item scev
>  Enable showing scalar evolution analysis details.
> +@item slim
> +Inhibit dumping of members of a scope or body of a function merely
> +because that scope has been reached.  Only dump such items when they
> +are directly reachable by some other path.  When dumping pretty-printed
> +trees, this option inhibits dumping the bodies of control structures.
> +@item =@var{filename}
> +Instead of using an auto generated name for a dump file, use the
> +provided name. For example:
> +
> +@smallexample
> +gcc -O2 -fdump-tree-pre=foobar.dump
> +@end smallexample
> +
> +produces PRE dump in a file named foobar.dump. Similarly
> +
> +@smallexample
> +gcc -O2 -fdump-tree-all=all.dump
> +@end smallexample
> +
> +produces all tree dumps in a file named all.dump.
> +
> +Note that stdout and stderr are treated specially, and the dumps are
> +done on standard streams. In case of any conflicts, the user provided
> +filename takes precedence. For example:
> +
> +@smallexample
> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-pre ...
> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stderr ...
> +@end smallexample
> +
> +Both invocations produce the PRE dump on stderr. Similarly, for the
> +following
> +
> +@smallexample
> +gcc -O2 -fdump-tree-all=stderr -fdump-tree-pre ...
> +@end smallexample
> +
> +All the dumps are output on stderr. In the following example,
> +
> +@smallexample
> +gcc -fdump-tree-all -fdump-tree-pre=stderr ...
> +@end smallexample
> +
> +all the dumps are written into named files except the PRE dump, which
> +is output on stderr, because @option{-fdump-tree-pre=stderr} takes
> +precedence.
> +
>  @item all
> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
> -and @option{lineno}.
> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
> +@option{lineno}.
>  @end table
>
>  The following tree dumps are possible:
> @@ -5913,6 +5972,10 @@ is made by appending @file{.vrp} to the source fil
>  @item all
>  @opindex fdump-tree-all
>  Enable all the available tree dumps with the flags provided in this option.
> +
> +@item all=stderr
> +@opindex fdump-tree-all=stderr
> +Enable all the available tree dumps on the stderr.
>  @end table
>
>  @item -ftree-vectorizer-verbose=@var{n}
> Index: tree-dump.c
> ===================================================================
> --- tree-dump.c (revision 187265)
> +++ tree-dump.c (working copy)
> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>    tree_dump_index enumeration in tree-pass.h.  */
>  static struct dump_file_info dump_files[TDI_end] =
>  {
> -  {NULL, NULL, NULL, 0, 0, 0},
> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
> -  {".ads", "ada-spec", NULL, 0, 0, 7},
> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>  #define FIRST_AUTO_NUMBERED_DUMP 8
>
> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>  };
>
>  /* Dynamically registered tree dump files and switches.  */
> @@ -802,7 +802,7 @@ struct dump_option_value_info
>  };
>
>  /* Table of dump options. This must be consistent with the TDF_* flags
> -   in tree.h */
> +   in tree-pass.h */
>  static const struct dump_option_value_info dump_options[] =
>  {
>   {"address", TDF_ADDRESS},
> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>   if (dfi->state == 0)
>     return NULL;
>
> +  if (dfi->user_filename)
> +    return xstrdup (dfi->user_filename);
> +
>   if (dfi->num < 0)
>     dump_id[0] = '\0';
>   else
> @@ -911,6 +914,19 @@ get_dump_file_name (int phase)
>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>  }
>
> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
> +   stderr stream.  */
> +
> +static int
> +dump_stream_p (const char *user_filename)
> +{
> +  if (user_filename)
> +    return !strncmp ("stderr", user_filename, 6) ||
> +      !strncmp ("stdout", user_filename, 6);
> +  else
> +    return 0;
> +}
> +
>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>    *FLAG_PTR and returns a stream to write to. If the dump is not
>    enabled, returns NULL.
> @@ -926,14 +942,28 @@ dump_begin (int phase, int *flag_ptr)
>   if (phase == TDI_none || !dump_enabled_p (phase))
>     return NULL;
>
> -  name = get_dump_file_name (phase);
>   dfi = get_dump_file_info (phase);
> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
> -  if (!stream)
> -    error ("could not open dump file %qs: %m", name);
> +  if (dump_stream_p (dfi->user_filename))
> +    {
> +      if (!strncmp ("stderr", dfi->user_filename, 6))
> +        stream = stderr;
> +      else
> +        if (!strncmp ("stdout", dfi->user_filename, 6))
> +          stream = stdout;
> +        else
> +          error ("unknown stream: %qs: %m", dfi->user_filename);
> +      dfi->state = 1;
> +    }
>   else
> -    dfi->state = 1;
> -  free (name);
> +    {
> +      name = get_dump_file_name (phase);
> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
> +      if (!stream)
> +        error ("could not open dump file %qs: %m", name);
> +      else
> +        dfi->state = 1;
> +      free (name);
> +    }
>
>   if (flag_ptr)
>     *flag_ptr = dfi->flags;
> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>    dump_begin.  */
>
>  void
> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
> +dump_end (int phase, FILE *stream)
>  {
> -  fclose (stream);
> +  struct dump_file_info *dfi = get_dump_file_info (phase);
> +  if (!dump_stream_p (dfi->user_filename))
> +    fclose (stream);
>  }
>
>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>
>  static int
> -dump_enable_all (int flags)
> +dump_enable_all (int flags, const char *user_filename)
>  {
>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>   int n = 0;
>   size_t i;
>
>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
> -    if ((dump_files[i].flags & ir_dump_type))
> -      {
> -        dump_files[i].state = -1;
> -        dump_files[i].flags |= flags;
> -        n++;
> -      }
> +    {
> +      if ((dump_files[i].flags & ir_dump_type))
> +        {
> +          dump_files[i].state = -1;
> +          dump_files[i].flags |= flags;
> +          n++;
> +        }
> +      if (user_filename)
> +        dump_files[i].user_filename = user_filename;
> +    }
>
>   for (i = 0; i < extra_dump_files_in_use; i++)
> -    if ((extra_dump_files[i].flags & ir_dump_type))
> -      {
> -        extra_dump_files[i].state = -1;
> -        extra_dump_files[i].flags |= flags;
> -       n++;
> -      }
> +    {
> +      if ((extra_dump_files[i].flags & ir_dump_type))
> +        {
> +          extra_dump_files[i].state = -1;
> +          extra_dump_files[i].flags |= flags;
> +          n++;
> +        }
> +      if (user_filename)
> +        extra_dump_files[i].user_filename = user_filename;
> +    }
>
>   return n;
>  }
> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>   if (!option_value)
>     return 0;
>
> -  if (*option_value && *option_value != '-')
> +  if (*option_value && *option_value != '-' && *option_value != '=')
>     return 0;
>
>   ptr = option_value;
> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>       while (*ptr == '-')
>        ptr++;
>       end_ptr = strchr (ptr, '-');
> +
>       if (!end_ptr)
>        end_ptr = ptr + strlen (ptr);
>       length = end_ptr - ptr;
>
> +      if (*ptr == '=')
> +        {
> +          /* Interpret rest of the argument as a dump filename.  The
> +             user provided filename overrides generated dump names as
> +             well as other command line filenames.  */
> +          flags |= TDF_USER_FILENAME;
> +          if (dfi->user_filename)
> +            free (dfi->user_filename);
> +          dfi->user_filename = xstrdup (ptr + 1);
> +          break;
> +        }
> +
>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>        if (strlen (option_ptr->name) == length
>            && !memcmp (option_ptr->name, ptr, length))
> -         {
> -           flags |= option_ptr->value;
> +          {
> +            flags |= option_ptr->value;
>            goto found;
> -         }
> +          }
>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>               length, ptr, dfi->swtch);
>     found:;
> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>      known dumps.  */
>   if (dfi->suffix == NULL)
> -    dump_enable_all (dfi->flags);
> +    dump_enable_all (dfi->flags, dfi->user_filename);
>
>   return 1;
>  }
> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>  bool
>  enable_rtl_dump_file (void)
>  {
> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>  }
> Index: tree-pass.h
> ===================================================================
> --- tree-pass.h (revision 187265)
> +++ tree-pass.h (working copy)
> @@ -84,8 +84,9 @@ enum tree_dump_index
>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
> +                                           instead of constructing one. */
>
> -
>  /* In tree-dump.c */
>
>  extern char *get_dump_file_name (int);
> @@ -222,6 +223,8 @@ struct dump_file_info
>   const char *suffix;           /* suffix to give output file.  */
>   const char *swtch;            /* command line switch */
>   const char *glob;             /* command line glob  */
> +  const char *user_filename;    /* user provided filename instead of making
> +                                   up one using dump_base_name + suffix.  */
>   int flags;                    /* user flags */
>   int state;                    /* state of play */
>   int num;                      /* dump file number */
> Index: testsuite/g++.dg/other/dump-userfile-1.C
> ===================================================================
> --- testsuite/g++.dg/other/dump-userfile-1.C    (revision 0)
> +++ testsuite/g++.dg/other/dump-userfile-1.C    (revision 0)
> @@ -0,0 +1,11 @@
> +// Test that the dump to a user-defined file works correctly.
> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
> +
> +void test (int *b, int *e, int stride)
> +  {
> +    for (int *p = b; p != e; p += stride)
> +      *p = 1;
> +  }
> +
> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
> +/* { dg-final { remove-build-file "foobar.dump" } } */
>
> --
> This patch is available for review at http://codereview.appspot.com/6190057

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-09  6:52 ` Andrew Pinski
@ 2012-05-09  6:55   ` Gabriel Dos Reis
  0 siblings, 0 replies; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-05-09  6:55 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Sharad Singhai, gcc-patches

On Wed, May 9, 2012 at 1:51 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Tue, May 8, 2012 at 11:46 PM, Sharad Singhai <singhai@google.com> wrote:
>> In response to comments, I have updated the patch to support dumps in
>> user provided files via the option -fdump-xxx=<filename>. The
>> filenames stdout/stderr are treated specially, and are considered
>> standard streams.
>
> I think - should also be treated as special (or maybe the only one
> which should be treated as special).

He originally wanted only "stderr", so treating "-" only specially
would not be in
the line with his original goal.  "-" is equivalent to "stdout", so it
is not like
we don't have the functionally with his revised patch.

>
> Thanks,
> Andrew Pinski
>
>>
>> Also updated documentation and a testcase. Okay for trunk?
>>
>> Thanks,
>> Sharad
>>
>> 2012-05-08   Sharad Singhai  <singhai@google.com>
>>
>>        * doc/invoke.texi: Add documentation for new option.
>>        * tree-dump.c (dump_stream_p): New function.
>>        (dump_files): Update for new field.
>>        (dump_switch_p_1): Handle user provided filenames.
>>        (dump_begin): Likewise.
>>        (get_dump_file_name): Likewise.
>>        (dump_enable_all): Add new parameter USER_FILENAME.
>>        All callers updated.
>>        (dump_end): Remove attribute.
>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>        (struct dump_file_info): Add new field USER_FILENAME.
>>        * testsuite/g++.dg/other/dump-userfile-1.C: New test.
>>
>> Index: doc/invoke.texi
>> ===================================================================
>> --- doc/invoke.texi     (revision 187265)
>> +++ doc/invoke.texi     (working copy)
>> @@ -5322,20 +5322,24 @@ Here are some examples showing uses of these optio
>>
>>  @item -d@var{letters}
>>  @itemx -fdump-rtl-@var{pass}
>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>  @opindex d
>>  Says to make debugging dumps during compilation at times specified by
>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>  compiler.  The file names for most of the dumps are made by appending
>>  a pass number and a word to the @var{dumpname}, and the files are
>> -created in the directory of the output file.  Note that the pass
>> -number is computed statically as passes get registered into the pass
>> -manager.  Thus the numbering is not related to the dynamic order of
>> -execution of passes.  In particular, a pass installed by a plugin
>> -could have a number over 200 even if it executed quite early.
>> -@var{dumpname} is generated from the name of the output file, if
>> -explicitly specified and it is not an executable, otherwise it is the
>> -basename of the source file. These switches may have different effects
>> -when @option{-E} is used for preprocessing.
>> +created in the directory of the output file. If the
>> +@option{=@var{filename}} is appended to the longer form of the dump
>> +option then the dump is done on that file instead of numbered
>> +files. The filenames stdout and stderr are treated specially. Note
>> +that the pass number is computed statically as passes get registered
>> +into the pass manager.  Thus the numbering is not related to the
>> +dynamic order of execution of passes.  In particular, a pass installed
>> +by a plugin could have a number over 200 even if it executed quite
>> +early.  @var{dumpname} is generated from the name of the output file,
>> +if explicitly specified and it is not an executable, otherwise it is
>> +the basename of the source file. These switches may have different
>> +effects when @option{-E} is used for preprocessing.
>>
>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>  @option{-d} option @var{letters}.  Here are the possible
>> @@ -5599,6 +5603,10 @@ These dumps are defined but always produce empty f
>>  @opindex fdump-rtl-all
>>  Produce all the dumps listed above.
>>
>> +@item -fdump-rtl-all=stderr
>> +@opindex fdump-rtl-all=stderr
>> +Produce all RTL dumps on stderr.
>> +
>>  @item -dA
>>  @opindex dA
>>  Annotate the assembler output with miscellaneous debugging information.
>> @@ -5719,15 +5727,19 @@ counters for each function compiled.
>>
>>  @item -fdump-tree-@var{switch}
>>  @itemx -fdump-tree-@var{switch}-@var{options}
>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>  @opindex fdump-tree
>>  Control the dumping at various stages of processing the intermediate
>>  language tree to a file.  The file name is generated by appending a
>>  switch specific suffix to the source file name, and the file is
>> -created in the same directory as the output file.  If the
>> -@samp{-@var{options}} form is used, @var{options} is a list of
>> -@samp{-} separated options which control the details of the dump.  Not
>> -all options are applicable to all dumps; those that are not
>> -meaningful are ignored.  The following options are available
>> +created in the same directory as the output file. In case of
>> +@option{=@var{filename}}, the dump output is on the given file. Note
>> +that the filenames stdout and stderr are treated specially and dumps
>> +are done on standard streams. If the @samp{-@var{options}} form is
>> +used, @var{options} is a list of @samp{-} separated options which
>> +control the details or location of the dump.  Not all options are
>> +applicable to all dumps; those that are not meaningful are ignored.
>> +The following options are available
>>
>>  @table @samp
>>  @item address
>> @@ -5765,9 +5777,56 @@ Enable showing the tree dump for each statement.
>>  Enable showing the EH region number holding each statement.
>>  @item scev
>>  Enable showing scalar evolution analysis details.
>> +@item slim
>> +Inhibit dumping of members of a scope or body of a function merely
>> +because that scope has been reached.  Only dump such items when they
>> +are directly reachable by some other path.  When dumping pretty-printed
>> +trees, this option inhibits dumping the bodies of control structures.
>> +@item =@var{filename}
>> +Instead of using an auto generated name for a dump file, use the
>> +provided name. For example:
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=foobar.dump
>> +@end smallexample
>> +
>> +produces PRE dump in a file named foobar.dump. Similarly
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-all=all.dump
>> +@end smallexample
>> +
>> +produces all tree dumps in a file named all.dump.
>> +
>> +Note that stdout and stderr are treated specially, and the dumps are
>> +done on standard streams. In case of any conflicts, the user provided
>> +filename takes precedence. For example:
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-pre ...
>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stderr ...
>> +@end smallexample
>> +
>> +Both invocations produce the PRE dump on stderr. Similarly, for the
>> +following
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-all=stderr -fdump-tree-pre ...
>> +@end smallexample
>> +
>> +All the dumps are output on stderr. In the following example,
>> +
>> +@smallexample
>> +gcc -fdump-tree-all -fdump-tree-pre=stderr ...
>> +@end smallexample
>> +
>> +all the dumps are written into named files except the PRE dump, which
>> +is output on stderr, because @option{-fdump-tree-pre=stderr} takes
>> +precedence.
>> +
>>  @item all
>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>> -and @option{lineno}.
>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>> +@option{lineno}.
>>  @end table
>>
>>  The following tree dumps are possible:
>> @@ -5913,6 +5972,10 @@ is made by appending @file{.vrp} to the source fil
>>  @item all
>>  @opindex fdump-tree-all
>>  Enable all the available tree dumps with the flags provided in this option.
>> +
>> +@item all=stderr
>> +@opindex fdump-tree-all=stderr
>> +Enable all the available tree dumps on the stderr.
>>  @end table
>>
>>  @item -ftree-vectorizer-verbose=@var{n}
>> Index: tree-dump.c
>> ===================================================================
>> --- tree-dump.c (revision 187265)
>> +++ tree-dump.c (working copy)
>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>    tree_dump_index enumeration in tree-pass.h.  */
>>  static struct dump_file_info dump_files[TDI_end] =
>>  {
>> -  {NULL, NULL, NULL, 0, 0, 0},
>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>
>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>  };
>>
>>  /* Dynamically registered tree dump files and switches.  */
>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>  };
>>
>>  /* Table of dump options. This must be consistent with the TDF_* flags
>> -   in tree.h */
>> +   in tree-pass.h */
>>  static const struct dump_option_value_info dump_options[] =
>>  {
>>   {"address", TDF_ADDRESS},
>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>   if (dfi->state == 0)
>>     return NULL;
>>
>> +  if (dfi->user_filename)
>> +    return xstrdup (dfi->user_filename);
>> +
>>   if (dfi->num < 0)
>>     dump_id[0] = '\0';
>>   else
>> @@ -911,6 +914,19 @@ get_dump_file_name (int phase)
>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>  }
>>
>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>> +   stderr stream.  */
>> +
>> +static int
>> +dump_stream_p (const char *user_filename)
>> +{
>> +  if (user_filename)
>> +    return !strncmp ("stderr", user_filename, 6) ||
>> +      !strncmp ("stdout", user_filename, 6);
>> +  else
>> +    return 0;
>> +}
>> +
>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>    enabled, returns NULL.
>> @@ -926,14 +942,28 @@ dump_begin (int phase, int *flag_ptr)
>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>     return NULL;
>>
>> -  name = get_dump_file_name (phase);
>>   dfi = get_dump_file_info (phase);
>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> -  if (!stream)
>> -    error ("could not open dump file %qs: %m", name);
>> +  if (dump_stream_p (dfi->user_filename))
>> +    {
>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>> +        stream = stderr;
>> +      else
>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>> +          stream = stdout;
>> +        else
>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>> +      dfi->state = 1;
>> +    }
>>   else
>> -    dfi->state = 1;
>> -  free (name);
>> +    {
>> +      name = get_dump_file_name (phase);
>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> +      if (!stream)
>> +        error ("could not open dump file %qs: %m", name);
>> +      else
>> +        dfi->state = 1;
>> +      free (name);
>> +    }
>>
>>   if (flag_ptr)
>>     *flag_ptr = dfi->flags;
>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>    dump_begin.  */
>>
>>  void
>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>> +dump_end (int phase, FILE *stream)
>>  {
>> -  fclose (stream);
>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>> +  if (!dump_stream_p (dfi->user_filename))
>> +    fclose (stream);
>>  }
>>
>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>
>>  static int
>> -dump_enable_all (int flags)
>> +dump_enable_all (int flags, const char *user_filename)
>>  {
>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>   int n = 0;
>>   size_t i;
>>
>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -    if ((dump_files[i].flags & ir_dump_type))
>> -      {
>> -        dump_files[i].state = -1;
>> -        dump_files[i].flags |= flags;
>> -        n++;
>> -      }
>> +    {
>> +      if ((dump_files[i].flags & ir_dump_type))
>> +        {
>> +          dump_files[i].state = -1;
>> +          dump_files[i].flags |= flags;
>> +          n++;
>> +        }
>> +      if (user_filename)
>> +        dump_files[i].user_filename = user_filename;
>> +    }
>>
>>   for (i = 0; i < extra_dump_files_in_use; i++)
>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>> -      {
>> -        extra_dump_files[i].state = -1;
>> -        extra_dump_files[i].flags |= flags;
>> -       n++;
>> -      }
>> +    {
>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>> +        {
>> +          extra_dump_files[i].state = -1;
>> +          extra_dump_files[i].flags |= flags;
>> +          n++;
>> +        }
>> +      if (user_filename)
>> +        extra_dump_files[i].user_filename = user_filename;
>> +    }
>>
>>   return n;
>>  }
>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   if (!option_value)
>>     return 0;
>>
>> -  if (*option_value && *option_value != '-')
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>     return 0;
>>
>>   ptr = option_value;
>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>       while (*ptr == '-')
>>        ptr++;
>>       end_ptr = strchr (ptr, '-');
>> +
>>       if (!end_ptr)
>>        end_ptr = ptr + strlen (ptr);
>>       length = end_ptr - ptr;
>>
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  The
>> +             user provided filename overrides generated dump names as
>> +             well as other command line filenames.  */
>> +          flags |= TDF_USER_FILENAME;
>> +          if (dfi->user_filename)
>> +            free (dfi->user_filename);
>> +          dfi->user_filename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +
>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>        if (strlen (option_ptr->name) == length
>>            && !memcmp (option_ptr->name, ptr, length))
>> -         {
>> -           flags |= option_ptr->value;
>> +          {
>> +            flags |= option_ptr->value;
>>            goto found;
>> -         }
>> +          }
>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>               length, ptr, dfi->swtch);
>>     found:;
>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>      known dumps.  */
>>   if (dfi->suffix == NULL)
>> -    dump_enable_all (dfi->flags);
>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>
>>   return 1;
>>  }
>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>  bool
>>  enable_rtl_dump_file (void)
>>  {
>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>  }
>> Index: tree-pass.h
>> ===================================================================
>> --- tree-pass.h (revision 187265)
>> +++ tree-pass.h (working copy)
>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>> +                                           instead of constructing one. */
>>
>> -
>>  /* In tree-dump.c */
>>
>>  extern char *get_dump_file_name (int);
>> @@ -222,6 +223,8 @@ struct dump_file_info
>>   const char *suffix;           /* suffix to give output file.  */
>>   const char *swtch;            /* command line switch */
>>   const char *glob;             /* command line glob  */
>> +  const char *user_filename;    /* user provided filename instead of making
>> +                                   up one using dump_base_name + suffix.  */
>>   int flags;                    /* user flags */
>>   int state;                    /* state of play */
>>   int num;                      /* dump file number */
>> Index: testsuite/g++.dg/other/dump-userfile-1.C
>> ===================================================================
>> --- testsuite/g++.dg/other/dump-userfile-1.C    (revision 0)
>> +++ testsuite/g++.dg/other/dump-userfile-1.C    (revision 0)
>> @@ -0,0 +1,11 @@
>> +// Test that the dump to a user-defined file works correctly.
>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>> +
>> +void test (int *b, int *e, int stride)
>> +  {
>> +    for (int *p = b; p != e; p += stride)
>> +      *p = 1;
>> +  }
>> +
>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>
>> --
>> This patch is available for review at http://codereview.appspot.com/6190057

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-09  6:46 [PATCH] Add option for dumping to stderr (issue6190057) Sharad Singhai
  2012-05-09  6:52 ` Andrew Pinski
@ 2012-05-09  7:22 ` Gabriel Dos Reis
  2012-05-09 23:58   ` Sharad Singhai
  1 sibling, 1 reply; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-05-09  7:22 UTC (permalink / raw)
  To: Sharad Singhai; +Cc: gcc-patches

On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
[...]

> +@item -fdump-rtl-all=stderr
> +@opindex fdump-rtl-all=stderr

You do not need to have a separate index entry for '=stderr' or '=stdout'.
Rather, expand the description to state this in all the documentation
for -fdump-xxx=yyy.

[...]

> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
> +   stderr stream.  */
> +
> +static int
> +dump_stream_p (const char *user_filename)
> +{
> +  if (user_filename)
> +    return !strncmp ("stderr", user_filename, 6) ||
> +      !strncmp ("stdout", user_filename, 6);
> +  else
> +    return 0;
> +}

The name is ambiguous.
This function is testing whether its string argument designates one of
the *standard* output streams.  Name it to reflect that..
Have it take the dump state context. Also the coding convention: the binary
operator "||" should be on next line.  In fact the thing could be
simpler.   Instead of
testing over and over again against "stderr" (once in this function, then again
later), just return the corresponding standard FILE* pointer.
Also, this is a case of overuse of strncmp.  If you name the function
dump_get_standard_stream:

    return strcmp("stderr", dfi->user_filename) == 0
       ? stderr
        : stdcmp("stdout", dfi->use_filename)
        ?  stdout
        : NULL;

you can simplify:

> -  name = get_dump_file_name (phase);
>   dfi = get_dump_file_info (phase);
> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
> -  if (!stream)
> -    error ("could not open dump file %qs: %m", name);
> +  if (dump_stream_p (dfi->user_filename))
> +    {
> +      if (!strncmp ("stderr", dfi->user_filename, 6))
> +        stream = stderr;
> +      else
> +        if (!strncmp ("stdout", dfi->user_filename, 6))
> +          stream = stdout;
> +        else
> +          error ("unknown stream: %qs: %m", dfi->user_filename);
> +      dfi->state = 1;
> +    }
>   else
> -    dfi->state = 1;
> -  free (name);
> +    {
> +      name = get_dump_file_name (phase);
> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
> +      if (!stream)
> +        error ("could not open dump file %qs: %m", name);
> +      else
> +        dfi->state = 1;
> +      free (name);
> +    }
>
>   if (flag_ptr)
>     *flag_ptr = dfi->flags;
> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>    dump_begin.  */
>
>  void
> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
> +dump_end (int phase, FILE *stream)
>  {
> -  fclose (stream);
> +  struct dump_file_info *dfi = get_dump_file_info (phase);
> +  if (!dump_stream_p (dfi->user_filename))
> +    fclose (stream);
>  }
>
>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>
>  static int
> -dump_enable_all (int flags)
> +dump_enable_all (int flags, const char *user_filename)
>  {
>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>   int n = 0;
>   size_t i;
>
>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
> -    if ((dump_files[i].flags & ir_dump_type))
> -      {
> -        dump_files[i].state = -1;
> -        dump_files[i].flags |= flags;
> -        n++;
> -      }
> +    {
> +      if ((dump_files[i].flags & ir_dump_type))
> +        {
> +          dump_files[i].state = -1;
> +          dump_files[i].flags |= flags;
> +          n++;
> +        }
> +      if (user_filename)
> +        dump_files[i].user_filename = user_filename;
> +    }
>
>   for (i = 0; i < extra_dump_files_in_use; i++)
> -    if ((extra_dump_files[i].flags & ir_dump_type))
> -      {
> -        extra_dump_files[i].state = -1;
> -        extra_dump_files[i].flags |= flags;
> -       n++;
> -      }
> +    {
> +      if ((extra_dump_files[i].flags & ir_dump_type))
> +        {
> +          extra_dump_files[i].state = -1;
> +          extra_dump_files[i].flags |= flags;
> +          n++;
> +        }
> +      if (user_filename)
> +        extra_dump_files[i].user_filename = user_filename;
> +    }
>
>   return n;
>  }
> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>   if (!option_value)
>     return 0;
>
> -  if (*option_value && *option_value != '-')
> +  if (*option_value && *option_value != '-' && *option_value != '=')
>     return 0;
>
>   ptr = option_value;
> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>       while (*ptr == '-')
>        ptr++;
>       end_ptr = strchr (ptr, '-');
> +
>       if (!end_ptr)
>        end_ptr = ptr + strlen (ptr);
>       length = end_ptr - ptr;
>
> +      if (*ptr == '=')
> +        {
> +          /* Interpret rest of the argument as a dump filename.  The
> +             user provided filename overrides generated dump names as
> +             well as other command line filenames.  */
> +          flags |= TDF_USER_FILENAME;
> +          if (dfi->user_filename)
> +            free (dfi->user_filename);
> +          dfi->user_filename = xstrdup (ptr + 1);
> +          break;
> +        }
> +
>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>        if (strlen (option_ptr->name) == length
>            && !memcmp (option_ptr->name, ptr, length))
> -         {
> -           flags |= option_ptr->value;
> +          {
> +            flags |= option_ptr->value;
>            goto found;
> -         }
> +          }
>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>               length, ptr, dfi->swtch);
>     found:;
> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>      known dumps.  */
>   if (dfi->suffix == NULL)
> -    dump_enable_all (dfi->flags);
> +    dump_enable_all (dfi->flags, dfi->user_filename);
>
>   return 1;
>  }
> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>  bool
>  enable_rtl_dump_file (void)
>  {
> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>  }
> Index: tree-pass.h
> ===================================================================
> --- tree-pass.h (revision 187265)
> +++ tree-pass.h (working copy)
> @@ -84,8 +84,9 @@ enum tree_dump_index
>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
> +                                           instead of constructing one. */
>
> -
>  /* In tree-dump.c */
>
>  extern char *get_dump_file_name (int);
> @@ -222,6 +223,8 @@ struct dump_file_info
>   const char *suffix;           /* suffix to give output file.  */
>   const char *swtch;            /* command line switch */
>   const char *glob;             /* command line glob  */
> +  const char *user_filename;    /* user provided filename instead of making
> +                                   up one using dump_base_name + suffix.  */

There is "no user" here: we are the users :-)  Just call it "filename".

-- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-09  7:22 ` Gabriel Dos Reis
@ 2012-05-09 23:58   ` Sharad Singhai
  2012-05-10  0:31     ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-05-09 23:58 UTC (permalink / raw)
  To: Gabriel Dos Reis
  Cc: gcc-patches, David Li, Richard Guenther, reply, Andrew Pinski

Thanks for your suggestions/comments. I have updated the patch and
documentation. It supports the following usage:

gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
-fdump-rtl-ira=ira.dump

Here all tree dumps except the PRE are output into tree.dump, PRE dump
goes to stdout and the IRA dump goes to ira.dump.

Thanks,
Sharad

2012-05-09   Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for the new option.
	* tree-dump.c (dump_get_standard_stream): New function.
	(dump_files): Update for new field.
	(dump_switch_p_1): Handle dump filenames.
	(dump_begin): Likewise.
	(get_dump_file_name): Likewise.
	(dump_end): Remove attribute.
	(dump_enable_all): Add new parameter FILENAME.
	All callers updated.
	(enable_rtl_dump_file):
	* tree-pass.h (enum tree_dump_index): Add new constant.
	(struct dump_file_info): Add new field FILENAME.
	* testsuite/g++.dg/other/dump-filename-1.C: New test.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 187265)
+++ doc/invoke.texi	(working copy)
@@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio

 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass}=@var{filename}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
 compiler.  The file names for most of the dumps are made by appending
 a pass number and a word to the @var{dumpname}, and the files are
-created in the directory of the output file.  Note that the pass
-number is computed statically as passes get registered into the pass
-manager.  Thus the numbering is not related to the dynamic order of
-execution of passes.  In particular, a pass installed by a plugin
-could have a number over 200 even if it executed quite early.
-@var{dumpname} is generated from the name of the output file, if
-explicitly specified and it is not an executable, otherwise it is the
-basename of the source file. These switches may have different effects
-when @option{-E} is used for preprocessing.
+created in the directory of the output file. If the
+@option{=@var{filename}} is appended to the longer form of the dump
+option then the dump is done on that file instead of numbered
+files. Note that the pass number is computed statically as passes get
+registered into the pass manager.  Thus the numbering is not related
+to the dynamic order of execution of passes.  In particular, a pass
+installed by a plugin could have a number over 200 even if it executed
+quite early.  @var{dumpname} is generated from the name of the output
+file, if explicitly specified and it is not an executable, otherwise
+it is the basename of the source file. These switches may have
+different effects when @option{-E} is used for preprocessing.

 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
 @option{-d} option @var{letters}.  Here are the possible
@@ -5719,15 +5722,18 @@ counters for each function compiled.

 @item -fdump-tree-@var{switch}
 @itemx -fdump-tree-@var{switch}-@var{options}
+@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
-@samp{-@var{options}} form is used, @var{options} is a list of
-@samp{-} separated options which control the details of the dump.  Not
-all options are applicable to all dumps; those that are not
-meaningful are ignored.  The following options are available
+created in the same directory as the output file. In case of
+@option{=@var{filename}} option, the dump is output on the given file
+name instead.  If the @samp{-@var{options}} form is used,
+@var{options} is a list of @samp{-} separated options which control
+the details or location of the dump.  Not all options are applicable
+to all dumps; those that are not meaningful are ignored.  The
+following options are available

 @table @samp
 @item address
@@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item slim
+Inhibit dumping of members of a scope or body of a function merely
+because that scope has been reached.  Only dump such items when they
+are directly reachable by some other path.  When dumping pretty-printed
+trees, this option inhibits dumping the bodies of control structures.
+@item =@var{filename}
+Instead of using an auto generated dump file name, use the given file
+name. The file names @file{stdout} and @file{stderr} are treated
+specially and are considered already open standard streams. For
+example:
+
+@smallexample
+gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
+@end smallexample
+
+outputs PRE dump on @file{stderr}, while the IRA dump is output in a
+file named @file{ira.txt}.
+
+In case of any conflicts, the command line file name takes precedence
+over generated file names. For example:
+
+@smallexample
+gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
+gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
+@end smallexample
+
+Both of the above output the PRE dump on @file{stdout}. However, if
+there are multiple command line file names are applicable then the
+last one is used. Thus the command
+
+@smallexample
+gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
+@end smallexample
+
+outputs all the dumps in @file{all.txt} because the stderr option for
+PRE dump is overridden by a later option.
+
 @item all
-Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
-and @option{lineno}.
+Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
+@option{lineno}.
 @end table

 The following tree dumps are possible:
@@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
 @item all
 @opindex fdump-tree-all
 Enable all the available tree dumps with the flags provided in this option.
+
 @end table

 @item -ftree-vectorizer-verbose=@var{n}
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 187265)
+++ tree-dump.c	(working copy)
@@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
    tree_dump_index enumeration in tree-pass.h.  */
 static struct dump_file_info dump_files[TDI_end] =
 {
-  {NULL, NULL, NULL, 0, 0, 0},
-  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
-  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
-  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
-  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
-  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
-  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
-  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
-  {".ads", "ada-spec", NULL, 0, 0, 7},
+  {NULL, NULL, NULL, NULL, 0, 0, 0},
+  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
+  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
+  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
+  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
+  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
+  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
+  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
+  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
 #define FIRST_AUTO_NUMBERED_DUMP 8

-  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
-  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
-  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
+  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
+  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
+  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
 };

 /* Dynamically registered tree dump files and switches.  */
@@ -802,7 +802,7 @@ struct dump_option_value_info
 };

 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in tree-pass.h */
 static const struct dump_option_value_info dump_options[] =
 {
   {"address", TDF_ADDRESS},
@@ -892,6 +892,9 @@ get_dump_file_name (int phase)
   if (dfi->state == 0)
     return NULL;

+  if (dfi->filename)
+    return xstrdup (dfi->filename);
+
   if (dfi->num < 0)
     dump_id[0] = '\0';
   else
@@ -911,6 +914,22 @@ get_dump_file_name (int phase)
   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }

+/* If the DFI dump output corresponds to stdout or stderr stream,
+   return that stream, NULL otherwise.  */
+
+static FILE *
+dump_get_standard_stream (struct dump_file_info *dfi)
+{
+  if (!dfi->filename)
+    return NULL;
+
+  return strcmp("stderr", dfi->filename) == 0
+    ? stderr
+    : strcmp("stdout", dfi->filename) == 0
+    ?  stdout
+    : NULL;
+}
+
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
@@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
   if (phase == TDI_none || !dump_enabled_p (phase))
     return NULL;

-  name = get_dump_file_name (phase);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
-  if (!stream)
-    error ("could not open dump file %qs: %m", name);
+  stream = dump_get_standard_stream (dfi);
+  if (stream)
+    dfi->state = 1;
   else
-    dfi->state = 1;
-  free (name);
+    {
+      name = get_dump_file_name (phase);
+      stream = fopen (name, dfi->state < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        dfi->state = 1;
+      free (name);
+    }

   if (flag_ptr)
     *flag_ptr = dfi->flags;
@@ -987,35 +1012,46 @@ dump_flag_name (int phase)
    dump_begin.  */

 void
-dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
+dump_end (int phase, FILE *stream)
 {
-  fclose (stream);
+  struct dump_file_info *dfi = get_dump_file_info (phase);
+  if (!dump_get_standard_stream (dfi))
+    fclose (stream);
 }

-/* Enable all tree dumps.  Return number of enabled tree dumps.  */
+/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
+   enabled tree dumps.  */

 static int
-dump_enable_all (int flags)
+dump_enable_all (int flags, const char *filename)
 {
   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;

   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_dump_type))
-      {
-        dump_files[i].state = -1;
-        dump_files[i].flags |= flags;
-        n++;
-      }
+    {
+      if ((dump_files[i].flags & ir_dump_type))
+        {
+          dump_files[i].state = -1;
+          dump_files[i].flags |= flags;
+          n++;
+          if (filename)
+            dump_files[i].filename = xstrdup (filename);
+        }
+    }

   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_dump_type))
-      {
-        extra_dump_files[i].state = -1;
-        extra_dump_files[i].flags |= flags;
-	n++;
-      }
+    {
+      if ((extra_dump_files[i].flags & ir_dump_type))
+        {
+          extra_dump_files[i].state = -1;
+          extra_dump_files[i].flags |= flags;
+          n++;
+          if (filename)
+            extra_dump_files[i].filename = xstrdup (filename);
+        }
+    }

   return n;
 }
@@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   if (!option_value)
     return 0;

-  if (*option_value && *option_value != '-')
+  if (*option_value && *option_value != '-' && *option_value != '=')
     return 0;

   ptr = option_value;
@@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
       while (*ptr == '-')
 	ptr++;
       end_ptr = strchr (ptr, '-');
+
       if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;

+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  This
+             filename overrides generated dump names as well as other
+             command line filenames.  */
+          flags |= TDF_FILENAME;
+          if (dfi->filename)
+            free (dfi->filename);
+          dfi->filename = xstrdup (ptr + 1);
+          break;
+        }
+
       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
-	  {
-	    flags |= option_ptr->value;
+          {
+            flags |= option_ptr->value;
 	    goto found;
-	  }
+          }
       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
 	       length, ptr, dfi->swtch);
     found:;
@@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
      known dumps.  */
   if (dfi->suffix == NULL)
-    dump_enable_all (dfi->flags);
+    dump_enable_all (dfi->flags, dfi->filename);

   return 1;
 }
@@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
 bool
 enable_rtl_dump_file (void)
 {
-  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
+  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
 }
Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 187265)
+++ tree-pass.h	(working copy)
@@ -84,8 +84,9 @@ enum tree_dump_index
 #define TDF_ENUMERATE_LOCALS (1 << 22)	/* Enumerate locals by uid.  */
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
+#define TDF_FILENAME    (1 << 25)	/* Dump on provided filename
+                                           instead of constructing one. */

-
 /* In tree-dump.c */

 extern char *get_dump_file_name (int);
@@ -222,6 +223,8 @@ struct dump_file_info
   const char *suffix;           /* suffix to give output file.  */
   const char *swtch;            /* command line switch */
   const char *glob;             /* command line glob  */
+  const char *filename;         /* use this filename instead of making
+                                   up one using dump_base_name + suffix.  */
   int flags;                    /* user flags */
   int state;                    /* state of play */
   int num;                      /* dump file number */
Index: testsuite/g++.dg/other/dump-filename-1.C
===================================================================
--- testsuite/g++.dg/other/dump-filename-1.C	(revision 0)
+++ testsuite/g++.dg/other/dump-filename-1.C	(revision 0)
@@ -0,0 +1,11 @@
+// Test that the dump to a user-defined file works correctly.
+/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
+
+void test (int *b, int *e, int stride)
+  {
+    for (int *p = b; p != e; p += stride)
+      *p = 1;
+  }
+
+/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
+/* { dg-final { remove-build-file "foobar.dump" } } */


On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
> [...]
>
>> +@item -fdump-rtl-all=stderr
>> +@opindex fdump-rtl-all=stderr
>
> You do not need to have a separate index entry for '=stderr' or '=stdout'.
> Rather, expand the description to state this in all the documentation
> for -fdump-xxx=yyy.
>
> [...]
>
>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>> +   stderr stream.  */
>> +
>> +static int
>> +dump_stream_p (const char *user_filename)
>> +{
>> +  if (user_filename)
>> +    return !strncmp ("stderr", user_filename, 6) ||
>> +      !strncmp ("stdout", user_filename, 6);
>> +  else
>> +    return 0;
>> +}
>
> The name is ambiguous.
> This function is testing whether its string argument designates one of
> the *standard* output streams.  Name it to reflect that..
> Have it take the dump state context. Also the coding convention: the binary
> operator "||" should be on next line.  In fact the thing could be
> simpler.   Instead of
> testing over and over again against "stderr" (once in this function, then again
> later), just return the corresponding standard FILE* pointer.
> Also, this is a case of overuse of strncmp.  If you name the function
> dump_get_standard_stream:
>
>    return strcmp("stderr", dfi->user_filename) == 0
>       ? stderr
>        : stdcmp("stdout", dfi->use_filename)
>        ?  stdout
>        : NULL;
>
> you can simplify:
>
>> -  name = get_dump_file_name (phase);
>>   dfi = get_dump_file_info (phase);
>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> -  if (!stream)
>> -    error ("could not open dump file %qs: %m", name);
>> +  if (dump_stream_p (dfi->user_filename))
>> +    {
>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>> +        stream = stderr;
>> +      else
>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>> +          stream = stdout;
>> +        else
>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>> +      dfi->state = 1;
>> +    }
>>   else
>> -    dfi->state = 1;
>> -  free (name);
>> +    {
>> +      name = get_dump_file_name (phase);
>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> +      if (!stream)
>> +        error ("could not open dump file %qs: %m", name);
>> +      else
>> +        dfi->state = 1;
>> +      free (name);
>> +    }
>>
>>   if (flag_ptr)
>>     *flag_ptr = dfi->flags;
>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>    dump_begin.  */
>>
>>  void
>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>> +dump_end (int phase, FILE *stream)
>>  {
>> -  fclose (stream);
>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>> +  if (!dump_stream_p (dfi->user_filename))
>> +    fclose (stream);
>>  }
>>
>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>
>>  static int
>> -dump_enable_all (int flags)
>> +dump_enable_all (int flags, const char *user_filename)
>>  {
>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>   int n = 0;
>>   size_t i;
>>
>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -    if ((dump_files[i].flags & ir_dump_type))
>> -      {
>> -        dump_files[i].state = -1;
>> -        dump_files[i].flags |= flags;
>> -        n++;
>> -      }
>> +    {
>> +      if ((dump_files[i].flags & ir_dump_type))
>> +        {
>> +          dump_files[i].state = -1;
>> +          dump_files[i].flags |= flags;
>> +          n++;
>> +        }
>> +      if (user_filename)
>> +        dump_files[i].user_filename = user_filename;
>> +    }
>>
>>   for (i = 0; i < extra_dump_files_in_use; i++)
>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>> -      {
>> -        extra_dump_files[i].state = -1;
>> -        extra_dump_files[i].flags |= flags;
>> -       n++;
>> -      }
>> +    {
>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>> +        {
>> +          extra_dump_files[i].state = -1;
>> +          extra_dump_files[i].flags |= flags;
>> +          n++;
>> +        }
>> +      if (user_filename)
>> +        extra_dump_files[i].user_filename = user_filename;
>> +    }
>>
>>   return n;
>>  }
>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   if (!option_value)
>>     return 0;
>>
>> -  if (*option_value && *option_value != '-')
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>     return 0;
>>
>>   ptr = option_value;
>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>       while (*ptr == '-')
>>        ptr++;
>>       end_ptr = strchr (ptr, '-');
>> +
>>       if (!end_ptr)
>>        end_ptr = ptr + strlen (ptr);
>>       length = end_ptr - ptr;
>>
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  The
>> +             user provided filename overrides generated dump names as
>> +             well as other command line filenames.  */
>> +          flags |= TDF_USER_FILENAME;
>> +          if (dfi->user_filename)
>> +            free (dfi->user_filename);
>> +          dfi->user_filename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +
>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>        if (strlen (option_ptr->name) == length
>>            && !memcmp (option_ptr->name, ptr, length))
>> -         {
>> -           flags |= option_ptr->value;
>> +          {
>> +            flags |= option_ptr->value;
>>            goto found;
>> -         }
>> +          }
>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>               length, ptr, dfi->swtch);
>>     found:;
>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>      known dumps.  */
>>   if (dfi->suffix == NULL)
>> -    dump_enable_all (dfi->flags);
>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>
>>   return 1;
>>  }
>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>  bool
>>  enable_rtl_dump_file (void)
>>  {
>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>  }
>> Index: tree-pass.h
>> ===================================================================
>> --- tree-pass.h (revision 187265)
>> +++ tree-pass.h (working copy)
>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>> +                                           instead of constructing one. */
>>
>> -
>>  /* In tree-dump.c */
>>
>>  extern char *get_dump_file_name (int);
>> @@ -222,6 +223,8 @@ struct dump_file_info
>>   const char *suffix;           /* suffix to give output file.  */
>>   const char *swtch;            /* command line switch */
>>   const char *glob;             /* command line glob  */
>> +  const char *user_filename;    /* user provided filename instead of making
>> +                                   up one using dump_base_name + suffix.  */
>
> There is "no user" here: we are the users :-)  Just call it "filename".
>
> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-09 23:58   ` Sharad Singhai
@ 2012-05-10  0:31     ` Xinliang David Li
  2012-05-10  8:18       ` Richard Guenther
  2012-05-10  8:19       ` Sharad Singhai
  0 siblings, 2 replies; 71+ messages in thread
From: Xinliang David Li @ 2012-05-10  0:31 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Gabriel Dos Reis, gcc-patches, Richard Guenther, reply, Andrew Pinski

Bummer.  I was thinking to reserve '=' for selective  dumping:

-fdump-tree-pre=<func_list_regexp>

I guess this can be achieved via @

-fdump-tree-pre@<func_list>

-fdump-tree-pre=<file_name>@<func_list>


Another issue -- I don't think the current precedence rule is correct.
Consider that -fopt-info=2 will be mapped to

-fdump-tree-all-transform-verbose2=stderr
-fdump-rtl-all-transform-verbose2=stderr

then

the current precedence rule will cause surprise when the following is used

-fopt-info -fdump-tree-pre

The PRE dump will be emitted to stderr which is not what user wants.
In short, special streams should be treated as 'weak' the same way as
your previous implementation.

thanks,

David



On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
> Thanks for your suggestions/comments. I have updated the patch and
> documentation. It supports the following usage:
>
> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
> -fdump-rtl-ira=ira.dump
>
> Here all tree dumps except the PRE are output into tree.dump, PRE dump
> goes to stdout and the IRA dump goes to ira.dump.
>
> Thanks,
> Sharad
>
> 2012-05-09   Sharad Singhai  <singhai@google.com>
>
>        * doc/invoke.texi: Add documentation for the new option.
>        * tree-dump.c (dump_get_standard_stream): New function.
>        (dump_files): Update for new field.
>        (dump_switch_p_1): Handle dump filenames.
>        (dump_begin): Likewise.
>        (get_dump_file_name): Likewise.
>        (dump_end): Remove attribute.
>        (dump_enable_all): Add new parameter FILENAME.
>        All callers updated.
>        (enable_rtl_dump_file):
>        * tree-pass.h (enum tree_dump_index): Add new constant.
>        (struct dump_file_info): Add new field FILENAME.
>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>
> Index: doc/invoke.texi
> ===================================================================
> --- doc/invoke.texi     (revision 187265)
> +++ doc/invoke.texi     (working copy)
> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>
>  @item -d@var{letters}
>  @itemx -fdump-rtl-@var{pass}
> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>  @opindex d
>  Says to make debugging dumps during compilation at times specified by
>  @var{letters}.  This is used for debugging the RTL-based passes of the
>  compiler.  The file names for most of the dumps are made by appending
>  a pass number and a word to the @var{dumpname}, and the files are
> -created in the directory of the output file.  Note that the pass
> -number is computed statically as passes get registered into the pass
> -manager.  Thus the numbering is not related to the dynamic order of
> -execution of passes.  In particular, a pass installed by a plugin
> -could have a number over 200 even if it executed quite early.
> -@var{dumpname} is generated from the name of the output file, if
> -explicitly specified and it is not an executable, otherwise it is the
> -basename of the source file. These switches may have different effects
> -when @option{-E} is used for preprocessing.
> +created in the directory of the output file. If the
> +@option{=@var{filename}} is appended to the longer form of the dump
> +option then the dump is done on that file instead of numbered
> +files. Note that the pass number is computed statically as passes get
> +registered into the pass manager.  Thus the numbering is not related
> +to the dynamic order of execution of passes.  In particular, a pass
> +installed by a plugin could have a number over 200 even if it executed
> +quite early.  @var{dumpname} is generated from the name of the output
> +file, if explicitly specified and it is not an executable, otherwise
> +it is the basename of the source file. These switches may have
> +different effects when @option{-E} is used for preprocessing.
>
>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>  @option{-d} option @var{letters}.  Here are the possible
> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>
>  @item -fdump-tree-@var{switch}
>  @itemx -fdump-tree-@var{switch}-@var{options}
> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>  @opindex fdump-tree
>  Control the dumping at various stages of processing the intermediate
>  language tree to a file.  The file name is generated by appending a
>  switch specific suffix to the source file name, and the file is
> -created in the same directory as the output file.  If the
> -@samp{-@var{options}} form is used, @var{options} is a list of
> -@samp{-} separated options which control the details of the dump.  Not
> -all options are applicable to all dumps; those that are not
> -meaningful are ignored.  The following options are available
> +created in the same directory as the output file. In case of
> +@option{=@var{filename}} option, the dump is output on the given file
> +name instead.  If the @samp{-@var{options}} form is used,
> +@var{options} is a list of @samp{-} separated options which control
> +the details or location of the dump.  Not all options are applicable
> +to all dumps; those that are not meaningful are ignored.  The
> +following options are available
>
>  @table @samp
>  @item address
> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>  Enable showing the EH region number holding each statement.
>  @item scev
>  Enable showing scalar evolution analysis details.
> +@item slim
> +Inhibit dumping of members of a scope or body of a function merely
> +because that scope has been reached.  Only dump such items when they
> +are directly reachable by some other path.  When dumping pretty-printed
> +trees, this option inhibits dumping the bodies of control structures.
> +@item =@var{filename}
> +Instead of using an auto generated dump file name, use the given file
> +name. The file names @file{stdout} and @file{stderr} are treated
> +specially and are considered already open standard streams. For
> +example:
> +
> +@smallexample
> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
> +@end smallexample
> +
> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
> +file named @file{ira.txt}.
> +
> +In case of any conflicts, the command line file name takes precedence
> +over generated file names. For example:
> +
> +@smallexample
> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
> +@end smallexample
> +
> +Both of the above output the PRE dump on @file{stdout}. However, if
> +there are multiple command line file names are applicable then the
> +last one is used. Thus the command
> +
> +@smallexample
> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
> +@end smallexample
> +
> +outputs all the dumps in @file{all.txt} because the stderr option for
> +PRE dump is overridden by a later option.
> +
>  @item all
> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
> -and @option{lineno}.
> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
> +@option{lineno}.
>  @end table
>
>  The following tree dumps are possible:
> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>  @item all
>  @opindex fdump-tree-all
>  Enable all the available tree dumps with the flags provided in this option.
> +
>  @end table
>
>  @item -ftree-vectorizer-verbose=@var{n}
> Index: tree-dump.c
> ===================================================================
> --- tree-dump.c (revision 187265)
> +++ tree-dump.c (working copy)
> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>    tree_dump_index enumeration in tree-pass.h.  */
>  static struct dump_file_info dump_files[TDI_end] =
>  {
> -  {NULL, NULL, NULL, 0, 0, 0},
> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
> -  {".ads", "ada-spec", NULL, 0, 0, 7},
> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>  #define FIRST_AUTO_NUMBERED_DUMP 8
>
> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>  };
>
>  /* Dynamically registered tree dump files and switches.  */
> @@ -802,7 +802,7 @@ struct dump_option_value_info
>  };
>
>  /* Table of dump options. This must be consistent with the TDF_* flags
> -   in tree.h */
> +   in tree-pass.h */
>  static const struct dump_option_value_info dump_options[] =
>  {
>   {"address", TDF_ADDRESS},
> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>   if (dfi->state == 0)
>     return NULL;
>
> +  if (dfi->filename)
> +    return xstrdup (dfi->filename);
> +
>   if (dfi->num < 0)
>     dump_id[0] = '\0';
>   else
> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>  }
>
> +/* If the DFI dump output corresponds to stdout or stderr stream,
> +   return that stream, NULL otherwise.  */
> +
> +static FILE *
> +dump_get_standard_stream (struct dump_file_info *dfi)
> +{
> +  if (!dfi->filename)
> +    return NULL;
> +
> +  return strcmp("stderr", dfi->filename) == 0
> +    ? stderr
> +    : strcmp("stdout", dfi->filename) == 0
> +    ?  stdout
> +    : NULL;
> +}
> +
>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>    *FLAG_PTR and returns a stream to write to. If the dump is not
>    enabled, returns NULL.
> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>   if (phase == TDI_none || !dump_enabled_p (phase))
>     return NULL;
>
> -  name = get_dump_file_name (phase);
>   dfi = get_dump_file_info (phase);
> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
> -  if (!stream)
> -    error ("could not open dump file %qs: %m", name);
> +  stream = dump_get_standard_stream (dfi);
> +  if (stream)
> +    dfi->state = 1;
>   else
> -    dfi->state = 1;
> -  free (name);
> +    {
> +      name = get_dump_file_name (phase);
> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
> +      if (!stream)
> +        error ("could not open dump file %qs: %m", name);
> +      else
> +        dfi->state = 1;
> +      free (name);
> +    }
>
>   if (flag_ptr)
>     *flag_ptr = dfi->flags;
> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>    dump_begin.  */
>
>  void
> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
> +dump_end (int phase, FILE *stream)
>  {
> -  fclose (stream);
> +  struct dump_file_info *dfi = get_dump_file_info (phase);
> +  if (!dump_get_standard_stream (dfi))
> +    fclose (stream);
>  }
>
> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
> +   enabled tree dumps.  */
>
>  static int
> -dump_enable_all (int flags)
> +dump_enable_all (int flags, const char *filename)
>  {
>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>   int n = 0;
>   size_t i;
>
>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
> -    if ((dump_files[i].flags & ir_dump_type))
> -      {
> -        dump_files[i].state = -1;
> -        dump_files[i].flags |= flags;
> -        n++;
> -      }
> +    {
> +      if ((dump_files[i].flags & ir_dump_type))
> +        {
> +          dump_files[i].state = -1;
> +          dump_files[i].flags |= flags;
> +          n++;
> +          if (filename)
> +            dump_files[i].filename = xstrdup (filename);
> +        }
> +    }
>
>   for (i = 0; i < extra_dump_files_in_use; i++)
> -    if ((extra_dump_files[i].flags & ir_dump_type))
> -      {
> -        extra_dump_files[i].state = -1;
> -        extra_dump_files[i].flags |= flags;
> -       n++;
> -      }
> +    {
> +      if ((extra_dump_files[i].flags & ir_dump_type))
> +        {
> +          extra_dump_files[i].state = -1;
> +          extra_dump_files[i].flags |= flags;
> +          n++;
> +          if (filename)
> +            extra_dump_files[i].filename = xstrdup (filename);
> +        }
> +    }
>
>   return n;
>  }
> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>   if (!option_value)
>     return 0;
>
> -  if (*option_value && *option_value != '-')
> +  if (*option_value && *option_value != '-' && *option_value != '=')
>     return 0;
>
>   ptr = option_value;
> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>       while (*ptr == '-')
>        ptr++;
>       end_ptr = strchr (ptr, '-');
> +
>       if (!end_ptr)
>        end_ptr = ptr + strlen (ptr);
>       length = end_ptr - ptr;
>
> +      if (*ptr == '=')
> +        {
> +          /* Interpret rest of the argument as a dump filename.  This
> +             filename overrides generated dump names as well as other
> +             command line filenames.  */
> +          flags |= TDF_FILENAME;
> +          if (dfi->filename)
> +            free (dfi->filename);
> +          dfi->filename = xstrdup (ptr + 1);
> +          break;
> +        }
> +
>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>        if (strlen (option_ptr->name) == length
>            && !memcmp (option_ptr->name, ptr, length))
> -         {
> -           flags |= option_ptr->value;
> +          {
> +            flags |= option_ptr->value;
>            goto found;
> -         }
> +          }
>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>               length, ptr, dfi->swtch);
>     found:;
> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>      known dumps.  */
>   if (dfi->suffix == NULL)
> -    dump_enable_all (dfi->flags);
> +    dump_enable_all (dfi->flags, dfi->filename);
>
>   return 1;
>  }
> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>  bool
>  enable_rtl_dump_file (void)
>  {
> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>  }
> Index: tree-pass.h
> ===================================================================
> --- tree-pass.h (revision 187265)
> +++ tree-pass.h (working copy)
> @@ -84,8 +84,9 @@ enum tree_dump_index
>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
> +                                           instead of constructing one. */
>
> -
>  /* In tree-dump.c */
>
>  extern char *get_dump_file_name (int);
> @@ -222,6 +223,8 @@ struct dump_file_info
>   const char *suffix;           /* suffix to give output file.  */
>   const char *swtch;            /* command line switch */
>   const char *glob;             /* command line glob  */
> +  const char *filename;         /* use this filename instead of making
> +                                   up one using dump_base_name + suffix.  */
>   int flags;                    /* user flags */
>   int state;                    /* state of play */
>   int num;                      /* dump file number */
> Index: testsuite/g++.dg/other/dump-filename-1.C
> ===================================================================
> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
> @@ -0,0 +1,11 @@
> +// Test that the dump to a user-defined file works correctly.
> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
> +
> +void test (int *b, int *e, int stride)
> +  {
> +    for (int *p = b; p != e; p += stride)
> +      *p = 1;
> +  }
> +
> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
> +/* { dg-final { remove-build-file "foobar.dump" } } */
>
>
> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>> [...]
>>
>>> +@item -fdump-rtl-all=stderr
>>> +@opindex fdump-rtl-all=stderr
>>
>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>> Rather, expand the description to state this in all the documentation
>> for -fdump-xxx=yyy.
>>
>> [...]
>>
>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>> +   stderr stream.  */
>>> +
>>> +static int
>>> +dump_stream_p (const char *user_filename)
>>> +{
>>> +  if (user_filename)
>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>> +      !strncmp ("stdout", user_filename, 6);
>>> +  else
>>> +    return 0;
>>> +}
>>
>> The name is ambiguous.
>> This function is testing whether its string argument designates one of
>> the *standard* output streams.  Name it to reflect that..
>> Have it take the dump state context. Also the coding convention: the binary
>> operator "||" should be on next line.  In fact the thing could be
>> simpler.   Instead of
>> testing over and over again against "stderr" (once in this function, then again
>> later), just return the corresponding standard FILE* pointer.
>> Also, this is a case of overuse of strncmp.  If you name the function
>> dump_get_standard_stream:
>>
>>    return strcmp("stderr", dfi->user_filename) == 0
>>       ? stderr
>>        : stdcmp("stdout", dfi->use_filename)
>>        ?  stdout
>>        : NULL;
>>
>> you can simplify:
>>
>>> -  name = get_dump_file_name (phase);
>>>   dfi = get_dump_file_info (phase);
>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>> -  if (!stream)
>>> -    error ("could not open dump file %qs: %m", name);
>>> +  if (dump_stream_p (dfi->user_filename))
>>> +    {
>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>> +        stream = stderr;
>>> +      else
>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>> +          stream = stdout;
>>> +        else
>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>> +      dfi->state = 1;
>>> +    }
>>>   else
>>> -    dfi->state = 1;
>>> -  free (name);
>>> +    {
>>> +      name = get_dump_file_name (phase);
>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>> +      if (!stream)
>>> +        error ("could not open dump file %qs: %m", name);
>>> +      else
>>> +        dfi->state = 1;
>>> +      free (name);
>>> +    }
>>>
>>>   if (flag_ptr)
>>>     *flag_ptr = dfi->flags;
>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>    dump_begin.  */
>>>
>>>  void
>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>> +dump_end (int phase, FILE *stream)
>>>  {
>>> -  fclose (stream);
>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>> +  if (!dump_stream_p (dfi->user_filename))
>>> +    fclose (stream);
>>>  }
>>>
>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>
>>>  static int
>>> -dump_enable_all (int flags)
>>> +dump_enable_all (int flags, const char *user_filename)
>>>  {
>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>   int n = 0;
>>>   size_t i;
>>>
>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>> -    if ((dump_files[i].flags & ir_dump_type))
>>> -      {
>>> -        dump_files[i].state = -1;
>>> -        dump_files[i].flags |= flags;
>>> -        n++;
>>> -      }
>>> +    {
>>> +      if ((dump_files[i].flags & ir_dump_type))
>>> +        {
>>> +          dump_files[i].state = -1;
>>> +          dump_files[i].flags |= flags;
>>> +          n++;
>>> +        }
>>> +      if (user_filename)
>>> +        dump_files[i].user_filename = user_filename;
>>> +    }
>>>
>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>> -      {
>>> -        extra_dump_files[i].state = -1;
>>> -        extra_dump_files[i].flags |= flags;
>>> -       n++;
>>> -      }
>>> +    {
>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>> +        {
>>> +          extra_dump_files[i].state = -1;
>>> +          extra_dump_files[i].flags |= flags;
>>> +          n++;
>>> +        }
>>> +      if (user_filename)
>>> +        extra_dump_files[i].user_filename = user_filename;
>>> +    }
>>>
>>>   return n;
>>>  }
>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>   if (!option_value)
>>>     return 0;
>>>
>>> -  if (*option_value && *option_value != '-')
>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>     return 0;
>>>
>>>   ptr = option_value;
>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>       while (*ptr == '-')
>>>        ptr++;
>>>       end_ptr = strchr (ptr, '-');
>>> +
>>>       if (!end_ptr)
>>>        end_ptr = ptr + strlen (ptr);
>>>       length = end_ptr - ptr;
>>>
>>> +      if (*ptr == '=')
>>> +        {
>>> +          /* Interpret rest of the argument as a dump filename.  The
>>> +             user provided filename overrides generated dump names as
>>> +             well as other command line filenames.  */
>>> +          flags |= TDF_USER_FILENAME;
>>> +          if (dfi->user_filename)
>>> +            free (dfi->user_filename);
>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>> +          break;
>>> +        }
>>> +
>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>        if (strlen (option_ptr->name) == length
>>>            && !memcmp (option_ptr->name, ptr, length))
>>> -         {
>>> -           flags |= option_ptr->value;
>>> +          {
>>> +            flags |= option_ptr->value;
>>>            goto found;
>>> -         }
>>> +          }
>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>               length, ptr, dfi->swtch);
>>>     found:;
>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>      known dumps.  */
>>>   if (dfi->suffix == NULL)
>>> -    dump_enable_all (dfi->flags);
>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>
>>>   return 1;
>>>  }
>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>  bool
>>>  enable_rtl_dump_file (void)
>>>  {
>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>  }
>>> Index: tree-pass.h
>>> ===================================================================
>>> --- tree-pass.h (revision 187265)
>>> +++ tree-pass.h (working copy)
>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>> +                                           instead of constructing one. */
>>>
>>> -
>>>  /* In tree-dump.c */
>>>
>>>  extern char *get_dump_file_name (int);
>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>   const char *suffix;           /* suffix to give output file.  */
>>>   const char *swtch;            /* command line switch */
>>>   const char *glob;             /* command line glob  */
>>> +  const char *user_filename;    /* user provided filename instead of making
>>> +                                   up one using dump_base_name + suffix.  */
>>
>> There is "no user" here: we are the users :-)  Just call it "filename".
>>
>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-10  0:31     ` Xinliang David Li
@ 2012-05-10  8:18       ` Richard Guenther
  2012-05-10 16:28         ` Xinliang David Li
  2012-05-10  8:19       ` Sharad Singhai
  1 sibling, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-05-10  8:18 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
> Bummer.  I was thinking to reserve '=' for selective  dumping:
>
> -fdump-tree-pre=<func_list_regexp>
>
> I guess this can be achieved via @
>
> -fdump-tree-pre@<func_list>
>
> -fdump-tree-pre=<file_name>@<func_list>
>
>
> Another issue -- I don't think the current precedence rule is correct.
> Consider that -fopt-info=2 will be mapped to
>
> -fdump-tree-all-transform-verbose2=stderr
> -fdump-rtl-all-transform-verbose2=stderr
>
> then
>
> the current precedence rule will cause surprise when the following is used
>
> -fopt-info -fdump-tree-pre
>
> The PRE dump will be emitted to stderr which is not what user wants.
> In short, special streams should be treated as 'weak' the same way as
> your previous implementation.

Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
With -fopt-info -fdump-tree-pre I do not want some information to be
present only on stderr or in the dump file!  I want it in _both_ places!
(-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
information :()

Thus, the information where dumping goes has to be done differently
(which is why I asked for some re-org originally, so that passes no
longer explicitely reference dump_file - dump_file may be different
for different kind of information it dumps!).  Passes should, instead of

  fprintf (dump_file, "...", ...)

do

 dump_printf (TDF_scev, "...", ...)

thus, specify the kind of information they dump (would be mostly
TDF_details vs. 0 today I guess).  The dump_printf routine would
then properly direct to one or more places to dump at.

I realize this needs some more dispatchers for dumping expressions
and statements (but it should not be too many).  Dumping to
dump_file would in any case dump to the passes private dump file
only (unqualified stuff would never be useful for -fopt-info).

The perfect candidate to convert to this kind of scheme is obviously
the vectorizer with its existing -fvectorizer-verbose.

If the patch doesn't work towards this kind of end-result I'd rather
not have it.

Thanks,
Richard.

> thanks,
>
> David
>
>
>
> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>> Thanks for your suggestions/comments. I have updated the patch and
>> documentation. It supports the following usage:
>>
>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>> -fdump-rtl-ira=ira.dump
>>
>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>> goes to stdout and the IRA dump goes to ira.dump.
>>
>> Thanks,
>> Sharad
>>
>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>
>>        * doc/invoke.texi: Add documentation for the new option.
>>        * tree-dump.c (dump_get_standard_stream): New function.
>>        (dump_files): Update for new field.
>>        (dump_switch_p_1): Handle dump filenames.
>>        (dump_begin): Likewise.
>>        (get_dump_file_name): Likewise.
>>        (dump_end): Remove attribute.
>>        (dump_enable_all): Add new parameter FILENAME.
>>        All callers updated.
>>        (enable_rtl_dump_file):
>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>        (struct dump_file_info): Add new field FILENAME.
>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>
>> Index: doc/invoke.texi
>> ===================================================================
>> --- doc/invoke.texi     (revision 187265)
>> +++ doc/invoke.texi     (working copy)
>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>
>>  @item -d@var{letters}
>>  @itemx -fdump-rtl-@var{pass}
>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>  @opindex d
>>  Says to make debugging dumps during compilation at times specified by
>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>  compiler.  The file names for most of the dumps are made by appending
>>  a pass number and a word to the @var{dumpname}, and the files are
>> -created in the directory of the output file.  Note that the pass
>> -number is computed statically as passes get registered into the pass
>> -manager.  Thus the numbering is not related to the dynamic order of
>> -execution of passes.  In particular, a pass installed by a plugin
>> -could have a number over 200 even if it executed quite early.
>> -@var{dumpname} is generated from the name of the output file, if
>> -explicitly specified and it is not an executable, otherwise it is the
>> -basename of the source file. These switches may have different effects
>> -when @option{-E} is used for preprocessing.
>> +created in the directory of the output file. If the
>> +@option{=@var{filename}} is appended to the longer form of the dump
>> +option then the dump is done on that file instead of numbered
>> +files. Note that the pass number is computed statically as passes get
>> +registered into the pass manager.  Thus the numbering is not related
>> +to the dynamic order of execution of passes.  In particular, a pass
>> +installed by a plugin could have a number over 200 even if it executed
>> +quite early.  @var{dumpname} is generated from the name of the output
>> +file, if explicitly specified and it is not an executable, otherwise
>> +it is the basename of the source file. These switches may have
>> +different effects when @option{-E} is used for preprocessing.
>>
>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>  @option{-d} option @var{letters}.  Here are the possible
>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>
>>  @item -fdump-tree-@var{switch}
>>  @itemx -fdump-tree-@var{switch}-@var{options}
>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>  @opindex fdump-tree
>>  Control the dumping at various stages of processing the intermediate
>>  language tree to a file.  The file name is generated by appending a
>>  switch specific suffix to the source file name, and the file is
>> -created in the same directory as the output file.  If the
>> -@samp{-@var{options}} form is used, @var{options} is a list of
>> -@samp{-} separated options which control the details of the dump.  Not
>> -all options are applicable to all dumps; those that are not
>> -meaningful are ignored.  The following options are available
>> +created in the same directory as the output file. In case of
>> +@option{=@var{filename}} option, the dump is output on the given file
>> +name instead.  If the @samp{-@var{options}} form is used,
>> +@var{options} is a list of @samp{-} separated options which control
>> +the details or location of the dump.  Not all options are applicable
>> +to all dumps; those that are not meaningful are ignored.  The
>> +following options are available
>>
>>  @table @samp
>>  @item address
>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>  Enable showing the EH region number holding each statement.
>>  @item scev
>>  Enable showing scalar evolution analysis details.
>> +@item slim
>> +Inhibit dumping of members of a scope or body of a function merely
>> +because that scope has been reached.  Only dump such items when they
>> +are directly reachable by some other path.  When dumping pretty-printed
>> +trees, this option inhibits dumping the bodies of control structures.
>> +@item =@var{filename}
>> +Instead of using an auto generated dump file name, use the given file
>> +name. The file names @file{stdout} and @file{stderr} are treated
>> +specially and are considered already open standard streams. For
>> +example:
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>> +@end smallexample
>> +
>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>> +file named @file{ira.txt}.
>> +
>> +In case of any conflicts, the command line file name takes precedence
>> +over generated file names. For example:
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>> +@end smallexample
>> +
>> +Both of the above output the PRE dump on @file{stdout}. However, if
>> +there are multiple command line file names are applicable then the
>> +last one is used. Thus the command
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>> +@end smallexample
>> +
>> +outputs all the dumps in @file{all.txt} because the stderr option for
>> +PRE dump is overridden by a later option.
>> +
>>  @item all
>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>> -and @option{lineno}.
>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>> +@option{lineno}.
>>  @end table
>>
>>  The following tree dumps are possible:
>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>  @item all
>>  @opindex fdump-tree-all
>>  Enable all the available tree dumps with the flags provided in this option.
>> +
>>  @end table
>>
>>  @item -ftree-vectorizer-verbose=@var{n}
>> Index: tree-dump.c
>> ===================================================================
>> --- tree-dump.c (revision 187265)
>> +++ tree-dump.c (working copy)
>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>    tree_dump_index enumeration in tree-pass.h.  */
>>  static struct dump_file_info dump_files[TDI_end] =
>>  {
>> -  {NULL, NULL, NULL, 0, 0, 0},
>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>
>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>  };
>>
>>  /* Dynamically registered tree dump files and switches.  */
>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>  };
>>
>>  /* Table of dump options. This must be consistent with the TDF_* flags
>> -   in tree.h */
>> +   in tree-pass.h */
>>  static const struct dump_option_value_info dump_options[] =
>>  {
>>   {"address", TDF_ADDRESS},
>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>   if (dfi->state == 0)
>>     return NULL;
>>
>> +  if (dfi->filename)
>> +    return xstrdup (dfi->filename);
>> +
>>   if (dfi->num < 0)
>>     dump_id[0] = '\0';
>>   else
>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>  }
>>
>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>> +   return that stream, NULL otherwise.  */
>> +
>> +static FILE *
>> +dump_get_standard_stream (struct dump_file_info *dfi)
>> +{
>> +  if (!dfi->filename)
>> +    return NULL;
>> +
>> +  return strcmp("stderr", dfi->filename) == 0
>> +    ? stderr
>> +    : strcmp("stdout", dfi->filename) == 0
>> +    ?  stdout
>> +    : NULL;
>> +}
>> +
>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>    enabled, returns NULL.
>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>     return NULL;
>>
>> -  name = get_dump_file_name (phase);
>>   dfi = get_dump_file_info (phase);
>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> -  if (!stream)
>> -    error ("could not open dump file %qs: %m", name);
>> +  stream = dump_get_standard_stream (dfi);
>> +  if (stream)
>> +    dfi->state = 1;
>>   else
>> -    dfi->state = 1;
>> -  free (name);
>> +    {
>> +      name = get_dump_file_name (phase);
>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> +      if (!stream)
>> +        error ("could not open dump file %qs: %m", name);
>> +      else
>> +        dfi->state = 1;
>> +      free (name);
>> +    }
>>
>>   if (flag_ptr)
>>     *flag_ptr = dfi->flags;
>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>    dump_begin.  */
>>
>>  void
>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>> +dump_end (int phase, FILE *stream)
>>  {
>> -  fclose (stream);
>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>> +  if (!dump_get_standard_stream (dfi))
>> +    fclose (stream);
>>  }
>>
>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>> +   enabled tree dumps.  */
>>
>>  static int
>> -dump_enable_all (int flags)
>> +dump_enable_all (int flags, const char *filename)
>>  {
>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>   int n = 0;
>>   size_t i;
>>
>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -    if ((dump_files[i].flags & ir_dump_type))
>> -      {
>> -        dump_files[i].state = -1;
>> -        dump_files[i].flags |= flags;
>> -        n++;
>> -      }
>> +    {
>> +      if ((dump_files[i].flags & ir_dump_type))
>> +        {
>> +          dump_files[i].state = -1;
>> +          dump_files[i].flags |= flags;
>> +          n++;
>> +          if (filename)
>> +            dump_files[i].filename = xstrdup (filename);
>> +        }
>> +    }
>>
>>   for (i = 0; i < extra_dump_files_in_use; i++)
>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>> -      {
>> -        extra_dump_files[i].state = -1;
>> -        extra_dump_files[i].flags |= flags;
>> -       n++;
>> -      }
>> +    {
>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>> +        {
>> +          extra_dump_files[i].state = -1;
>> +          extra_dump_files[i].flags |= flags;
>> +          n++;
>> +          if (filename)
>> +            extra_dump_files[i].filename = xstrdup (filename);
>> +        }
>> +    }
>>
>>   return n;
>>  }
>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   if (!option_value)
>>     return 0;
>>
>> -  if (*option_value && *option_value != '-')
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>     return 0;
>>
>>   ptr = option_value;
>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>       while (*ptr == '-')
>>        ptr++;
>>       end_ptr = strchr (ptr, '-');
>> +
>>       if (!end_ptr)
>>        end_ptr = ptr + strlen (ptr);
>>       length = end_ptr - ptr;
>>
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  This
>> +             filename overrides generated dump names as well as other
>> +             command line filenames.  */
>> +          flags |= TDF_FILENAME;
>> +          if (dfi->filename)
>> +            free (dfi->filename);
>> +          dfi->filename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +
>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>        if (strlen (option_ptr->name) == length
>>            && !memcmp (option_ptr->name, ptr, length))
>> -         {
>> -           flags |= option_ptr->value;
>> +          {
>> +            flags |= option_ptr->value;
>>            goto found;
>> -         }
>> +          }
>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>               length, ptr, dfi->swtch);
>>     found:;
>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>      known dumps.  */
>>   if (dfi->suffix == NULL)
>> -    dump_enable_all (dfi->flags);
>> +    dump_enable_all (dfi->flags, dfi->filename);
>>
>>   return 1;
>>  }
>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>  bool
>>  enable_rtl_dump_file (void)
>>  {
>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>  }
>> Index: tree-pass.h
>> ===================================================================
>> --- tree-pass.h (revision 187265)
>> +++ tree-pass.h (working copy)
>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>> +                                           instead of constructing one. */
>>
>> -
>>  /* In tree-dump.c */
>>
>>  extern char *get_dump_file_name (int);
>> @@ -222,6 +223,8 @@ struct dump_file_info
>>   const char *suffix;           /* suffix to give output file.  */
>>   const char *swtch;            /* command line switch */
>>   const char *glob;             /* command line glob  */
>> +  const char *filename;         /* use this filename instead of making
>> +                                   up one using dump_base_name + suffix.  */
>>   int flags;                    /* user flags */
>>   int state;                    /* state of play */
>>   int num;                      /* dump file number */
>> Index: testsuite/g++.dg/other/dump-filename-1.C
>> ===================================================================
>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>> @@ -0,0 +1,11 @@
>> +// Test that the dump to a user-defined file works correctly.
>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>> +
>> +void test (int *b, int *e, int stride)
>> +  {
>> +    for (int *p = b; p != e; p += stride)
>> +      *p = 1;
>> +  }
>> +
>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>
>>
>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>> <gdr@integrable-solutions.net> wrote:
>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>> [...]
>>>
>>>> +@item -fdump-rtl-all=stderr
>>>> +@opindex fdump-rtl-all=stderr
>>>
>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>> Rather, expand the description to state this in all the documentation
>>> for -fdump-xxx=yyy.
>>>
>>> [...]
>>>
>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>> +   stderr stream.  */
>>>> +
>>>> +static int
>>>> +dump_stream_p (const char *user_filename)
>>>> +{
>>>> +  if (user_filename)
>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>> +      !strncmp ("stdout", user_filename, 6);
>>>> +  else
>>>> +    return 0;
>>>> +}
>>>
>>> The name is ambiguous.
>>> This function is testing whether its string argument designates one of
>>> the *standard* output streams.  Name it to reflect that..
>>> Have it take the dump state context. Also the coding convention: the binary
>>> operator "||" should be on next line.  In fact the thing could be
>>> simpler.   Instead of
>>> testing over and over again against "stderr" (once in this function, then again
>>> later), just return the corresponding standard FILE* pointer.
>>> Also, this is a case of overuse of strncmp.  If you name the function
>>> dump_get_standard_stream:
>>>
>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>       ? stderr
>>>        : stdcmp("stdout", dfi->use_filename)
>>>        ?  stdout
>>>        : NULL;
>>>
>>> you can simplify:
>>>
>>>> -  name = get_dump_file_name (phase);
>>>>   dfi = get_dump_file_info (phase);
>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>> -  if (!stream)
>>>> -    error ("could not open dump file %qs: %m", name);
>>>> +  if (dump_stream_p (dfi->user_filename))
>>>> +    {
>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>> +        stream = stderr;
>>>> +      else
>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>> +          stream = stdout;
>>>> +        else
>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>> +      dfi->state = 1;
>>>> +    }
>>>>   else
>>>> -    dfi->state = 1;
>>>> -  free (name);
>>>> +    {
>>>> +      name = get_dump_file_name (phase);
>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>> +      if (!stream)
>>>> +        error ("could not open dump file %qs: %m", name);
>>>> +      else
>>>> +        dfi->state = 1;
>>>> +      free (name);
>>>> +    }
>>>>
>>>>   if (flag_ptr)
>>>>     *flag_ptr = dfi->flags;
>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>    dump_begin.  */
>>>>
>>>>  void
>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>> +dump_end (int phase, FILE *stream)
>>>>  {
>>>> -  fclose (stream);
>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>> +    fclose (stream);
>>>>  }
>>>>
>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>
>>>>  static int
>>>> -dump_enable_all (int flags)
>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>  {
>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>   int n = 0;
>>>>   size_t i;
>>>>
>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>> -      {
>>>> -        dump_files[i].state = -1;
>>>> -        dump_files[i].flags |= flags;
>>>> -        n++;
>>>> -      }
>>>> +    {
>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>> +        {
>>>> +          dump_files[i].state = -1;
>>>> +          dump_files[i].flags |= flags;
>>>> +          n++;
>>>> +        }
>>>> +      if (user_filename)
>>>> +        dump_files[i].user_filename = user_filename;
>>>> +    }
>>>>
>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>> -      {
>>>> -        extra_dump_files[i].state = -1;
>>>> -        extra_dump_files[i].flags |= flags;
>>>> -       n++;
>>>> -      }
>>>> +    {
>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>> +        {
>>>> +          extra_dump_files[i].state = -1;
>>>> +          extra_dump_files[i].flags |= flags;
>>>> +          n++;
>>>> +        }
>>>> +      if (user_filename)
>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>> +    }
>>>>
>>>>   return n;
>>>>  }
>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>   if (!option_value)
>>>>     return 0;
>>>>
>>>> -  if (*option_value && *option_value != '-')
>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>     return 0;
>>>>
>>>>   ptr = option_value;
>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>       while (*ptr == '-')
>>>>        ptr++;
>>>>       end_ptr = strchr (ptr, '-');
>>>> +
>>>>       if (!end_ptr)
>>>>        end_ptr = ptr + strlen (ptr);
>>>>       length = end_ptr - ptr;
>>>>
>>>> +      if (*ptr == '=')
>>>> +        {
>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>> +             user provided filename overrides generated dump names as
>>>> +             well as other command line filenames.  */
>>>> +          flags |= TDF_USER_FILENAME;
>>>> +          if (dfi->user_filename)
>>>> +            free (dfi->user_filename);
>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>> +          break;
>>>> +        }
>>>> +
>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>        if (strlen (option_ptr->name) == length
>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>> -         {
>>>> -           flags |= option_ptr->value;
>>>> +          {
>>>> +            flags |= option_ptr->value;
>>>>            goto found;
>>>> -         }
>>>> +          }
>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>               length, ptr, dfi->swtch);
>>>>     found:;
>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>      known dumps.  */
>>>>   if (dfi->suffix == NULL)
>>>> -    dump_enable_all (dfi->flags);
>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>
>>>>   return 1;
>>>>  }
>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>  bool
>>>>  enable_rtl_dump_file (void)
>>>>  {
>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>  }
>>>> Index: tree-pass.h
>>>> ===================================================================
>>>> --- tree-pass.h (revision 187265)
>>>> +++ tree-pass.h (working copy)
>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>> +                                           instead of constructing one. */
>>>>
>>>> -
>>>>  /* In tree-dump.c */
>>>>
>>>>  extern char *get_dump_file_name (int);
>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>   const char *swtch;            /* command line switch */
>>>>   const char *glob;             /* command line glob  */
>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>> +                                   up one using dump_base_name + suffix.  */
>>>
>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>
>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-10  0:31     ` Xinliang David Li
  2012-05-10  8:18       ` Richard Guenther
@ 2012-05-10  8:19       ` Sharad Singhai
  1 sibling, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-05-10  8:19 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Gabriel Dos Reis, gcc-patches, Richard Guenther, reply, Andrew Pinski

Okay, I have restored the original behavior where standard streams
were considered weak. Thus in case of a conflict, the
standard streams have lower precedence. For example,

               gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...

does the PRE dump in auto numbered file since stdout has lower
precedence. Also this works as expected,

               gcc -O2 -fdump-tree-pre=pre.txt -fdump-tree-all=stderr ...

It outputs PRE dump to pre.txt while the remaining tree dumps are
output on to stderr. Does it look okay?

Thanks,
Sharad


2012-05-09   Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for the new option.
	* tree-dump.c (dump_get_standard_stream): New function.
	(dump_files): Update for new field.
	(dump_switch_p_1): Handle dump filenames.
	(dump_begin): Likewise.
	(get_dump_file_name): Likewise.
	(dump_end): Remove attribute.
	(dump_enable_all): Add new parameter FILENAME.
	All callers updated.
	* tree-pass.h (enum tree_dump_index): Add new constant.
	(struct dump_file_info): Add new field FILENAME.
	* testsuite/g++.dg/other/dump-filename-1.C: New test.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 187265)
+++ doc/invoke.texi	(working copy)
@@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio

 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass}=@var{filename}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
 compiler.  The file names for most of the dumps are made by appending
 a pass number and a word to the @var{dumpname}, and the files are
-created in the directory of the output file.  Note that the pass
-number is computed statically as passes get registered into the pass
-manager.  Thus the numbering is not related to the dynamic order of
-execution of passes.  In particular, a pass installed by a plugin
-could have a number over 200 even if it executed quite early.
-@var{dumpname} is generated from the name of the output file, if
-explicitly specified and it is not an executable, otherwise it is the
-basename of the source file. These switches may have different effects
-when @option{-E} is used for preprocessing.
+created in the directory of the output file. If the
+@option{=@var{filename}} is appended to the longer form of the dump
+option then the dump is done on that file instead of numbered
+files. Note that the pass number is computed statically as passes get
+registered into the pass manager.  Thus the numbering is not related
+to the dynamic order of execution of passes.  In particular, a pass
+installed by a plugin could have a number over 200 even if it executed
+quite early.  @var{dumpname} is generated from the name of the output
+file, if explicitly specified and it is not an executable, otherwise
+it is the basename of the source file. These switches may have
+different effects when @option{-E} is used for preprocessing.

 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
 @option{-d} option @var{letters}.  Here are the possible
@@ -5719,15 +5722,18 @@ counters for each function compiled.

 @item -fdump-tree-@var{switch}
 @itemx -fdump-tree-@var{switch}-@var{options}
+@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
-@samp{-@var{options}} form is used, @var{options} is a list of
-@samp{-} separated options which control the details of the dump.  Not
-all options are applicable to all dumps; those that are not
-meaningful are ignored.  The following options are available
+created in the same directory as the output file. In case of
+@option{=@var{filename}} option, the dump is output on the given file
+name instead.  If the @samp{-@var{options}} form is used,
+@var{options} is a list of @samp{-} separated options which control
+the details or location of the dump.  Not all options are applicable
+to all dumps; those that are not meaningful are ignored.  The
+following options are available

 @table @samp
 @item address
@@ -5765,9 +5771,49 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item slim
+Inhibit dumping of members of a scope or body of a function merely
+because that scope has been reached.  Only dump such items when they
+are directly reachable by some other path.  When dumping pretty-printed
+trees, this option inhibits dumping the bodies of control structures.
+@item =@var{filename}
+Instead of using an auto generated dump file name, use the given file
+name. The file names @file{stdout} and @file{stderr} are treated
+specially and are considered already open standard streams. In
+addition, the standard streams @file{stdout} and @file{stderr} are
+considered weak, i.e., in case of a conflict, some other applicable
+dump file is used instead. For example:
+
+@smallexample
+gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
+@end smallexample
+
+outputs PRE dump on @file{stderr}, while the IRA dump is output in a
+file named @file{ira.txt}.
+
+Usually the command line file names have precedence over automatic
+file names unless the command line file name is a standard stream. For
+example:
+
+@smallexample
+gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
+gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
+@end smallexample
+
+Both of the above output the PRE dump into an auto generated file name
+since the @file{stdout} stream has lower precedence. As another
+example,
+
+@smallexample
+gcc -O2 -fdump-tree-pre=pre.txt -fdump-tree-all=stderr ...
+@end smallexample
+
+outputs all the tree dumps on @file{stderr}, except the PRE dump,
+which is output into @file{pre.txt}.
+
 @item all
-Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
-and @option{lineno}.
+Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
+@option{lineno}.
 @end table

 The following tree dumps are possible:
@@ -5913,6 +5959,7 @@ is made by appending @file{.vrp} to the source fil
 @item all
 @opindex fdump-tree-all
 Enable all the available tree dumps with the flags provided in this option.
+
 @end table

 @item -ftree-vectorizer-verbose=@var{n}
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 187265)
+++ tree-dump.c	(working copy)
@@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
    tree_dump_index enumeration in tree-pass.h.  */
 static struct dump_file_info dump_files[TDI_end] =
 {
-  {NULL, NULL, NULL, 0, 0, 0},
-  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
-  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
-  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
-  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
-  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
-  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
-  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
-  {".ads", "ada-spec", NULL, 0, 0, 7},
+  {NULL, NULL, NULL, NULL, 0, 0, 0},
+  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
+  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
+  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
+  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
+  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
+  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
+  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
+  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
 #define FIRST_AUTO_NUMBERED_DUMP 8

-  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
-  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
-  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
+  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
+  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
+  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
 };

 /* Dynamically registered tree dump files and switches.  */
@@ -802,7 +802,7 @@ struct dump_option_value_info
 };

 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in tree-pass.h */
 static const struct dump_option_value_info dump_options[] =
 {
   {"address", TDF_ADDRESS},
@@ -892,6 +892,9 @@ get_dump_file_name (int phase)
   if (dfi->state == 0)
     return NULL;

+  if (dfi->filename)
+    return xstrdup (dfi->filename);
+
   if (dfi->num < 0)
     dump_id[0] = '\0';
   else
@@ -911,6 +914,22 @@ get_dump_file_name (int phase)
   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }

+/* If FILENAME is a standard stream (stdout or stderr), return that
+   stream, otherwise return NULL.  */
+
+static FILE *
+dump_get_standard_stream (const char *filename)
+{
+  if (!filename)
+    return NULL;
+
+  return strcmp("stderr", filename) == 0
+    ? stderr
+    : strcmp("stdout", filename) == 0
+    ?  stdout
+    : NULL;
+}
+
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
@@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
   if (phase == TDI_none || !dump_enabled_p (phase))
     return NULL;

-  name = get_dump_file_name (phase);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
-  if (!stream)
-    error ("could not open dump file %qs: %m", name);
+  stream = dump_get_standard_stream (dfi->filename);
+  if (stream)
+    dfi->state = 1;
   else
-    dfi->state = 1;
-  free (name);
+    {
+      name = get_dump_file_name (phase);
+      stream = fopen (name, dfi->state < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        dfi->state = 1;
+      free (name);
+    }

   if (flag_ptr)
     *flag_ptr = dfi->flags;
@@ -987,35 +1012,60 @@ dump_flag_name (int phase)
    dump_begin.  */

 void
-dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
+dump_end (int phase, FILE *stream)
 {
-  fclose (stream);
+  struct dump_file_info *dfi = get_dump_file_info (phase);
+  if (!dump_get_standard_stream (dfi->filename))
+    fclose (stream);
 }

-/* Enable all tree dumps.  Return number of enabled tree dumps.  */
+/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
+   enabled tree dumps.  */

 static int
-dump_enable_all (int flags)
+dump_enable_all (int flags, const char *filename)
 {
   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;

   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_dump_type))
-      {
-        dump_files[i].state = -1;
-        dump_files[i].flags |= flags;
-        n++;
-      }
+    {
+      if ((dump_files[i].flags & ir_dump_type))
+        {
+          const char *old_filename = dump_files[i].filename;
+          dump_files[i].state = -1;
+          dump_files[i].flags |= flags;
+          n++;
+          /* Do we need to override an existing filename?  */
+          if (filename && (!old_filename
+                           || dump_get_standard_stream (old_filename)))
+            {
+              dump_files[i].filename = xstrdup (filename);
+              if (filename != old_filename)
+                free ((void *)old_filename);
+            }
+        }
+    }

   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_dump_type))
-      {
-        extra_dump_files[i].state = -1;
-        extra_dump_files[i].flags |= flags;
-	n++;
-      }
+    {
+      if ((extra_dump_files[i].flags & ir_dump_type))
+        {
+          const char *old_filename = extra_dump_files[i].filename;
+          extra_dump_files[i].state = -1;
+          extra_dump_files[i].flags |= flags;
+          n++;
+          /* Do we need to override an existing filename?  */
+          if (filename && (!old_filename
+                           || dump_get_standard_stream (old_filename)))
+            {
+              extra_dump_files[i].filename = xstrdup (filename);
+              if (filename != old_filename)
+                free ((void *)old_filename);
+            }
+        }
+    }

   return n;
 }
@@ -1037,7 +1087,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   if (!option_value)
     return 0;

-  if (*option_value && *option_value != '-')
+  if (*option_value && *option_value != '-' && *option_value != '=')
     return 0;

   ptr = option_value;
@@ -1052,30 +1102,61 @@ dump_switch_p_1 (const char *arg, struct dump_file
       while (*ptr == '-')
 	ptr++;
       end_ptr = strchr (ptr, '-');
+
       if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;

+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  This
+             filename overrides generated dump names as well as other
+             command line filenames. However, the standard streams are
+             considered weak, i.e. they do not override other
+             filenames. */
+          const char *filename = ptr + 1;
+
+          if (!dump_get_standard_stream (filename)
+              || !dfi->state
+              || dump_get_standard_stream (dfi->filename))
+            {
+              free ((void *)dfi->filename);
+              dfi->filename = xstrdup (ptr + 1);
+            }
+          flags |= TDF_FILENAME;
+          break;
+        }
+
       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
-	  {
-	    flags |= option_ptr->value;
+          {
+            flags |= option_ptr->value;
 	    goto found;
-	  }
+          }
       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
 	       length, ptr, dfi->swtch);
     found:;
       ptr = end_ptr;
     }

+  /* For the same dump seen again, override the standard stream
+     because it is considered as a weak filename.  */
+  if ((dfi->flags & TDF_FILENAME)
+      && !(flags & TDF_FILENAME)
+      && dump_get_standard_stream (dfi->filename))
+    {
+      dfi->flags &= ~TDF_FILENAME;
+      free ((void *)dfi->filename);
+      dfi->filename = NULL;
+    }
   dfi->state = -1;
   dfi->flags |= flags;

   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
      known dumps.  */
   if (dfi->suffix == NULL)
-    dump_enable_all (dfi->flags);
+    dump_enable_all (dfi->flags, dfi->filename);

   return 1;
 }
@@ -1124,5 +1205,5 @@ dump_function (int phase, tree fn)
 bool
 enable_rtl_dump_file (void)
 {
-  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
+  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
 }
Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 187265)
+++ tree-pass.h	(working copy)
@@ -84,8 +84,9 @@ enum tree_dump_index
 #define TDF_ENUMERATE_LOCALS (1 << 22)	/* Enumerate locals by uid.  */
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
+#define TDF_FILENAME    (1 << 25)	/* Dump on provided filename
+                                           instead of constructing one. */

-
 /* In tree-dump.c */

 extern char *get_dump_file_name (int);
@@ -222,6 +223,8 @@ struct dump_file_info
   const char *suffix;           /* suffix to give output file.  */
   const char *swtch;            /* command line switch */
   const char *glob;             /* command line glob  */
+  const char *filename;         /* use this filename instead of making
+                                   up one using dump_base_name + suffix.  */
   int flags;                    /* user flags */
   int state;                    /* state of play */
   int num;                      /* dump file number */
Index: testsuite/g++.dg/other/dump-filename-1.C
===================================================================
--- testsuite/g++.dg/other/dump-filename-1.C	(revision 0)
+++ testsuite/g++.dg/other/dump-filename-1.C	(revision 0)
@@ -0,0 +1,11 @@
+// Test that the dump to a user-defined file works correctly.
+/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
+
+void test (int *b, int *e, int stride)
+  {
+    for (int *p = b; p != e; p += stride)
+      *p = 1;
+  }
+
+/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
+/* { dg-final { remove-build-file "foobar.dump" } } */

Sharad


On Wed, May 9, 2012 at 5:31 PM, Xinliang David Li <davidxl@google.com> wrote:
> Bummer.  I was thinking to reserve '=' for selective  dumping:
>
> -fdump-tree-pre=<func_list_regexp>
>
> I guess this can be achieved via @
>
> -fdump-tree-pre@<func_list>
>
> -fdump-tree-pre=<file_name>@<func_list>
>
>
> Another issue -- I don't think the current precedence rule is correct.
> Consider that -fopt-info=2 will be mapped to
>
> -fdump-tree-all-transform-verbose2=stderr
> -fdump-rtl-all-transform-verbose2=stderr
>
> then
>
> the current precedence rule will cause surprise when the following is used
>
> -fopt-info -fdump-tree-pre
>
> The PRE dump will be emitted to stderr which is not what user wants.
> In short, special streams should be treated as 'weak' the same way as
> your previous implementation.
>
> thanks,
>
> David
>
>
>
> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>> Thanks for your suggestions/comments. I have updated the patch and
>> documentation. It supports the following usage:
>>
>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>> -fdump-rtl-ira=ira.dump
>>
>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>> goes to stdout and the IRA dump goes to ira.dump.
>>
>> Thanks,
>> Sharad
>>
>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>
>>        * doc/invoke.texi: Add documentation for the new option.
>>        * tree-dump.c (dump_get_standard_stream): New function.
>>        (dump_files): Update for new field.
>>        (dump_switch_p_1): Handle dump filenames.
>>        (dump_begin): Likewise.
>>        (get_dump_file_name): Likewise.
>>        (dump_end): Remove attribute.
>>        (dump_enable_all): Add new parameter FILENAME.
>>        All callers updated.
>>        (enable_rtl_dump_file):
>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>        (struct dump_file_info): Add new field FILENAME.
>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>
>> Index: doc/invoke.texi
>> ===================================================================
>> --- doc/invoke.texi     (revision 187265)
>> +++ doc/invoke.texi     (working copy)
>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>
>>  @item -d@var{letters}
>>  @itemx -fdump-rtl-@var{pass}
>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>  @opindex d
>>  Says to make debugging dumps during compilation at times specified by
>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>  compiler.  The file names for most of the dumps are made by appending
>>  a pass number and a word to the @var{dumpname}, and the files are
>> -created in the directory of the output file.  Note that the pass
>> -number is computed statically as passes get registered into the pass
>> -manager.  Thus the numbering is not related to the dynamic order of
>> -execution of passes.  In particular, a pass installed by a plugin
>> -could have a number over 200 even if it executed quite early.
>> -@var{dumpname} is generated from the name of the output file, if
>> -explicitly specified and it is not an executable, otherwise it is the
>> -basename of the source file. These switches may have different effects
>> -when @option{-E} is used for preprocessing.
>> +created in the directory of the output file. If the
>> +@option{=@var{filename}} is appended to the longer form of the dump
>> +option then the dump is done on that file instead of numbered
>> +files. Note that the pass number is computed statically as passes get
>> +registered into the pass manager.  Thus the numbering is not related
>> +to the dynamic order of execution of passes.  In particular, a pass
>> +installed by a plugin could have a number over 200 even if it executed
>> +quite early.  @var{dumpname} is generated from the name of the output
>> +file, if explicitly specified and it is not an executable, otherwise
>> +it is the basename of the source file. These switches may have
>> +different effects when @option{-E} is used for preprocessing.
>>
>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>  @option{-d} option @var{letters}.  Here are the possible
>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>
>>  @item -fdump-tree-@var{switch}
>>  @itemx -fdump-tree-@var{switch}-@var{options}
>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>  @opindex fdump-tree
>>  Control the dumping at various stages of processing the intermediate
>>  language tree to a file.  The file name is generated by appending a
>>  switch specific suffix to the source file name, and the file is
>> -created in the same directory as the output file.  If the
>> -@samp{-@var{options}} form is used, @var{options} is a list of
>> -@samp{-} separated options which control the details of the dump.  Not
>> -all options are applicable to all dumps; those that are not
>> -meaningful are ignored.  The following options are available
>> +created in the same directory as the output file. In case of
>> +@option{=@var{filename}} option, the dump is output on the given file
>> +name instead.  If the @samp{-@var{options}} form is used,
>> +@var{options} is a list of @samp{-} separated options which control
>> +the details or location of the dump.  Not all options are applicable
>> +to all dumps; those that are not meaningful are ignored.  The
>> +following options are available
>>
>>  @table @samp
>>  @item address
>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>  Enable showing the EH region number holding each statement.
>>  @item scev
>>  Enable showing scalar evolution analysis details.
>> +@item slim
>> +Inhibit dumping of members of a scope or body of a function merely
>> +because that scope has been reached.  Only dump such items when they
>> +are directly reachable by some other path.  When dumping pretty-printed
>> +trees, this option inhibits dumping the bodies of control structures.
>> +@item =@var{filename}
>> +Instead of using an auto generated dump file name, use the given file
>> +name. The file names @file{stdout} and @file{stderr} are treated
>> +specially and are considered already open standard streams. For
>> +example:
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>> +@end smallexample
>> +
>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>> +file named @file{ira.txt}.
>> +
>> +In case of any conflicts, the command line file name takes precedence
>> +over generated file names. For example:
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>> +@end smallexample
>> +
>> +Both of the above output the PRE dump on @file{stdout}. However, if
>> +there are multiple command line file names are applicable then the
>> +last one is used. Thus the command
>> +
>> +@smallexample
>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>> +@end smallexample
>> +
>> +outputs all the dumps in @file{all.txt} because the stderr option for
>> +PRE dump is overridden by a later option.
>> +
>>  @item all
>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>> -and @option{lineno}.
>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>> +@option{lineno}.
>>  @end table
>>
>>  The following tree dumps are possible:
>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>  @item all
>>  @opindex fdump-tree-all
>>  Enable all the available tree dumps with the flags provided in this option.
>> +
>>  @end table
>>
>>  @item -ftree-vectorizer-verbose=@var{n}
>> Index: tree-dump.c
>> ===================================================================
>> --- tree-dump.c (revision 187265)
>> +++ tree-dump.c (working copy)
>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>    tree_dump_index enumeration in tree-pass.h.  */
>>  static struct dump_file_info dump_files[TDI_end] =
>>  {
>> -  {NULL, NULL, NULL, 0, 0, 0},
>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>
>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>  };
>>
>>  /* Dynamically registered tree dump files and switches.  */
>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>  };
>>
>>  /* Table of dump options. This must be consistent with the TDF_* flags
>> -   in tree.h */
>> +   in tree-pass.h */
>>  static const struct dump_option_value_info dump_options[] =
>>  {
>>   {"address", TDF_ADDRESS},
>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>   if (dfi->state == 0)
>>     return NULL;
>>
>> +  if (dfi->filename)
>> +    return xstrdup (dfi->filename);
>> +
>>   if (dfi->num < 0)
>>     dump_id[0] = '\0';
>>   else
>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>  }
>>
>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>> +   return that stream, NULL otherwise.  */
>> +
>> +static FILE *
>> +dump_get_standard_stream (struct dump_file_info *dfi)
>> +{
>> +  if (!dfi->filename)
>> +    return NULL;
>> +
>> +  return strcmp("stderr", dfi->filename) == 0
>> +    ? stderr
>> +    : strcmp("stdout", dfi->filename) == 0
>> +    ?  stdout
>> +    : NULL;
>> +}
>> +
>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>    enabled, returns NULL.
>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>     return NULL;
>>
>> -  name = get_dump_file_name (phase);
>>   dfi = get_dump_file_info (phase);
>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> -  if (!stream)
>> -    error ("could not open dump file %qs: %m", name);
>> +  stream = dump_get_standard_stream (dfi);
>> +  if (stream)
>> +    dfi->state = 1;
>>   else
>> -    dfi->state = 1;
>> -  free (name);
>> +    {
>> +      name = get_dump_file_name (phase);
>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> +      if (!stream)
>> +        error ("could not open dump file %qs: %m", name);
>> +      else
>> +        dfi->state = 1;
>> +      free (name);
>> +    }
>>
>>   if (flag_ptr)
>>     *flag_ptr = dfi->flags;
>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>    dump_begin.  */
>>
>>  void
>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>> +dump_end (int phase, FILE *stream)
>>  {
>> -  fclose (stream);
>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>> +  if (!dump_get_standard_stream (dfi))
>> +    fclose (stream);
>>  }
>>
>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>> +   enabled tree dumps.  */
>>
>>  static int
>> -dump_enable_all (int flags)
>> +dump_enable_all (int flags, const char *filename)
>>  {
>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>   int n = 0;
>>   size_t i;
>>
>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -    if ((dump_files[i].flags & ir_dump_type))
>> -      {
>> -        dump_files[i].state = -1;
>> -        dump_files[i].flags |= flags;
>> -        n++;
>> -      }
>> +    {
>> +      if ((dump_files[i].flags & ir_dump_type))
>> +        {
>> +          dump_files[i].state = -1;
>> +          dump_files[i].flags |= flags;
>> +          n++;
>> +          if (filename)
>> +            dump_files[i].filename = xstrdup (filename);
>> +        }
>> +    }
>>
>>   for (i = 0; i < extra_dump_files_in_use; i++)
>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>> -      {
>> -        extra_dump_files[i].state = -1;
>> -        extra_dump_files[i].flags |= flags;
>> -       n++;
>> -      }
>> +    {
>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>> +        {
>> +          extra_dump_files[i].state = -1;
>> +          extra_dump_files[i].flags |= flags;
>> +          n++;
>> +          if (filename)
>> +            extra_dump_files[i].filename = xstrdup (filename);
>> +        }
>> +    }
>>
>>   return n;
>>  }
>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   if (!option_value)
>>     return 0;
>>
>> -  if (*option_value && *option_value != '-')
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>     return 0;
>>
>>   ptr = option_value;
>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>       while (*ptr == '-')
>>        ptr++;
>>       end_ptr = strchr (ptr, '-');
>> +
>>       if (!end_ptr)
>>        end_ptr = ptr + strlen (ptr);
>>       length = end_ptr - ptr;
>>
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  This
>> +             filename overrides generated dump names as well as other
>> +             command line filenames.  */
>> +          flags |= TDF_FILENAME;
>> +          if (dfi->filename)
>> +            free (dfi->filename);
>> +          dfi->filename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +
>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>        if (strlen (option_ptr->name) == length
>>            && !memcmp (option_ptr->name, ptr, length))
>> -         {
>> -           flags |= option_ptr->value;
>> +          {
>> +            flags |= option_ptr->value;
>>            goto found;
>> -         }
>> +          }
>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>               length, ptr, dfi->swtch);
>>     found:;
>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>      known dumps.  */
>>   if (dfi->suffix == NULL)
>> -    dump_enable_all (dfi->flags);
>> +    dump_enable_all (dfi->flags, dfi->filename);
>>
>>   return 1;
>>  }
>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>  bool
>>  enable_rtl_dump_file (void)
>>  {
>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>  }
>> Index: tree-pass.h
>> ===================================================================
>> --- tree-pass.h (revision 187265)
>> +++ tree-pass.h (working copy)
>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>> +                                           instead of constructing one. */
>>
>> -
>>  /* In tree-dump.c */
>>
>>  extern char *get_dump_file_name (int);
>> @@ -222,6 +223,8 @@ struct dump_file_info
>>   const char *suffix;           /* suffix to give output file.  */
>>   const char *swtch;            /* command line switch */
>>   const char *glob;             /* command line glob  */
>> +  const char *filename;         /* use this filename instead of making
>> +                                   up one using dump_base_name + suffix.  */
>>   int flags;                    /* user flags */
>>   int state;                    /* state of play */
>>   int num;                      /* dump file number */
>> Index: testsuite/g++.dg/other/dump-filename-1.C
>> ===================================================================
>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>> @@ -0,0 +1,11 @@
>> +// Test that the dump to a user-defined file works correctly.
>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>> +
>> +void test (int *b, int *e, int stride)
>> +  {
>> +    for (int *p = b; p != e; p += stride)
>> +      *p = 1;
>> +  }
>> +
>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>
>>
>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>> <gdr@integrable-solutions.net> wrote:
>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>> [...]
>>>
>>>> +@item -fdump-rtl-all=stderr
>>>> +@opindex fdump-rtl-all=stderr
>>>
>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>> Rather, expand the description to state this in all the documentation
>>> for -fdump-xxx=yyy.
>>>
>>> [...]
>>>
>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>> +   stderr stream.  */
>>>> +
>>>> +static int
>>>> +dump_stream_p (const char *user_filename)
>>>> +{
>>>> +  if (user_filename)
>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>> +      !strncmp ("stdout", user_filename, 6);
>>>> +  else
>>>> +    return 0;
>>>> +}
>>>
>>> The name is ambiguous.
>>> This function is testing whether its string argument designates one of
>>> the *standard* output streams.  Name it to reflect that..
>>> Have it take the dump state context. Also the coding convention: the binary
>>> operator "||" should be on next line.  In fact the thing could be
>>> simpler.   Instead of
>>> testing over and over again against "stderr" (once in this function, then again
>>> later), just return the corresponding standard FILE* pointer.
>>> Also, this is a case of overuse of strncmp.  If you name the function
>>> dump_get_standard_stream:
>>>
>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>       ? stderr
>>>        : stdcmp("stdout", dfi->use_filename)
>>>        ?  stdout
>>>        : NULL;
>>>
>>> you can simplify:
>>>
>>>> -  name = get_dump_file_name (phase);
>>>>   dfi = get_dump_file_info (phase);
>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>> -  if (!stream)
>>>> -    error ("could not open dump file %qs: %m", name);
>>>> +  if (dump_stream_p (dfi->user_filename))
>>>> +    {
>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>> +        stream = stderr;
>>>> +      else
>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>> +          stream = stdout;
>>>> +        else
>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>> +      dfi->state = 1;
>>>> +    }
>>>>   else
>>>> -    dfi->state = 1;
>>>> -  free (name);
>>>> +    {
>>>> +      name = get_dump_file_name (phase);
>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>> +      if (!stream)
>>>> +        error ("could not open dump file %qs: %m", name);
>>>> +      else
>>>> +        dfi->state = 1;
>>>> +      free (name);
>>>> +    }
>>>>
>>>>   if (flag_ptr)
>>>>     *flag_ptr = dfi->flags;
>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>    dump_begin.  */
>>>>
>>>>  void
>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>> +dump_end (int phase, FILE *stream)
>>>>  {
>>>> -  fclose (stream);
>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>> +    fclose (stream);
>>>>  }
>>>>
>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>
>>>>  static int
>>>> -dump_enable_all (int flags)
>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>  {
>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>   int n = 0;
>>>>   size_t i;
>>>>
>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>> -      {
>>>> -        dump_files[i].state = -1;
>>>> -        dump_files[i].flags |= flags;
>>>> -        n++;
>>>> -      }
>>>> +    {
>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>> +        {
>>>> +          dump_files[i].state = -1;
>>>> +          dump_files[i].flags |= flags;
>>>> +          n++;
>>>> +        }
>>>> +      if (user_filename)
>>>> +        dump_files[i].user_filename = user_filename;
>>>> +    }
>>>>
>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>> -      {
>>>> -        extra_dump_files[i].state = -1;
>>>> -        extra_dump_files[i].flags |= flags;
>>>> -       n++;
>>>> -      }
>>>> +    {
>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>> +        {
>>>> +          extra_dump_files[i].state = -1;
>>>> +          extra_dump_files[i].flags |= flags;
>>>> +          n++;
>>>> +        }
>>>> +      if (user_filename)
>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>> +    }
>>>>
>>>>   return n;
>>>>  }
>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>   if (!option_value)
>>>>     return 0;
>>>>
>>>> -  if (*option_value && *option_value != '-')
>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>     return 0;
>>>>
>>>>   ptr = option_value;
>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>       while (*ptr == '-')
>>>>        ptr++;
>>>>       end_ptr = strchr (ptr, '-');
>>>> +
>>>>       if (!end_ptr)
>>>>        end_ptr = ptr + strlen (ptr);
>>>>       length = end_ptr - ptr;
>>>>
>>>> +      if (*ptr == '=')
>>>> +        {
>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>> +             user provided filename overrides generated dump names as
>>>> +             well as other command line filenames.  */
>>>> +          flags |= TDF_USER_FILENAME;
>>>> +          if (dfi->user_filename)
>>>> +            free (dfi->user_filename);
>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>> +          break;
>>>> +        }
>>>> +
>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>        if (strlen (option_ptr->name) == length
>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>> -         {
>>>> -           flags |= option_ptr->value;
>>>> +          {
>>>> +            flags |= option_ptr->value;
>>>>            goto found;
>>>> -         }
>>>> +          }
>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>               length, ptr, dfi->swtch);
>>>>     found:;
>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>      known dumps.  */
>>>>   if (dfi->suffix == NULL)
>>>> -    dump_enable_all (dfi->flags);
>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>
>>>>   return 1;
>>>>  }
>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>  bool
>>>>  enable_rtl_dump_file (void)
>>>>  {
>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>  }
>>>> Index: tree-pass.h
>>>> ===================================================================
>>>> --- tree-pass.h (revision 187265)
>>>> +++ tree-pass.h (working copy)
>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>> +                                           instead of constructing one. */
>>>>
>>>> -
>>>>  /* In tree-dump.c */
>>>>
>>>>  extern char *get_dump_file_name (int);
>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>   const char *swtch;            /* command line switch */
>>>>   const char *glob;             /* command line glob  */
>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>> +                                   up one using dump_base_name + suffix.  */
>>>
>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>
>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-10  8:18       ` Richard Guenther
@ 2012-05-10 16:28         ` Xinliang David Li
  2012-05-11  8:49           ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-05-10 16:28 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

I like your suggestion and support the end goal you have.  I don't
like the -fopt-info behavior to interfere with regular -fdump-xxx
options either.

I think we should stage the changes in multiple steps as originally
planned. Is Sharad's change good to be checked in for the first stage?

After this one is checked in, the new dump interfaces will be worked
on (and to allow multiple streams). Most of the remaining changes will
be massive text replacement.

thanks,

David


On Thu, May 10, 2012 at 1:18 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
>> Bummer.  I was thinking to reserve '=' for selective  dumping:
>>
>> -fdump-tree-pre=<func_list_regexp>
>>
>> I guess this can be achieved via @
>>
>> -fdump-tree-pre@<func_list>
>>
>> -fdump-tree-pre=<file_name>@<func_list>
>>
>>
>> Another issue -- I don't think the current precedence rule is correct.
>> Consider that -fopt-info=2 will be mapped to
>>
>> -fdump-tree-all-transform-verbose2=stderr
>> -fdump-rtl-all-transform-verbose2=stderr
>>
>> then
>>
>> the current precedence rule will cause surprise when the following is used
>>
>> -fopt-info -fdump-tree-pre
>>
>> The PRE dump will be emitted to stderr which is not what user wants.
>> In short, special streams should be treated as 'weak' the same way as
>> your previous implementation.
>
> Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
> With -fopt-info -fdump-tree-pre I do not want some information to be
> present only on stderr or in the dump file!  I want it in _both_ places!
> (-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
> information :()
>
> Thus, the information where dumping goes has to be done differently
> (which is why I asked for some re-org originally, so that passes no
> longer explicitely reference dump_file - dump_file may be different
> for different kind of information it dumps!).  Passes should, instead of
>
>  fprintf (dump_file, "...", ...)
>
> do
>
>  dump_printf (TDF_scev, "...", ...)
>
> thus, specify the kind of information they dump (would be mostly
> TDF_details vs. 0 today I guess).  The dump_printf routine would
> then properly direct to one or more places to dump at.
>
> I realize this needs some more dispatchers for dumping expressions
> and statements (but it should not be too many).  Dumping to
> dump_file would in any case dump to the passes private dump file
> only (unqualified stuff would never be useful for -fopt-info).
>
> The perfect candidate to convert to this kind of scheme is obviously
> the vectorizer with its existing -fvectorizer-verbose.
>
> If the patch doesn't work towards this kind of end-result I'd rather
> not have it.
>
> Thanks,
> Richard.
>
>> thanks,
>>
>> David
>>
>>
>>
>> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>>> Thanks for your suggestions/comments. I have updated the patch and
>>> documentation. It supports the following usage:
>>>
>>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>>> -fdump-rtl-ira=ira.dump
>>>
>>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>>> goes to stdout and the IRA dump goes to ira.dump.
>>>
>>> Thanks,
>>> Sharad
>>>
>>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>>
>>>        * doc/invoke.texi: Add documentation for the new option.
>>>        * tree-dump.c (dump_get_standard_stream): New function.
>>>        (dump_files): Update for new field.
>>>        (dump_switch_p_1): Handle dump filenames.
>>>        (dump_begin): Likewise.
>>>        (get_dump_file_name): Likewise.
>>>        (dump_end): Remove attribute.
>>>        (dump_enable_all): Add new parameter FILENAME.
>>>        All callers updated.
>>>        (enable_rtl_dump_file):
>>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>>        (struct dump_file_info): Add new field FILENAME.
>>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>>
>>> Index: doc/invoke.texi
>>> ===================================================================
>>> --- doc/invoke.texi     (revision 187265)
>>> +++ doc/invoke.texi     (working copy)
>>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>>
>>>  @item -d@var{letters}
>>>  @itemx -fdump-rtl-@var{pass}
>>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>>  @opindex d
>>>  Says to make debugging dumps during compilation at times specified by
>>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>>  compiler.  The file names for most of the dumps are made by appending
>>>  a pass number and a word to the @var{dumpname}, and the files are
>>> -created in the directory of the output file.  Note that the pass
>>> -number is computed statically as passes get registered into the pass
>>> -manager.  Thus the numbering is not related to the dynamic order of
>>> -execution of passes.  In particular, a pass installed by a plugin
>>> -could have a number over 200 even if it executed quite early.
>>> -@var{dumpname} is generated from the name of the output file, if
>>> -explicitly specified and it is not an executable, otherwise it is the
>>> -basename of the source file. These switches may have different effects
>>> -when @option{-E} is used for preprocessing.
>>> +created in the directory of the output file. If the
>>> +@option{=@var{filename}} is appended to the longer form of the dump
>>> +option then the dump is done on that file instead of numbered
>>> +files. Note that the pass number is computed statically as passes get
>>> +registered into the pass manager.  Thus the numbering is not related
>>> +to the dynamic order of execution of passes.  In particular, a pass
>>> +installed by a plugin could have a number over 200 even if it executed
>>> +quite early.  @var{dumpname} is generated from the name of the output
>>> +file, if explicitly specified and it is not an executable, otherwise
>>> +it is the basename of the source file. These switches may have
>>> +different effects when @option{-E} is used for preprocessing.
>>>
>>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>>  @option{-d} option @var{letters}.  Here are the possible
>>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>>
>>>  @item -fdump-tree-@var{switch}
>>>  @itemx -fdump-tree-@var{switch}-@var{options}
>>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>>  @opindex fdump-tree
>>>  Control the dumping at various stages of processing the intermediate
>>>  language tree to a file.  The file name is generated by appending a
>>>  switch specific suffix to the source file name, and the file is
>>> -created in the same directory as the output file.  If the
>>> -@samp{-@var{options}} form is used, @var{options} is a list of
>>> -@samp{-} separated options which control the details of the dump.  Not
>>> -all options are applicable to all dumps; those that are not
>>> -meaningful are ignored.  The following options are available
>>> +created in the same directory as the output file. In case of
>>> +@option{=@var{filename}} option, the dump is output on the given file
>>> +name instead.  If the @samp{-@var{options}} form is used,
>>> +@var{options} is a list of @samp{-} separated options which control
>>> +the details or location of the dump.  Not all options are applicable
>>> +to all dumps; those that are not meaningful are ignored.  The
>>> +following options are available
>>>
>>>  @table @samp
>>>  @item address
>>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>>  Enable showing the EH region number holding each statement.
>>>  @item scev
>>>  Enable showing scalar evolution analysis details.
>>> +@item slim
>>> +Inhibit dumping of members of a scope or body of a function merely
>>> +because that scope has been reached.  Only dump such items when they
>>> +are directly reachable by some other path.  When dumping pretty-printed
>>> +trees, this option inhibits dumping the bodies of control structures.
>>> +@item =@var{filename}
>>> +Instead of using an auto generated dump file name, use the given file
>>> +name. The file names @file{stdout} and @file{stderr} are treated
>>> +specially and are considered already open standard streams. For
>>> +example:
>>> +
>>> +@smallexample
>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>>> +@end smallexample
>>> +
>>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>>> +file named @file{ira.txt}.
>>> +
>>> +In case of any conflicts, the command line file name takes precedence
>>> +over generated file names. For example:
>>> +
>>> +@smallexample
>>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>>> +@end smallexample
>>> +
>>> +Both of the above output the PRE dump on @file{stdout}. However, if
>>> +there are multiple command line file names are applicable then the
>>> +last one is used. Thus the command
>>> +
>>> +@smallexample
>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>>> +@end smallexample
>>> +
>>> +outputs all the dumps in @file{all.txt} because the stderr option for
>>> +PRE dump is overridden by a later option.
>>> +
>>>  @item all
>>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>> -and @option{lineno}.
>>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>>> +@option{lineno}.
>>>  @end table
>>>
>>>  The following tree dumps are possible:
>>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>>  @item all
>>>  @opindex fdump-tree-all
>>>  Enable all the available tree dumps with the flags provided in this option.
>>> +
>>>  @end table
>>>
>>>  @item -ftree-vectorizer-verbose=@var{n}
>>> Index: tree-dump.c
>>> ===================================================================
>>> --- tree-dump.c (revision 187265)
>>> +++ tree-dump.c (working copy)
>>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>>    tree_dump_index enumeration in tree-pass.h.  */
>>>  static struct dump_file_info dump_files[TDI_end] =
>>>  {
>>> -  {NULL, NULL, NULL, 0, 0, 0},
>>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>>
>>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>>  };
>>>
>>>  /* Dynamically registered tree dump files and switches.  */
>>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>>  };
>>>
>>>  /* Table of dump options. This must be consistent with the TDF_* flags
>>> -   in tree.h */
>>> +   in tree-pass.h */
>>>  static const struct dump_option_value_info dump_options[] =
>>>  {
>>>   {"address", TDF_ADDRESS},
>>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>>   if (dfi->state == 0)
>>>     return NULL;
>>>
>>> +  if (dfi->filename)
>>> +    return xstrdup (dfi->filename);
>>> +
>>>   if (dfi->num < 0)
>>>     dump_id[0] = '\0';
>>>   else
>>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>>  }
>>>
>>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>>> +   return that stream, NULL otherwise.  */
>>> +
>>> +static FILE *
>>> +dump_get_standard_stream (struct dump_file_info *dfi)
>>> +{
>>> +  if (!dfi->filename)
>>> +    return NULL;
>>> +
>>> +  return strcmp("stderr", dfi->filename) == 0
>>> +    ? stderr
>>> +    : strcmp("stdout", dfi->filename) == 0
>>> +    ?  stdout
>>> +    : NULL;
>>> +}
>>> +
>>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>>    enabled, returns NULL.
>>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>>     return NULL;
>>>
>>> -  name = get_dump_file_name (phase);
>>>   dfi = get_dump_file_info (phase);
>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>> -  if (!stream)
>>> -    error ("could not open dump file %qs: %m", name);
>>> +  stream = dump_get_standard_stream (dfi);
>>> +  if (stream)
>>> +    dfi->state = 1;
>>>   else
>>> -    dfi->state = 1;
>>> -  free (name);
>>> +    {
>>> +      name = get_dump_file_name (phase);
>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>> +      if (!stream)
>>> +        error ("could not open dump file %qs: %m", name);
>>> +      else
>>> +        dfi->state = 1;
>>> +      free (name);
>>> +    }
>>>
>>>   if (flag_ptr)
>>>     *flag_ptr = dfi->flags;
>>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>>    dump_begin.  */
>>>
>>>  void
>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>> +dump_end (int phase, FILE *stream)
>>>  {
>>> -  fclose (stream);
>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>> +  if (!dump_get_standard_stream (dfi))
>>> +    fclose (stream);
>>>  }
>>>
>>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>>> +   enabled tree dumps.  */
>>>
>>>  static int
>>> -dump_enable_all (int flags)
>>> +dump_enable_all (int flags, const char *filename)
>>>  {
>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>   int n = 0;
>>>   size_t i;
>>>
>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>> -    if ((dump_files[i].flags & ir_dump_type))
>>> -      {
>>> -        dump_files[i].state = -1;
>>> -        dump_files[i].flags |= flags;
>>> -        n++;
>>> -      }
>>> +    {
>>> +      if ((dump_files[i].flags & ir_dump_type))
>>> +        {
>>> +          dump_files[i].state = -1;
>>> +          dump_files[i].flags |= flags;
>>> +          n++;
>>> +          if (filename)
>>> +            dump_files[i].filename = xstrdup (filename);
>>> +        }
>>> +    }
>>>
>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>> -      {
>>> -        extra_dump_files[i].state = -1;
>>> -        extra_dump_files[i].flags |= flags;
>>> -       n++;
>>> -      }
>>> +    {
>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>> +        {
>>> +          extra_dump_files[i].state = -1;
>>> +          extra_dump_files[i].flags |= flags;
>>> +          n++;
>>> +          if (filename)
>>> +            extra_dump_files[i].filename = xstrdup (filename);
>>> +        }
>>> +    }
>>>
>>>   return n;
>>>  }
>>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>   if (!option_value)
>>>     return 0;
>>>
>>> -  if (*option_value && *option_value != '-')
>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>     return 0;
>>>
>>>   ptr = option_value;
>>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>       while (*ptr == '-')
>>>        ptr++;
>>>       end_ptr = strchr (ptr, '-');
>>> +
>>>       if (!end_ptr)
>>>        end_ptr = ptr + strlen (ptr);
>>>       length = end_ptr - ptr;
>>>
>>> +      if (*ptr == '=')
>>> +        {
>>> +          /* Interpret rest of the argument as a dump filename.  This
>>> +             filename overrides generated dump names as well as other
>>> +             command line filenames.  */
>>> +          flags |= TDF_FILENAME;
>>> +          if (dfi->filename)
>>> +            free (dfi->filename);
>>> +          dfi->filename = xstrdup (ptr + 1);
>>> +          break;
>>> +        }
>>> +
>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>        if (strlen (option_ptr->name) == length
>>>            && !memcmp (option_ptr->name, ptr, length))
>>> -         {
>>> -           flags |= option_ptr->value;
>>> +          {
>>> +            flags |= option_ptr->value;
>>>            goto found;
>>> -         }
>>> +          }
>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>               length, ptr, dfi->swtch);
>>>     found:;
>>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>      known dumps.  */
>>>   if (dfi->suffix == NULL)
>>> -    dump_enable_all (dfi->flags);
>>> +    dump_enable_all (dfi->flags, dfi->filename);
>>>
>>>   return 1;
>>>  }
>>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>>  bool
>>>  enable_rtl_dump_file (void)
>>>  {
>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>  }
>>> Index: tree-pass.h
>>> ===================================================================
>>> --- tree-pass.h (revision 187265)
>>> +++ tree-pass.h (working copy)
>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>>> +                                           instead of constructing one. */
>>>
>>> -
>>>  /* In tree-dump.c */
>>>
>>>  extern char *get_dump_file_name (int);
>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>   const char *suffix;           /* suffix to give output file.  */
>>>   const char *swtch;            /* command line switch */
>>>   const char *glob;             /* command line glob  */
>>> +  const char *filename;         /* use this filename instead of making
>>> +                                   up one using dump_base_name + suffix.  */
>>>   int flags;                    /* user flags */
>>>   int state;                    /* state of play */
>>>   int num;                      /* dump file number */
>>> Index: testsuite/g++.dg/other/dump-filename-1.C
>>> ===================================================================
>>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>> @@ -0,0 +1,11 @@
>>> +// Test that the dump to a user-defined file works correctly.
>>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>>> +
>>> +void test (int *b, int *e, int stride)
>>> +  {
>>> +    for (int *p = b; p != e; p += stride)
>>> +      *p = 1;
>>> +  }
>>> +
>>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>>
>>>
>>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>>> <gdr@integrable-solutions.net> wrote:
>>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>>> [...]
>>>>
>>>>> +@item -fdump-rtl-all=stderr
>>>>> +@opindex fdump-rtl-all=stderr
>>>>
>>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>>> Rather, expand the description to state this in all the documentation
>>>> for -fdump-xxx=yyy.
>>>>
>>>> [...]
>>>>
>>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>>> +   stderr stream.  */
>>>>> +
>>>>> +static int
>>>>> +dump_stream_p (const char *user_filename)
>>>>> +{
>>>>> +  if (user_filename)
>>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>>> +      !strncmp ("stdout", user_filename, 6);
>>>>> +  else
>>>>> +    return 0;
>>>>> +}
>>>>
>>>> The name is ambiguous.
>>>> This function is testing whether its string argument designates one of
>>>> the *standard* output streams.  Name it to reflect that..
>>>> Have it take the dump state context. Also the coding convention: the binary
>>>> operator "||" should be on next line.  In fact the thing could be
>>>> simpler.   Instead of
>>>> testing over and over again against "stderr" (once in this function, then again
>>>> later), just return the corresponding standard FILE* pointer.
>>>> Also, this is a case of overuse of strncmp.  If you name the function
>>>> dump_get_standard_stream:
>>>>
>>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>>       ? stderr
>>>>        : stdcmp("stdout", dfi->use_filename)
>>>>        ?  stdout
>>>>        : NULL;
>>>>
>>>> you can simplify:
>>>>
>>>>> -  name = get_dump_file_name (phase);
>>>>>   dfi = get_dump_file_info (phase);
>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>> -  if (!stream)
>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>> +  if (dump_stream_p (dfi->user_filename))
>>>>> +    {
>>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>>> +        stream = stderr;
>>>>> +      else
>>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>>> +          stream = stdout;
>>>>> +        else
>>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>>> +      dfi->state = 1;
>>>>> +    }
>>>>>   else
>>>>> -    dfi->state = 1;
>>>>> -  free (name);
>>>>> +    {
>>>>> +      name = get_dump_file_name (phase);
>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>> +      if (!stream)
>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>> +      else
>>>>> +        dfi->state = 1;
>>>>> +      free (name);
>>>>> +    }
>>>>>
>>>>>   if (flag_ptr)
>>>>>     *flag_ptr = dfi->flags;
>>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>>    dump_begin.  */
>>>>>
>>>>>  void
>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>> +dump_end (int phase, FILE *stream)
>>>>>  {
>>>>> -  fclose (stream);
>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>>> +    fclose (stream);
>>>>>  }
>>>>>
>>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>
>>>>>  static int
>>>>> -dump_enable_all (int flags)
>>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>>  {
>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>   int n = 0;
>>>>>   size_t i;
>>>>>
>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>> -      {
>>>>> -        dump_files[i].state = -1;
>>>>> -        dump_files[i].flags |= flags;
>>>>> -        n++;
>>>>> -      }
>>>>> +    {
>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>> +        {
>>>>> +          dump_files[i].state = -1;
>>>>> +          dump_files[i].flags |= flags;
>>>>> +          n++;
>>>>> +        }
>>>>> +      if (user_filename)
>>>>> +        dump_files[i].user_filename = user_filename;
>>>>> +    }
>>>>>
>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>> -      {
>>>>> -        extra_dump_files[i].state = -1;
>>>>> -        extra_dump_files[i].flags |= flags;
>>>>> -       n++;
>>>>> -      }
>>>>> +    {
>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>> +        {
>>>>> +          extra_dump_files[i].state = -1;
>>>>> +          extra_dump_files[i].flags |= flags;
>>>>> +          n++;
>>>>> +        }
>>>>> +      if (user_filename)
>>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>>> +    }
>>>>>
>>>>>   return n;
>>>>>  }
>>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>   if (!option_value)
>>>>>     return 0;
>>>>>
>>>>> -  if (*option_value && *option_value != '-')
>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>     return 0;
>>>>>
>>>>>   ptr = option_value;
>>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>       while (*ptr == '-')
>>>>>        ptr++;
>>>>>       end_ptr = strchr (ptr, '-');
>>>>> +
>>>>>       if (!end_ptr)
>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>       length = end_ptr - ptr;
>>>>>
>>>>> +      if (*ptr == '=')
>>>>> +        {
>>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>>> +             user provided filename overrides generated dump names as
>>>>> +             well as other command line filenames.  */
>>>>> +          flags |= TDF_USER_FILENAME;
>>>>> +          if (dfi->user_filename)
>>>>> +            free (dfi->user_filename);
>>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>>> +          break;
>>>>> +        }
>>>>> +
>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>        if (strlen (option_ptr->name) == length
>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>> -         {
>>>>> -           flags |= option_ptr->value;
>>>>> +          {
>>>>> +            flags |= option_ptr->value;
>>>>>            goto found;
>>>>> -         }
>>>>> +          }
>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>               length, ptr, dfi->swtch);
>>>>>     found:;
>>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>      known dumps.  */
>>>>>   if (dfi->suffix == NULL)
>>>>> -    dump_enable_all (dfi->flags);
>>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>>
>>>>>   return 1;
>>>>>  }
>>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>>  bool
>>>>>  enable_rtl_dump_file (void)
>>>>>  {
>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>  }
>>>>> Index: tree-pass.h
>>>>> ===================================================================
>>>>> --- tree-pass.h (revision 187265)
>>>>> +++ tree-pass.h (working copy)
>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>>> +                                           instead of constructing one. */
>>>>>
>>>>> -
>>>>>  /* In tree-dump.c */
>>>>>
>>>>>  extern char *get_dump_file_name (int);
>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>   const char *swtch;            /* command line switch */
>>>>>   const char *glob;             /* command line glob  */
>>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>
>>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>>
>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-10 16:28         ` Xinliang David Li
@ 2012-05-11  8:49           ` Richard Guenther
  2012-05-11 16:07             ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-05-11  8:49 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

On Thu, May 10, 2012 at 6:28 PM, Xinliang David Li <davidxl@google.com> wrote:
> I like your suggestion and support the end goal you have.  I don't
> like the -fopt-info behavior to interfere with regular -fdump-xxx
> options either.
>
> I think we should stage the changes in multiple steps as originally
> planned. Is Sharad's change good to be checked in for the first stage?

Well - I don't think the change walks in the direction we want to go, so I don't
see a good reason to make that change.

> After this one is checked in, the new dump interfaces will be worked
> on (and to allow multiple streams). Most of the remaining changes will
> be massive text replacement.
>
> thanks,
>
> David
>
>
> On Thu, May 10, 2012 at 1:18 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
>>> Bummer.  I was thinking to reserve '=' for selective  dumping:
>>>
>>> -fdump-tree-pre=<func_list_regexp>
>>>
>>> I guess this can be achieved via @
>>>
>>> -fdump-tree-pre@<func_list>
>>>
>>> -fdump-tree-pre=<file_name>@<func_list>
>>>
>>>
>>> Another issue -- I don't think the current precedence rule is correct.
>>> Consider that -fopt-info=2 will be mapped to
>>>
>>> -fdump-tree-all-transform-verbose2=stderr
>>> -fdump-rtl-all-transform-verbose2=stderr
>>>
>>> then
>>>
>>> the current precedence rule will cause surprise when the following is used
>>>
>>> -fopt-info -fdump-tree-pre
>>>
>>> The PRE dump will be emitted to stderr which is not what user wants.
>>> In short, special streams should be treated as 'weak' the same way as
>>> your previous implementation.
>>
>> Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
>> With -fopt-info -fdump-tree-pre I do not want some information to be
>> present only on stderr or in the dump file!  I want it in _both_ places!
>> (-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
>> information :()
>>
>> Thus, the information where dumping goes has to be done differently
>> (which is why I asked for some re-org originally, so that passes no
>> longer explicitely reference dump_file - dump_file may be different
>> for different kind of information it dumps!).  Passes should, instead of
>>
>>  fprintf (dump_file, "...", ...)
>>
>> do
>>
>>  dump_printf (TDF_scev, "...", ...)
>>
>> thus, specify the kind of information they dump (would be mostly
>> TDF_details vs. 0 today I guess).  The dump_printf routine would
>> then properly direct to one or more places to dump at.
>>
>> I realize this needs some more dispatchers for dumping expressions
>> and statements (but it should not be too many).  Dumping to
>> dump_file would in any case dump to the passes private dump file
>> only (unqualified stuff would never be useful for -fopt-info).
>>
>> The perfect candidate to convert to this kind of scheme is obviously
>> the vectorizer with its existing -fvectorizer-verbose.
>>
>> If the patch doesn't work towards this kind of end-result I'd rather
>> not have it.
>>
>> Thanks,
>> Richard.
>>
>>> thanks,
>>>
>>> David
>>>
>>>
>>>
>>> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>>>> Thanks for your suggestions/comments. I have updated the patch and
>>>> documentation. It supports the following usage:
>>>>
>>>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>>>> -fdump-rtl-ira=ira.dump
>>>>
>>>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>>>> goes to stdout and the IRA dump goes to ira.dump.
>>>>
>>>> Thanks,
>>>> Sharad
>>>>
>>>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>>>
>>>>        * doc/invoke.texi: Add documentation for the new option.
>>>>        * tree-dump.c (dump_get_standard_stream): New function.
>>>>        (dump_files): Update for new field.
>>>>        (dump_switch_p_1): Handle dump filenames.
>>>>        (dump_begin): Likewise.
>>>>        (get_dump_file_name): Likewise.
>>>>        (dump_end): Remove attribute.
>>>>        (dump_enable_all): Add new parameter FILENAME.
>>>>        All callers updated.
>>>>        (enable_rtl_dump_file):
>>>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>>>        (struct dump_file_info): Add new field FILENAME.
>>>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>>>
>>>> Index: doc/invoke.texi
>>>> ===================================================================
>>>> --- doc/invoke.texi     (revision 187265)
>>>> +++ doc/invoke.texi     (working copy)
>>>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>>>
>>>>  @item -d@var{letters}
>>>>  @itemx -fdump-rtl-@var{pass}
>>>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>>>  @opindex d
>>>>  Says to make debugging dumps during compilation at times specified by
>>>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>>>  compiler.  The file names for most of the dumps are made by appending
>>>>  a pass number and a word to the @var{dumpname}, and the files are
>>>> -created in the directory of the output file.  Note that the pass
>>>> -number is computed statically as passes get registered into the pass
>>>> -manager.  Thus the numbering is not related to the dynamic order of
>>>> -execution of passes.  In particular, a pass installed by a plugin
>>>> -could have a number over 200 even if it executed quite early.
>>>> -@var{dumpname} is generated from the name of the output file, if
>>>> -explicitly specified and it is not an executable, otherwise it is the
>>>> -basename of the source file. These switches may have different effects
>>>> -when @option{-E} is used for preprocessing.
>>>> +created in the directory of the output file. If the
>>>> +@option{=@var{filename}} is appended to the longer form of the dump
>>>> +option then the dump is done on that file instead of numbered
>>>> +files. Note that the pass number is computed statically as passes get
>>>> +registered into the pass manager.  Thus the numbering is not related
>>>> +to the dynamic order of execution of passes.  In particular, a pass
>>>> +installed by a plugin could have a number over 200 even if it executed
>>>> +quite early.  @var{dumpname} is generated from the name of the output
>>>> +file, if explicitly specified and it is not an executable, otherwise
>>>> +it is the basename of the source file. These switches may have
>>>> +different effects when @option{-E} is used for preprocessing.
>>>>
>>>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>>>  @option{-d} option @var{letters}.  Here are the possible
>>>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>>>
>>>>  @item -fdump-tree-@var{switch}
>>>>  @itemx -fdump-tree-@var{switch}-@var{options}
>>>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>>>  @opindex fdump-tree
>>>>  Control the dumping at various stages of processing the intermediate
>>>>  language tree to a file.  The file name is generated by appending a
>>>>  switch specific suffix to the source file name, and the file is
>>>> -created in the same directory as the output file.  If the
>>>> -@samp{-@var{options}} form is used, @var{options} is a list of
>>>> -@samp{-} separated options which control the details of the dump.  Not
>>>> -all options are applicable to all dumps; those that are not
>>>> -meaningful are ignored.  The following options are available
>>>> +created in the same directory as the output file. In case of
>>>> +@option{=@var{filename}} option, the dump is output on the given file
>>>> +name instead.  If the @samp{-@var{options}} form is used,
>>>> +@var{options} is a list of @samp{-} separated options which control
>>>> +the details or location of the dump.  Not all options are applicable
>>>> +to all dumps; those that are not meaningful are ignored.  The
>>>> +following options are available
>>>>
>>>>  @table @samp
>>>>  @item address
>>>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>>>  Enable showing the EH region number holding each statement.
>>>>  @item scev
>>>>  Enable showing scalar evolution analysis details.
>>>> +@item slim
>>>> +Inhibit dumping of members of a scope or body of a function merely
>>>> +because that scope has been reached.  Only dump such items when they
>>>> +are directly reachable by some other path.  When dumping pretty-printed
>>>> +trees, this option inhibits dumping the bodies of control structures.
>>>> +@item =@var{filename}
>>>> +Instead of using an auto generated dump file name, use the given file
>>>> +name. The file names @file{stdout} and @file{stderr} are treated
>>>> +specially and are considered already open standard streams. For
>>>> +example:
>>>> +
>>>> +@smallexample
>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>>>> +@end smallexample
>>>> +
>>>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>>>> +file named @file{ira.txt}.
>>>> +
>>>> +In case of any conflicts, the command line file name takes precedence
>>>> +over generated file names. For example:
>>>> +
>>>> +@smallexample
>>>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>>>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>>>> +@end smallexample
>>>> +
>>>> +Both of the above output the PRE dump on @file{stdout}. However, if
>>>> +there are multiple command line file names are applicable then the
>>>> +last one is used. Thus the command
>>>> +
>>>> +@smallexample
>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>>>> +@end smallexample
>>>> +
>>>> +outputs all the dumps in @file{all.txt} because the stderr option for
>>>> +PRE dump is overridden by a later option.
>>>> +
>>>>  @item all
>>>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>>> -and @option{lineno}.
>>>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>>>> +@option{lineno}.
>>>>  @end table
>>>>
>>>>  The following tree dumps are possible:
>>>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>>>  @item all
>>>>  @opindex fdump-tree-all
>>>>  Enable all the available tree dumps with the flags provided in this option.
>>>> +
>>>>  @end table
>>>>
>>>>  @item -ftree-vectorizer-verbose=@var{n}
>>>> Index: tree-dump.c
>>>> ===================================================================
>>>> --- tree-dump.c (revision 187265)
>>>> +++ tree-dump.c (working copy)
>>>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>>>    tree_dump_index enumeration in tree-pass.h.  */
>>>>  static struct dump_file_info dump_files[TDI_end] =
>>>>  {
>>>> -  {NULL, NULL, NULL, 0, 0, 0},
>>>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>>>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>>>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>>>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>>>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>>>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>>>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>>>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>>>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>>>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>>>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>>>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>>>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>>>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>>>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>>>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>>>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>>>
>>>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>>>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>>>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>>>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>>>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>>>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>>>  };
>>>>
>>>>  /* Dynamically registered tree dump files and switches.  */
>>>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>>>  };
>>>>
>>>>  /* Table of dump options. This must be consistent with the TDF_* flags
>>>> -   in tree.h */
>>>> +   in tree-pass.h */
>>>>  static const struct dump_option_value_info dump_options[] =
>>>>  {
>>>>   {"address", TDF_ADDRESS},
>>>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>>>   if (dfi->state == 0)
>>>>     return NULL;
>>>>
>>>> +  if (dfi->filename)
>>>> +    return xstrdup (dfi->filename);
>>>> +
>>>>   if (dfi->num < 0)
>>>>     dump_id[0] = '\0';
>>>>   else
>>>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>>>  }
>>>>
>>>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>>>> +   return that stream, NULL otherwise.  */
>>>> +
>>>> +static FILE *
>>>> +dump_get_standard_stream (struct dump_file_info *dfi)
>>>> +{
>>>> +  if (!dfi->filename)
>>>> +    return NULL;
>>>> +
>>>> +  return strcmp("stderr", dfi->filename) == 0
>>>> +    ? stderr
>>>> +    : strcmp("stdout", dfi->filename) == 0
>>>> +    ?  stdout
>>>> +    : NULL;
>>>> +}
>>>> +
>>>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>>>    enabled, returns NULL.
>>>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>>>     return NULL;
>>>>
>>>> -  name = get_dump_file_name (phase);
>>>>   dfi = get_dump_file_info (phase);
>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>> -  if (!stream)
>>>> -    error ("could not open dump file %qs: %m", name);
>>>> +  stream = dump_get_standard_stream (dfi);
>>>> +  if (stream)
>>>> +    dfi->state = 1;
>>>>   else
>>>> -    dfi->state = 1;
>>>> -  free (name);
>>>> +    {
>>>> +      name = get_dump_file_name (phase);
>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>> +      if (!stream)
>>>> +        error ("could not open dump file %qs: %m", name);
>>>> +      else
>>>> +        dfi->state = 1;
>>>> +      free (name);
>>>> +    }
>>>>
>>>>   if (flag_ptr)
>>>>     *flag_ptr = dfi->flags;
>>>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>>>    dump_begin.  */
>>>>
>>>>  void
>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>> +dump_end (int phase, FILE *stream)
>>>>  {
>>>> -  fclose (stream);
>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>> +  if (!dump_get_standard_stream (dfi))
>>>> +    fclose (stream);
>>>>  }
>>>>
>>>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>>>> +   enabled tree dumps.  */
>>>>
>>>>  static int
>>>> -dump_enable_all (int flags)
>>>> +dump_enable_all (int flags, const char *filename)
>>>>  {
>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>   int n = 0;
>>>>   size_t i;
>>>>
>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>> -      {
>>>> -        dump_files[i].state = -1;
>>>> -        dump_files[i].flags |= flags;
>>>> -        n++;
>>>> -      }
>>>> +    {
>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>> +        {
>>>> +          dump_files[i].state = -1;
>>>> +          dump_files[i].flags |= flags;
>>>> +          n++;
>>>> +          if (filename)
>>>> +            dump_files[i].filename = xstrdup (filename);
>>>> +        }
>>>> +    }
>>>>
>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>> -      {
>>>> -        extra_dump_files[i].state = -1;
>>>> -        extra_dump_files[i].flags |= flags;
>>>> -       n++;
>>>> -      }
>>>> +    {
>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>> +        {
>>>> +          extra_dump_files[i].state = -1;
>>>> +          extra_dump_files[i].flags |= flags;
>>>> +          n++;
>>>> +          if (filename)
>>>> +            extra_dump_files[i].filename = xstrdup (filename);
>>>> +        }
>>>> +    }
>>>>
>>>>   return n;
>>>>  }
>>>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>   if (!option_value)
>>>>     return 0;
>>>>
>>>> -  if (*option_value && *option_value != '-')
>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>     return 0;
>>>>
>>>>   ptr = option_value;
>>>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>       while (*ptr == '-')
>>>>        ptr++;
>>>>       end_ptr = strchr (ptr, '-');
>>>> +
>>>>       if (!end_ptr)
>>>>        end_ptr = ptr + strlen (ptr);
>>>>       length = end_ptr - ptr;
>>>>
>>>> +      if (*ptr == '=')
>>>> +        {
>>>> +          /* Interpret rest of the argument as a dump filename.  This
>>>> +             filename overrides generated dump names as well as other
>>>> +             command line filenames.  */
>>>> +          flags |= TDF_FILENAME;
>>>> +          if (dfi->filename)
>>>> +            free (dfi->filename);
>>>> +          dfi->filename = xstrdup (ptr + 1);
>>>> +          break;
>>>> +        }
>>>> +
>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>        if (strlen (option_ptr->name) == length
>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>> -         {
>>>> -           flags |= option_ptr->value;
>>>> +          {
>>>> +            flags |= option_ptr->value;
>>>>            goto found;
>>>> -         }
>>>> +          }
>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>               length, ptr, dfi->swtch);
>>>>     found:;
>>>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>      known dumps.  */
>>>>   if (dfi->suffix == NULL)
>>>> -    dump_enable_all (dfi->flags);
>>>> +    dump_enable_all (dfi->flags, dfi->filename);
>>>>
>>>>   return 1;
>>>>  }
>>>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>>>  bool
>>>>  enable_rtl_dump_file (void)
>>>>  {
>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>  }
>>>> Index: tree-pass.h
>>>> ===================================================================
>>>> --- tree-pass.h (revision 187265)
>>>> +++ tree-pass.h (working copy)
>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>>>> +                                           instead of constructing one. */
>>>>
>>>> -
>>>>  /* In tree-dump.c */
>>>>
>>>>  extern char *get_dump_file_name (int);
>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>   const char *swtch;            /* command line switch */
>>>>   const char *glob;             /* command line glob  */
>>>> +  const char *filename;         /* use this filename instead of making
>>>> +                                   up one using dump_base_name + suffix.  */
>>>>   int flags;                    /* user flags */
>>>>   int state;                    /* state of play */
>>>>   int num;                      /* dump file number */
>>>> Index: testsuite/g++.dg/other/dump-filename-1.C
>>>> ===================================================================
>>>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>> @@ -0,0 +1,11 @@
>>>> +// Test that the dump to a user-defined file works correctly.
>>>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>>>> +
>>>> +void test (int *b, int *e, int stride)
>>>> +  {
>>>> +    for (int *p = b; p != e; p += stride)
>>>> +      *p = 1;
>>>> +  }
>>>> +
>>>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>>>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>>>
>>>>
>>>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>>>> <gdr@integrable-solutions.net> wrote:
>>>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>> [...]
>>>>>
>>>>>> +@item -fdump-rtl-all=stderr
>>>>>> +@opindex fdump-rtl-all=stderr
>>>>>
>>>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>>>> Rather, expand the description to state this in all the documentation
>>>>> for -fdump-xxx=yyy.
>>>>>
>>>>> [...]
>>>>>
>>>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>>>> +   stderr stream.  */
>>>>>> +
>>>>>> +static int
>>>>>> +dump_stream_p (const char *user_filename)
>>>>>> +{
>>>>>> +  if (user_filename)
>>>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>>>> +      !strncmp ("stdout", user_filename, 6);
>>>>>> +  else
>>>>>> +    return 0;
>>>>>> +}
>>>>>
>>>>> The name is ambiguous.
>>>>> This function is testing whether its string argument designates one of
>>>>> the *standard* output streams.  Name it to reflect that..
>>>>> Have it take the dump state context. Also the coding convention: the binary
>>>>> operator "||" should be on next line.  In fact the thing could be
>>>>> simpler.   Instead of
>>>>> testing over and over again against "stderr" (once in this function, then again
>>>>> later), just return the corresponding standard FILE* pointer.
>>>>> Also, this is a case of overuse of strncmp.  If you name the function
>>>>> dump_get_standard_stream:
>>>>>
>>>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>>>       ? stderr
>>>>>        : stdcmp("stdout", dfi->use_filename)
>>>>>        ?  stdout
>>>>>        : NULL;
>>>>>
>>>>> you can simplify:
>>>>>
>>>>>> -  name = get_dump_file_name (phase);
>>>>>>   dfi = get_dump_file_info (phase);
>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>> -  if (!stream)
>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>> +  if (dump_stream_p (dfi->user_filename))
>>>>>> +    {
>>>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>>>> +        stream = stderr;
>>>>>> +      else
>>>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>>>> +          stream = stdout;
>>>>>> +        else
>>>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>>>> +      dfi->state = 1;
>>>>>> +    }
>>>>>>   else
>>>>>> -    dfi->state = 1;
>>>>>> -  free (name);
>>>>>> +    {
>>>>>> +      name = get_dump_file_name (phase);
>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>> +      if (!stream)
>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>> +      else
>>>>>> +        dfi->state = 1;
>>>>>> +      free (name);
>>>>>> +    }
>>>>>>
>>>>>>   if (flag_ptr)
>>>>>>     *flag_ptr = dfi->flags;
>>>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>>>    dump_begin.  */
>>>>>>
>>>>>>  void
>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>  {
>>>>>> -  fclose (stream);
>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>>>> +    fclose (stream);
>>>>>>  }
>>>>>>
>>>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>
>>>>>>  static int
>>>>>> -dump_enable_all (int flags)
>>>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>>>  {
>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>   int n = 0;
>>>>>>   size_t i;
>>>>>>
>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>> -      {
>>>>>> -        dump_files[i].state = -1;
>>>>>> -        dump_files[i].flags |= flags;
>>>>>> -        n++;
>>>>>> -      }
>>>>>> +    {
>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>> +        {
>>>>>> +          dump_files[i].state = -1;
>>>>>> +          dump_files[i].flags |= flags;
>>>>>> +          n++;
>>>>>> +        }
>>>>>> +      if (user_filename)
>>>>>> +        dump_files[i].user_filename = user_filename;
>>>>>> +    }
>>>>>>
>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>> -      {
>>>>>> -        extra_dump_files[i].state = -1;
>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>> -       n++;
>>>>>> -      }
>>>>>> +    {
>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>> +        {
>>>>>> +          extra_dump_files[i].state = -1;
>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>> +          n++;
>>>>>> +        }
>>>>>> +      if (user_filename)
>>>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>>>> +    }
>>>>>>
>>>>>>   return n;
>>>>>>  }
>>>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>   if (!option_value)
>>>>>>     return 0;
>>>>>>
>>>>>> -  if (*option_value && *option_value != '-')
>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>     return 0;
>>>>>>
>>>>>>   ptr = option_value;
>>>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>       while (*ptr == '-')
>>>>>>        ptr++;
>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>> +
>>>>>>       if (!end_ptr)
>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>       length = end_ptr - ptr;
>>>>>>
>>>>>> +      if (*ptr == '=')
>>>>>> +        {
>>>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>>>> +             user provided filename overrides generated dump names as
>>>>>> +             well as other command line filenames.  */
>>>>>> +          flags |= TDF_USER_FILENAME;
>>>>>> +          if (dfi->user_filename)
>>>>>> +            free (dfi->user_filename);
>>>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>>>> +          break;
>>>>>> +        }
>>>>>> +
>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>> -         {
>>>>>> -           flags |= option_ptr->value;
>>>>>> +          {
>>>>>> +            flags |= option_ptr->value;
>>>>>>            goto found;
>>>>>> -         }
>>>>>> +          }
>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>               length, ptr, dfi->swtch);
>>>>>>     found:;
>>>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>      known dumps.  */
>>>>>>   if (dfi->suffix == NULL)
>>>>>> -    dump_enable_all (dfi->flags);
>>>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>>>
>>>>>>   return 1;
>>>>>>  }
>>>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>>>  bool
>>>>>>  enable_rtl_dump_file (void)
>>>>>>  {
>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>  }
>>>>>> Index: tree-pass.h
>>>>>> ===================================================================
>>>>>> --- tree-pass.h (revision 187265)
>>>>>> +++ tree-pass.h (working copy)
>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>>>> +                                           instead of constructing one. */
>>>>>>
>>>>>> -
>>>>>>  /* In tree-dump.c */
>>>>>>
>>>>>>  extern char *get_dump_file_name (int);
>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>   const char *swtch;            /* command line switch */
>>>>>>   const char *glob;             /* command line glob  */
>>>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>
>>>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>>>
>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-11  8:49           ` Richard Guenther
@ 2012-05-11 16:07             ` Xinliang David Li
  2012-05-11 18:12               ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-05-11 16:07 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

On Fri, May 11, 2012 at 1:49 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Thu, May 10, 2012 at 6:28 PM, Xinliang David Li <davidxl@google.com> wrote:
>> I like your suggestion and support the end goal you have.  I don't
>> like the -fopt-info behavior to interfere with regular -fdump-xxx
>> options either.
>>
>> I think we should stage the changes in multiple steps as originally
>> planned. Is Sharad's change good to be checked in for the first stage?
>
> Well - I don't think the change walks in the direction we want to go, so I don't
> see a good reason to make that change.

Is your direction misunderstood or you want everything to be changed
in one single patch (including replacement of all fprintf (dump_file,
...)? If the former, please clarify. If the latter, it can be done.

thanks,

David

>
>> After this one is checked in, the new dump interfaces will be worked
>> on (and to allow multiple streams). Most of the remaining changes will
>> be massive text replacement.
>>
>> thanks,
>>
>> David
>>
>>
>> On Thu, May 10, 2012 at 1:18 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>> Bummer.  I was thinking to reserve '=' for selective  dumping:
>>>>
>>>> -fdump-tree-pre=<func_list_regexp>
>>>>
>>>> I guess this can be achieved via @
>>>>
>>>> -fdump-tree-pre@<func_list>
>>>>
>>>> -fdump-tree-pre=<file_name>@<func_list>
>>>>
>>>>
>>>> Another issue -- I don't think the current precedence rule is correct.
>>>> Consider that -fopt-info=2 will be mapped to
>>>>
>>>> -fdump-tree-all-transform-verbose2=stderr
>>>> -fdump-rtl-all-transform-verbose2=stderr
>>>>
>>>> then
>>>>
>>>> the current precedence rule will cause surprise when the following is used
>>>>
>>>> -fopt-info -fdump-tree-pre
>>>>
>>>> The PRE dump will be emitted to stderr which is not what user wants.
>>>> In short, special streams should be treated as 'weak' the same way as
>>>> your previous implementation.
>>>
>>> Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
>>> With -fopt-info -fdump-tree-pre I do not want some information to be
>>> present only on stderr or in the dump file!  I want it in _both_ places!
>>> (-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
>>> information :()
>>>
>>> Thus, the information where dumping goes has to be done differently
>>> (which is why I asked for some re-org originally, so that passes no
>>> longer explicitely reference dump_file - dump_file may be different
>>> for different kind of information it dumps!).  Passes should, instead of
>>>
>>>  fprintf (dump_file, "...", ...)
>>>
>>> do
>>>
>>>  dump_printf (TDF_scev, "...", ...)
>>>
>>> thus, specify the kind of information they dump (would be mostly
>>> TDF_details vs. 0 today I guess).  The dump_printf routine would
>>> then properly direct to one or more places to dump at.
>>>
>>> I realize this needs some more dispatchers for dumping expressions
>>> and statements (but it should not be too many).  Dumping to
>>> dump_file would in any case dump to the passes private dump file
>>> only (unqualified stuff would never be useful for -fopt-info).
>>>
>>> The perfect candidate to convert to this kind of scheme is obviously
>>> the vectorizer with its existing -fvectorizer-verbose.
>>>
>>> If the patch doesn't work towards this kind of end-result I'd rather
>>> not have it.
>>>
>>> Thanks,
>>> Richard.
>>>
>>>> thanks,
>>>>
>>>> David
>>>>
>>>>
>>>>
>>>> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>> Thanks for your suggestions/comments. I have updated the patch and
>>>>> documentation. It supports the following usage:
>>>>>
>>>>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>>>>> -fdump-rtl-ira=ira.dump
>>>>>
>>>>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>>>>> goes to stdout and the IRA dump goes to ira.dump.
>>>>>
>>>>> Thanks,
>>>>> Sharad
>>>>>
>>>>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>>>>
>>>>>        * doc/invoke.texi: Add documentation for the new option.
>>>>>        * tree-dump.c (dump_get_standard_stream): New function.
>>>>>        (dump_files): Update for new field.
>>>>>        (dump_switch_p_1): Handle dump filenames.
>>>>>        (dump_begin): Likewise.
>>>>>        (get_dump_file_name): Likewise.
>>>>>        (dump_end): Remove attribute.
>>>>>        (dump_enable_all): Add new parameter FILENAME.
>>>>>        All callers updated.
>>>>>        (enable_rtl_dump_file):
>>>>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>>>>        (struct dump_file_info): Add new field FILENAME.
>>>>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>>>>
>>>>> Index: doc/invoke.texi
>>>>> ===================================================================
>>>>> --- doc/invoke.texi     (revision 187265)
>>>>> +++ doc/invoke.texi     (working copy)
>>>>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>>>>
>>>>>  @item -d@var{letters}
>>>>>  @itemx -fdump-rtl-@var{pass}
>>>>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>>>>  @opindex d
>>>>>  Says to make debugging dumps during compilation at times specified by
>>>>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>>>>  compiler.  The file names for most of the dumps are made by appending
>>>>>  a pass number and a word to the @var{dumpname}, and the files are
>>>>> -created in the directory of the output file.  Note that the pass
>>>>> -number is computed statically as passes get registered into the pass
>>>>> -manager.  Thus the numbering is not related to the dynamic order of
>>>>> -execution of passes.  In particular, a pass installed by a plugin
>>>>> -could have a number over 200 even if it executed quite early.
>>>>> -@var{dumpname} is generated from the name of the output file, if
>>>>> -explicitly specified and it is not an executable, otherwise it is the
>>>>> -basename of the source file. These switches may have different effects
>>>>> -when @option{-E} is used for preprocessing.
>>>>> +created in the directory of the output file. If the
>>>>> +@option{=@var{filename}} is appended to the longer form of the dump
>>>>> +option then the dump is done on that file instead of numbered
>>>>> +files. Note that the pass number is computed statically as passes get
>>>>> +registered into the pass manager.  Thus the numbering is not related
>>>>> +to the dynamic order of execution of passes.  In particular, a pass
>>>>> +installed by a plugin could have a number over 200 even if it executed
>>>>> +quite early.  @var{dumpname} is generated from the name of the output
>>>>> +file, if explicitly specified and it is not an executable, otherwise
>>>>> +it is the basename of the source file. These switches may have
>>>>> +different effects when @option{-E} is used for preprocessing.
>>>>>
>>>>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>>>>  @option{-d} option @var{letters}.  Here are the possible
>>>>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>>>>
>>>>>  @item -fdump-tree-@var{switch}
>>>>>  @itemx -fdump-tree-@var{switch}-@var{options}
>>>>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>>>>  @opindex fdump-tree
>>>>>  Control the dumping at various stages of processing the intermediate
>>>>>  language tree to a file.  The file name is generated by appending a
>>>>>  switch specific suffix to the source file name, and the file is
>>>>> -created in the same directory as the output file.  If the
>>>>> -@samp{-@var{options}} form is used, @var{options} is a list of
>>>>> -@samp{-} separated options which control the details of the dump.  Not
>>>>> -all options are applicable to all dumps; those that are not
>>>>> -meaningful are ignored.  The following options are available
>>>>> +created in the same directory as the output file. In case of
>>>>> +@option{=@var{filename}} option, the dump is output on the given file
>>>>> +name instead.  If the @samp{-@var{options}} form is used,
>>>>> +@var{options} is a list of @samp{-} separated options which control
>>>>> +the details or location of the dump.  Not all options are applicable
>>>>> +to all dumps; those that are not meaningful are ignored.  The
>>>>> +following options are available
>>>>>
>>>>>  @table @samp
>>>>>  @item address
>>>>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>>>>  Enable showing the EH region number holding each statement.
>>>>>  @item scev
>>>>>  Enable showing scalar evolution analysis details.
>>>>> +@item slim
>>>>> +Inhibit dumping of members of a scope or body of a function merely
>>>>> +because that scope has been reached.  Only dump such items when they
>>>>> +are directly reachable by some other path.  When dumping pretty-printed
>>>>> +trees, this option inhibits dumping the bodies of control structures.
>>>>> +@item =@var{filename}
>>>>> +Instead of using an auto generated dump file name, use the given file
>>>>> +name. The file names @file{stdout} and @file{stderr} are treated
>>>>> +specially and are considered already open standard streams. For
>>>>> +example:
>>>>> +
>>>>> +@smallexample
>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>>>>> +@end smallexample
>>>>> +
>>>>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>>>>> +file named @file{ira.txt}.
>>>>> +
>>>>> +In case of any conflicts, the command line file name takes precedence
>>>>> +over generated file names. For example:
>>>>> +
>>>>> +@smallexample
>>>>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>>>>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>>>>> +@end smallexample
>>>>> +
>>>>> +Both of the above output the PRE dump on @file{stdout}. However, if
>>>>> +there are multiple command line file names are applicable then the
>>>>> +last one is used. Thus the command
>>>>> +
>>>>> +@smallexample
>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>>>>> +@end smallexample
>>>>> +
>>>>> +outputs all the dumps in @file{all.txt} because the stderr option for
>>>>> +PRE dump is overridden by a later option.
>>>>> +
>>>>>  @item all
>>>>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>>>> -and @option{lineno}.
>>>>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>>>>> +@option{lineno}.
>>>>>  @end table
>>>>>
>>>>>  The following tree dumps are possible:
>>>>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>>>>  @item all
>>>>>  @opindex fdump-tree-all
>>>>>  Enable all the available tree dumps with the flags provided in this option.
>>>>> +
>>>>>  @end table
>>>>>
>>>>>  @item -ftree-vectorizer-verbose=@var{n}
>>>>> Index: tree-dump.c
>>>>> ===================================================================
>>>>> --- tree-dump.c (revision 187265)
>>>>> +++ tree-dump.c (working copy)
>>>>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>>>>    tree_dump_index enumeration in tree-pass.h.  */
>>>>>  static struct dump_file_info dump_files[TDI_end] =
>>>>>  {
>>>>> -  {NULL, NULL, NULL, 0, 0, 0},
>>>>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>>>>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>>>>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>>>>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>>>>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>>>>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>>>>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>>>>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>>>>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>>>>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>>>>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>>>>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>>>>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>>>>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>>>>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>>>>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>>>>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>>>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>>>>
>>>>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>>>>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>>>>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>>>>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>>>>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>>>>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>>>>  };
>>>>>
>>>>>  /* Dynamically registered tree dump files and switches.  */
>>>>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>>>>  };
>>>>>
>>>>>  /* Table of dump options. This must be consistent with the TDF_* flags
>>>>> -   in tree.h */
>>>>> +   in tree-pass.h */
>>>>>  static const struct dump_option_value_info dump_options[] =
>>>>>  {
>>>>>   {"address", TDF_ADDRESS},
>>>>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>>>>   if (dfi->state == 0)
>>>>>     return NULL;
>>>>>
>>>>> +  if (dfi->filename)
>>>>> +    return xstrdup (dfi->filename);
>>>>> +
>>>>>   if (dfi->num < 0)
>>>>>     dump_id[0] = '\0';
>>>>>   else
>>>>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>>>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>>>>  }
>>>>>
>>>>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>>>>> +   return that stream, NULL otherwise.  */
>>>>> +
>>>>> +static FILE *
>>>>> +dump_get_standard_stream (struct dump_file_info *dfi)
>>>>> +{
>>>>> +  if (!dfi->filename)
>>>>> +    return NULL;
>>>>> +
>>>>> +  return strcmp("stderr", dfi->filename) == 0
>>>>> +    ? stderr
>>>>> +    : strcmp("stdout", dfi->filename) == 0
>>>>> +    ?  stdout
>>>>> +    : NULL;
>>>>> +}
>>>>> +
>>>>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>>>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>>>>    enabled, returns NULL.
>>>>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>>>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>>>>     return NULL;
>>>>>
>>>>> -  name = get_dump_file_name (phase);
>>>>>   dfi = get_dump_file_info (phase);
>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>> -  if (!stream)
>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>> +  stream = dump_get_standard_stream (dfi);
>>>>> +  if (stream)
>>>>> +    dfi->state = 1;
>>>>>   else
>>>>> -    dfi->state = 1;
>>>>> -  free (name);
>>>>> +    {
>>>>> +      name = get_dump_file_name (phase);
>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>> +      if (!stream)
>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>> +      else
>>>>> +        dfi->state = 1;
>>>>> +      free (name);
>>>>> +    }
>>>>>
>>>>>   if (flag_ptr)
>>>>>     *flag_ptr = dfi->flags;
>>>>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>>>>    dump_begin.  */
>>>>>
>>>>>  void
>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>> +dump_end (int phase, FILE *stream)
>>>>>  {
>>>>> -  fclose (stream);
>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>> +  if (!dump_get_standard_stream (dfi))
>>>>> +    fclose (stream);
>>>>>  }
>>>>>
>>>>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>>>>> +   enabled tree dumps.  */
>>>>>
>>>>>  static int
>>>>> -dump_enable_all (int flags)
>>>>> +dump_enable_all (int flags, const char *filename)
>>>>>  {
>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>   int n = 0;
>>>>>   size_t i;
>>>>>
>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>> -      {
>>>>> -        dump_files[i].state = -1;
>>>>> -        dump_files[i].flags |= flags;
>>>>> -        n++;
>>>>> -      }
>>>>> +    {
>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>> +        {
>>>>> +          dump_files[i].state = -1;
>>>>> +          dump_files[i].flags |= flags;
>>>>> +          n++;
>>>>> +          if (filename)
>>>>> +            dump_files[i].filename = xstrdup (filename);
>>>>> +        }
>>>>> +    }
>>>>>
>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>> -      {
>>>>> -        extra_dump_files[i].state = -1;
>>>>> -        extra_dump_files[i].flags |= flags;
>>>>> -       n++;
>>>>> -      }
>>>>> +    {
>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>> +        {
>>>>> +          extra_dump_files[i].state = -1;
>>>>> +          extra_dump_files[i].flags |= flags;
>>>>> +          n++;
>>>>> +          if (filename)
>>>>> +            extra_dump_files[i].filename = xstrdup (filename);
>>>>> +        }
>>>>> +    }
>>>>>
>>>>>   return n;
>>>>>  }
>>>>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>   if (!option_value)
>>>>>     return 0;
>>>>>
>>>>> -  if (*option_value && *option_value != '-')
>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>     return 0;
>>>>>
>>>>>   ptr = option_value;
>>>>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>       while (*ptr == '-')
>>>>>        ptr++;
>>>>>       end_ptr = strchr (ptr, '-');
>>>>> +
>>>>>       if (!end_ptr)
>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>       length = end_ptr - ptr;
>>>>>
>>>>> +      if (*ptr == '=')
>>>>> +        {
>>>>> +          /* Interpret rest of the argument as a dump filename.  This
>>>>> +             filename overrides generated dump names as well as other
>>>>> +             command line filenames.  */
>>>>> +          flags |= TDF_FILENAME;
>>>>> +          if (dfi->filename)
>>>>> +            free (dfi->filename);
>>>>> +          dfi->filename = xstrdup (ptr + 1);
>>>>> +          break;
>>>>> +        }
>>>>> +
>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>        if (strlen (option_ptr->name) == length
>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>> -         {
>>>>> -           flags |= option_ptr->value;
>>>>> +          {
>>>>> +            flags |= option_ptr->value;
>>>>>            goto found;
>>>>> -         }
>>>>> +          }
>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>               length, ptr, dfi->swtch);
>>>>>     found:;
>>>>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>      known dumps.  */
>>>>>   if (dfi->suffix == NULL)
>>>>> -    dump_enable_all (dfi->flags);
>>>>> +    dump_enable_all (dfi->flags, dfi->filename);
>>>>>
>>>>>   return 1;
>>>>>  }
>>>>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>>>>  bool
>>>>>  enable_rtl_dump_file (void)
>>>>>  {
>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>  }
>>>>> Index: tree-pass.h
>>>>> ===================================================================
>>>>> --- tree-pass.h (revision 187265)
>>>>> +++ tree-pass.h (working copy)
>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>>>>> +                                           instead of constructing one. */
>>>>>
>>>>> -
>>>>>  /* In tree-dump.c */
>>>>>
>>>>>  extern char *get_dump_file_name (int);
>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>   const char *swtch;            /* command line switch */
>>>>>   const char *glob;             /* command line glob  */
>>>>> +  const char *filename;         /* use this filename instead of making
>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>   int flags;                    /* user flags */
>>>>>   int state;                    /* state of play */
>>>>>   int num;                      /* dump file number */
>>>>> Index: testsuite/g++.dg/other/dump-filename-1.C
>>>>> ===================================================================
>>>>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>> @@ -0,0 +1,11 @@
>>>>> +// Test that the dump to a user-defined file works correctly.
>>>>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>>>>> +
>>>>> +void test (int *b, int *e, int stride)
>>>>> +  {
>>>>> +    for (int *p = b; p != e; p += stride)
>>>>> +      *p = 1;
>>>>> +  }
>>>>> +
>>>>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>>>>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>>>>
>>>>>
>>>>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>>> [...]
>>>>>>
>>>>>>> +@item -fdump-rtl-all=stderr
>>>>>>> +@opindex fdump-rtl-all=stderr
>>>>>>
>>>>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>>>>> Rather, expand the description to state this in all the documentation
>>>>>> for -fdump-xxx=yyy.
>>>>>>
>>>>>> [...]
>>>>>>
>>>>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>>>>> +   stderr stream.  */
>>>>>>> +
>>>>>>> +static int
>>>>>>> +dump_stream_p (const char *user_filename)
>>>>>>> +{
>>>>>>> +  if (user_filename)
>>>>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>>>>> +      !strncmp ("stdout", user_filename, 6);
>>>>>>> +  else
>>>>>>> +    return 0;
>>>>>>> +}
>>>>>>
>>>>>> The name is ambiguous.
>>>>>> This function is testing whether its string argument designates one of
>>>>>> the *standard* output streams.  Name it to reflect that..
>>>>>> Have it take the dump state context. Also the coding convention: the binary
>>>>>> operator "||" should be on next line.  In fact the thing could be
>>>>>> simpler.   Instead of
>>>>>> testing over and over again against "stderr" (once in this function, then again
>>>>>> later), just return the corresponding standard FILE* pointer.
>>>>>> Also, this is a case of overuse of strncmp.  If you name the function
>>>>>> dump_get_standard_stream:
>>>>>>
>>>>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>>>>       ? stderr
>>>>>>        : stdcmp("stdout", dfi->use_filename)
>>>>>>        ?  stdout
>>>>>>        : NULL;
>>>>>>
>>>>>> you can simplify:
>>>>>>
>>>>>>> -  name = get_dump_file_name (phase);
>>>>>>>   dfi = get_dump_file_info (phase);
>>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>> -  if (!stream)
>>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>>> +  if (dump_stream_p (dfi->user_filename))
>>>>>>> +    {
>>>>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>>>>> +        stream = stderr;
>>>>>>> +      else
>>>>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>>>>> +          stream = stdout;
>>>>>>> +        else
>>>>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>>>>> +      dfi->state = 1;
>>>>>>> +    }
>>>>>>>   else
>>>>>>> -    dfi->state = 1;
>>>>>>> -  free (name);
>>>>>>> +    {
>>>>>>> +      name = get_dump_file_name (phase);
>>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>> +      if (!stream)
>>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>>> +      else
>>>>>>> +        dfi->state = 1;
>>>>>>> +      free (name);
>>>>>>> +    }
>>>>>>>
>>>>>>>   if (flag_ptr)
>>>>>>>     *flag_ptr = dfi->flags;
>>>>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>>>>    dump_begin.  */
>>>>>>>
>>>>>>>  void
>>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>>  {
>>>>>>> -  fclose (stream);
>>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>>>>> +    fclose (stream);
>>>>>>>  }
>>>>>>>
>>>>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>>
>>>>>>>  static int
>>>>>>> -dump_enable_all (int flags)
>>>>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>>>>  {
>>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>>   int n = 0;
>>>>>>>   size_t i;
>>>>>>>
>>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>>> -      {
>>>>>>> -        dump_files[i].state = -1;
>>>>>>> -        dump_files[i].flags |= flags;
>>>>>>> -        n++;
>>>>>>> -      }
>>>>>>> +    {
>>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>>> +        {
>>>>>>> +          dump_files[i].state = -1;
>>>>>>> +          dump_files[i].flags |= flags;
>>>>>>> +          n++;
>>>>>>> +        }
>>>>>>> +      if (user_filename)
>>>>>>> +        dump_files[i].user_filename = user_filename;
>>>>>>> +    }
>>>>>>>
>>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>> -      {
>>>>>>> -        extra_dump_files[i].state = -1;
>>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>>> -       n++;
>>>>>>> -      }
>>>>>>> +    {
>>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>> +        {
>>>>>>> +          extra_dump_files[i].state = -1;
>>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>>> +          n++;
>>>>>>> +        }
>>>>>>> +      if (user_filename)
>>>>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>>>>> +    }
>>>>>>>
>>>>>>>   return n;
>>>>>>>  }
>>>>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>   if (!option_value)
>>>>>>>     return 0;
>>>>>>>
>>>>>>> -  if (*option_value && *option_value != '-')
>>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>>     return 0;
>>>>>>>
>>>>>>>   ptr = option_value;
>>>>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>       while (*ptr == '-')
>>>>>>>        ptr++;
>>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>>> +
>>>>>>>       if (!end_ptr)
>>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>>       length = end_ptr - ptr;
>>>>>>>
>>>>>>> +      if (*ptr == '=')
>>>>>>> +        {
>>>>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>>>>> +             user provided filename overrides generated dump names as
>>>>>>> +             well as other command line filenames.  */
>>>>>>> +          flags |= TDF_USER_FILENAME;
>>>>>>> +          if (dfi->user_filename)
>>>>>>> +            free (dfi->user_filename);
>>>>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>>>>> +          break;
>>>>>>> +        }
>>>>>>> +
>>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>>> -         {
>>>>>>> -           flags |= option_ptr->value;
>>>>>>> +          {
>>>>>>> +            flags |= option_ptr->value;
>>>>>>>            goto found;
>>>>>>> -         }
>>>>>>> +          }
>>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>>               length, ptr, dfi->swtch);
>>>>>>>     found:;
>>>>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>>      known dumps.  */
>>>>>>>   if (dfi->suffix == NULL)
>>>>>>> -    dump_enable_all (dfi->flags);
>>>>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>>>>
>>>>>>>   return 1;
>>>>>>>  }
>>>>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>>>>  bool
>>>>>>>  enable_rtl_dump_file (void)
>>>>>>>  {
>>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>>  }
>>>>>>> Index: tree-pass.h
>>>>>>> ===================================================================
>>>>>>> --- tree-pass.h (revision 187265)
>>>>>>> +++ tree-pass.h (working copy)
>>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>>>>> +                                           instead of constructing one. */
>>>>>>>
>>>>>>> -
>>>>>>>  /* In tree-dump.c */
>>>>>>>
>>>>>>>  extern char *get_dump_file_name (int);
>>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>>   const char *swtch;            /* command line switch */
>>>>>>>   const char *glob;             /* command line glob  */
>>>>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>
>>>>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>>>>
>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-11 16:07             ` Xinliang David Li
@ 2012-05-11 18:12               ` Xinliang David Li
  2012-05-12 10:31                 ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-05-11 18:12 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

To be more specific, does the following match what your envisioned?

1) when multiple streams are specified for dumping, the information
will be dumped to all streams IF the new dumping interfaces are used
(see below). For legacy code, the default dump file will still be used
and the user specified file (including stderr) will be silently
ignored. This is of course temporary until all dumping sites are
converted

2) Define the following new dumping interfaces which will honor all
streams specified

  dump_printf (const char*, ....);   // for raw string dumping
  dump_generic_expr (...); //  wrapper to print_generic_expr without
taking FILE*
  dump_node (...); // wrapper to print_node
  dump_gimple_stmt(...); // wrapper to print_gimple_stmt

  dump_inform (...); //wrapper to inform (..) method, but is aware of
of the dumping streams and modify global_dc appropriately.

3) Implement -fopt-info=N, and take -ftree-vectorizer-verbose as the
first guinea pig to use the new dumping interfaces.

After the infrastructure is ready, gradually deprecate the use of the
original dumper interfaces.

what do you think?

thanks,

David

On Fri, May 11, 2012 at 9:06 AM, Xinliang David Li <davidxl@google.com> wrote:
> On Fri, May 11, 2012 at 1:49 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Thu, May 10, 2012 at 6:28 PM, Xinliang David Li <davidxl@google.com> wrote:
>>> I like your suggestion and support the end goal you have.  I don't
>>> like the -fopt-info behavior to interfere with regular -fdump-xxx
>>> options either.
>>>
>>> I think we should stage the changes in multiple steps as originally
>>> planned. Is Sharad's change good to be checked in for the first stage?
>>
>> Well - I don't think the change walks in the direction we want to go, so I don't
>> see a good reason to make that change.
>
> Is your direction misunderstood or you want everything to be changed
> in one single patch (including replacement of all fprintf (dump_file,
> ...)? If the former, please clarify. If the latter, it can be done.
>
> thanks,
>
> David
>
>>
>>> After this one is checked in, the new dump interfaces will be worked
>>> on (and to allow multiple streams). Most of the remaining changes will
>>> be massive text replacement.
>>>
>>> thanks,
>>>
>>> David
>>>
>>>
>>> On Thu, May 10, 2012 at 1:18 AM, Richard Guenther
>>> <richard.guenther@gmail.com> wrote:
>>>> On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> Bummer.  I was thinking to reserve '=' for selective  dumping:
>>>>>
>>>>> -fdump-tree-pre=<func_list_regexp>
>>>>>
>>>>> I guess this can be achieved via @
>>>>>
>>>>> -fdump-tree-pre@<func_list>
>>>>>
>>>>> -fdump-tree-pre=<file_name>@<func_list>
>>>>>
>>>>>
>>>>> Another issue -- I don't think the current precedence rule is correct.
>>>>> Consider that -fopt-info=2 will be mapped to
>>>>>
>>>>> -fdump-tree-all-transform-verbose2=stderr
>>>>> -fdump-rtl-all-transform-verbose2=stderr
>>>>>
>>>>> then
>>>>>
>>>>> the current precedence rule will cause surprise when the following is used
>>>>>
>>>>> -fopt-info -fdump-tree-pre
>>>>>
>>>>> The PRE dump will be emitted to stderr which is not what user wants.
>>>>> In short, special streams should be treated as 'weak' the same way as
>>>>> your previous implementation.
>>>>
>>>> Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
>>>> With -fopt-info -fdump-tree-pre I do not want some information to be
>>>> present only on stderr or in the dump file!  I want it in _both_ places!
>>>> (-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
>>>> information :()
>>>>
>>>> Thus, the information where dumping goes has to be done differently
>>>> (which is why I asked for some re-org originally, so that passes no
>>>> longer explicitely reference dump_file - dump_file may be different
>>>> for different kind of information it dumps!).  Passes should, instead of
>>>>
>>>>  fprintf (dump_file, "...", ...)
>>>>
>>>> do
>>>>
>>>>  dump_printf (TDF_scev, "...", ...)
>>>>
>>>> thus, specify the kind of information they dump (would be mostly
>>>> TDF_details vs. 0 today I guess).  The dump_printf routine would
>>>> then properly direct to one or more places to dump at.
>>>>
>>>> I realize this needs some more dispatchers for dumping expressions
>>>> and statements (but it should not be too many).  Dumping to
>>>> dump_file would in any case dump to the passes private dump file
>>>> only (unqualified stuff would never be useful for -fopt-info).
>>>>
>>>> The perfect candidate to convert to this kind of scheme is obviously
>>>> the vectorizer with its existing -fvectorizer-verbose.
>>>>
>>>> If the patch doesn't work towards this kind of end-result I'd rather
>>>> not have it.
>>>>
>>>> Thanks,
>>>> Richard.
>>>>
>>>>> thanks,
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>>
>>>>> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>> Thanks for your suggestions/comments. I have updated the patch and
>>>>>> documentation. It supports the following usage:
>>>>>>
>>>>>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>>>>>> -fdump-rtl-ira=ira.dump
>>>>>>
>>>>>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>>>>>> goes to stdout and the IRA dump goes to ira.dump.
>>>>>>
>>>>>> Thanks,
>>>>>> Sharad
>>>>>>
>>>>>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>>>>>
>>>>>>        * doc/invoke.texi: Add documentation for the new option.
>>>>>>        * tree-dump.c (dump_get_standard_stream): New function.
>>>>>>        (dump_files): Update for new field.
>>>>>>        (dump_switch_p_1): Handle dump filenames.
>>>>>>        (dump_begin): Likewise.
>>>>>>        (get_dump_file_name): Likewise.
>>>>>>        (dump_end): Remove attribute.
>>>>>>        (dump_enable_all): Add new parameter FILENAME.
>>>>>>        All callers updated.
>>>>>>        (enable_rtl_dump_file):
>>>>>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>>>>>        (struct dump_file_info): Add new field FILENAME.
>>>>>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>>>>>
>>>>>> Index: doc/invoke.texi
>>>>>> ===================================================================
>>>>>> --- doc/invoke.texi     (revision 187265)
>>>>>> +++ doc/invoke.texi     (working copy)
>>>>>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>>>>>
>>>>>>  @item -d@var{letters}
>>>>>>  @itemx -fdump-rtl-@var{pass}
>>>>>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>>>>>  @opindex d
>>>>>>  Says to make debugging dumps during compilation at times specified by
>>>>>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>>>>>  compiler.  The file names for most of the dumps are made by appending
>>>>>>  a pass number and a word to the @var{dumpname}, and the files are
>>>>>> -created in the directory of the output file.  Note that the pass
>>>>>> -number is computed statically as passes get registered into the pass
>>>>>> -manager.  Thus the numbering is not related to the dynamic order of
>>>>>> -execution of passes.  In particular, a pass installed by a plugin
>>>>>> -could have a number over 200 even if it executed quite early.
>>>>>> -@var{dumpname} is generated from the name of the output file, if
>>>>>> -explicitly specified and it is not an executable, otherwise it is the
>>>>>> -basename of the source file. These switches may have different effects
>>>>>> -when @option{-E} is used for preprocessing.
>>>>>> +created in the directory of the output file. If the
>>>>>> +@option{=@var{filename}} is appended to the longer form of the dump
>>>>>> +option then the dump is done on that file instead of numbered
>>>>>> +files. Note that the pass number is computed statically as passes get
>>>>>> +registered into the pass manager.  Thus the numbering is not related
>>>>>> +to the dynamic order of execution of passes.  In particular, a pass
>>>>>> +installed by a plugin could have a number over 200 even if it executed
>>>>>> +quite early.  @var{dumpname} is generated from the name of the output
>>>>>> +file, if explicitly specified and it is not an executable, otherwise
>>>>>> +it is the basename of the source file. These switches may have
>>>>>> +different effects when @option{-E} is used for preprocessing.
>>>>>>
>>>>>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>>>>>  @option{-d} option @var{letters}.  Here are the possible
>>>>>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>>>>>
>>>>>>  @item -fdump-tree-@var{switch}
>>>>>>  @itemx -fdump-tree-@var{switch}-@var{options}
>>>>>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>>>>>  @opindex fdump-tree
>>>>>>  Control the dumping at various stages of processing the intermediate
>>>>>>  language tree to a file.  The file name is generated by appending a
>>>>>>  switch specific suffix to the source file name, and the file is
>>>>>> -created in the same directory as the output file.  If the
>>>>>> -@samp{-@var{options}} form is used, @var{options} is a list of
>>>>>> -@samp{-} separated options which control the details of the dump.  Not
>>>>>> -all options are applicable to all dumps; those that are not
>>>>>> -meaningful are ignored.  The following options are available
>>>>>> +created in the same directory as the output file. In case of
>>>>>> +@option{=@var{filename}} option, the dump is output on the given file
>>>>>> +name instead.  If the @samp{-@var{options}} form is used,
>>>>>> +@var{options} is a list of @samp{-} separated options which control
>>>>>> +the details or location of the dump.  Not all options are applicable
>>>>>> +to all dumps; those that are not meaningful are ignored.  The
>>>>>> +following options are available
>>>>>>
>>>>>>  @table @samp
>>>>>>  @item address
>>>>>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>>>>>  Enable showing the EH region number holding each statement.
>>>>>>  @item scev
>>>>>>  Enable showing scalar evolution analysis details.
>>>>>> +@item slim
>>>>>> +Inhibit dumping of members of a scope or body of a function merely
>>>>>> +because that scope has been reached.  Only dump such items when they
>>>>>> +are directly reachable by some other path.  When dumping pretty-printed
>>>>>> +trees, this option inhibits dumping the bodies of control structures.
>>>>>> +@item =@var{filename}
>>>>>> +Instead of using an auto generated dump file name, use the given file
>>>>>> +name. The file names @file{stdout} and @file{stderr} are treated
>>>>>> +specially and are considered already open standard streams. For
>>>>>> +example:
>>>>>> +
>>>>>> +@smallexample
>>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>>>>>> +@end smallexample
>>>>>> +
>>>>>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>>>>>> +file named @file{ira.txt}.
>>>>>> +
>>>>>> +In case of any conflicts, the command line file name takes precedence
>>>>>> +over generated file names. For example:
>>>>>> +
>>>>>> +@smallexample
>>>>>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>>>>>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>>>>>> +@end smallexample
>>>>>> +
>>>>>> +Both of the above output the PRE dump on @file{stdout}. However, if
>>>>>> +there are multiple command line file names are applicable then the
>>>>>> +last one is used. Thus the command
>>>>>> +
>>>>>> +@smallexample
>>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>>>>>> +@end smallexample
>>>>>> +
>>>>>> +outputs all the dumps in @file{all.txt} because the stderr option for
>>>>>> +PRE dump is overridden by a later option.
>>>>>> +
>>>>>>  @item all
>>>>>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>>>>> -and @option{lineno}.
>>>>>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>>>>>> +@option{lineno}.
>>>>>>  @end table
>>>>>>
>>>>>>  The following tree dumps are possible:
>>>>>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>>>>>  @item all
>>>>>>  @opindex fdump-tree-all
>>>>>>  Enable all the available tree dumps with the flags provided in this option.
>>>>>> +
>>>>>>  @end table
>>>>>>
>>>>>>  @item -ftree-vectorizer-verbose=@var{n}
>>>>>> Index: tree-dump.c
>>>>>> ===================================================================
>>>>>> --- tree-dump.c (revision 187265)
>>>>>> +++ tree-dump.c (working copy)
>>>>>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>>>>>    tree_dump_index enumeration in tree-pass.h.  */
>>>>>>  static struct dump_file_info dump_files[TDI_end] =
>>>>>>  {
>>>>>> -  {NULL, NULL, NULL, 0, 0, 0},
>>>>>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>>>>>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>>>>>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>>>>>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>>>>>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>>>>>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>>>>>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>>>>>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>>>>>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>>>>>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>>>>>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>>>>>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>>>>>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>>>>>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>>>>>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>>>>>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>>>>>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>>>>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>>>>>
>>>>>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>>>>>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>>>>>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>>>>>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>>>>>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>>>>>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>>>>>  };
>>>>>>
>>>>>>  /* Dynamically registered tree dump files and switches.  */
>>>>>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>>>>>  };
>>>>>>
>>>>>>  /* Table of dump options. This must be consistent with the TDF_* flags
>>>>>> -   in tree.h */
>>>>>> +   in tree-pass.h */
>>>>>>  static const struct dump_option_value_info dump_options[] =
>>>>>>  {
>>>>>>   {"address", TDF_ADDRESS},
>>>>>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>>>>>   if (dfi->state == 0)
>>>>>>     return NULL;
>>>>>>
>>>>>> +  if (dfi->filename)
>>>>>> +    return xstrdup (dfi->filename);
>>>>>> +
>>>>>>   if (dfi->num < 0)
>>>>>>     dump_id[0] = '\0';
>>>>>>   else
>>>>>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>>>>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>>>>>  }
>>>>>>
>>>>>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>>>>>> +   return that stream, NULL otherwise.  */
>>>>>> +
>>>>>> +static FILE *
>>>>>> +dump_get_standard_stream (struct dump_file_info *dfi)
>>>>>> +{
>>>>>> +  if (!dfi->filename)
>>>>>> +    return NULL;
>>>>>> +
>>>>>> +  return strcmp("stderr", dfi->filename) == 0
>>>>>> +    ? stderr
>>>>>> +    : strcmp("stdout", dfi->filename) == 0
>>>>>> +    ?  stdout
>>>>>> +    : NULL;
>>>>>> +}
>>>>>> +
>>>>>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>>>>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>>>>>    enabled, returns NULL.
>>>>>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>>>>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>>>>>     return NULL;
>>>>>>
>>>>>> -  name = get_dump_file_name (phase);
>>>>>>   dfi = get_dump_file_info (phase);
>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>> -  if (!stream)
>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>> +  stream = dump_get_standard_stream (dfi);
>>>>>> +  if (stream)
>>>>>> +    dfi->state = 1;
>>>>>>   else
>>>>>> -    dfi->state = 1;
>>>>>> -  free (name);
>>>>>> +    {
>>>>>> +      name = get_dump_file_name (phase);
>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>> +      if (!stream)
>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>> +      else
>>>>>> +        dfi->state = 1;
>>>>>> +      free (name);
>>>>>> +    }
>>>>>>
>>>>>>   if (flag_ptr)
>>>>>>     *flag_ptr = dfi->flags;
>>>>>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>>>>>    dump_begin.  */
>>>>>>
>>>>>>  void
>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>  {
>>>>>> -  fclose (stream);
>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>> +  if (!dump_get_standard_stream (dfi))
>>>>>> +    fclose (stream);
>>>>>>  }
>>>>>>
>>>>>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>>>>>> +   enabled tree dumps.  */
>>>>>>
>>>>>>  static int
>>>>>> -dump_enable_all (int flags)
>>>>>> +dump_enable_all (int flags, const char *filename)
>>>>>>  {
>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>   int n = 0;
>>>>>>   size_t i;
>>>>>>
>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>> -      {
>>>>>> -        dump_files[i].state = -1;
>>>>>> -        dump_files[i].flags |= flags;
>>>>>> -        n++;
>>>>>> -      }
>>>>>> +    {
>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>> +        {
>>>>>> +          dump_files[i].state = -1;
>>>>>> +          dump_files[i].flags |= flags;
>>>>>> +          n++;
>>>>>> +          if (filename)
>>>>>> +            dump_files[i].filename = xstrdup (filename);
>>>>>> +        }
>>>>>> +    }
>>>>>>
>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>> -      {
>>>>>> -        extra_dump_files[i].state = -1;
>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>> -       n++;
>>>>>> -      }
>>>>>> +    {
>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>> +        {
>>>>>> +          extra_dump_files[i].state = -1;
>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>> +          n++;
>>>>>> +          if (filename)
>>>>>> +            extra_dump_files[i].filename = xstrdup (filename);
>>>>>> +        }
>>>>>> +    }
>>>>>>
>>>>>>   return n;
>>>>>>  }
>>>>>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>   if (!option_value)
>>>>>>     return 0;
>>>>>>
>>>>>> -  if (*option_value && *option_value != '-')
>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>     return 0;
>>>>>>
>>>>>>   ptr = option_value;
>>>>>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>       while (*ptr == '-')
>>>>>>        ptr++;
>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>> +
>>>>>>       if (!end_ptr)
>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>       length = end_ptr - ptr;
>>>>>>
>>>>>> +      if (*ptr == '=')
>>>>>> +        {
>>>>>> +          /* Interpret rest of the argument as a dump filename.  This
>>>>>> +             filename overrides generated dump names as well as other
>>>>>> +             command line filenames.  */
>>>>>> +          flags |= TDF_FILENAME;
>>>>>> +          if (dfi->filename)
>>>>>> +            free (dfi->filename);
>>>>>> +          dfi->filename = xstrdup (ptr + 1);
>>>>>> +          break;
>>>>>> +        }
>>>>>> +
>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>> -         {
>>>>>> -           flags |= option_ptr->value;
>>>>>> +          {
>>>>>> +            flags |= option_ptr->value;
>>>>>>            goto found;
>>>>>> -         }
>>>>>> +          }
>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>               length, ptr, dfi->swtch);
>>>>>>     found:;
>>>>>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>      known dumps.  */
>>>>>>   if (dfi->suffix == NULL)
>>>>>> -    dump_enable_all (dfi->flags);
>>>>>> +    dump_enable_all (dfi->flags, dfi->filename);
>>>>>>
>>>>>>   return 1;
>>>>>>  }
>>>>>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>>>>>  bool
>>>>>>  enable_rtl_dump_file (void)
>>>>>>  {
>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>  }
>>>>>> Index: tree-pass.h
>>>>>> ===================================================================
>>>>>> --- tree-pass.h (revision 187265)
>>>>>> +++ tree-pass.h (working copy)
>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>>>>>> +                                           instead of constructing one. */
>>>>>>
>>>>>> -
>>>>>>  /* In tree-dump.c */
>>>>>>
>>>>>>  extern char *get_dump_file_name (int);
>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>   const char *swtch;            /* command line switch */
>>>>>>   const char *glob;             /* command line glob  */
>>>>>> +  const char *filename;         /* use this filename instead of making
>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>   int flags;                    /* user flags */
>>>>>>   int state;                    /* state of play */
>>>>>>   int num;                      /* dump file number */
>>>>>> Index: testsuite/g++.dg/other/dump-filename-1.C
>>>>>> ===================================================================
>>>>>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>>> @@ -0,0 +1,11 @@
>>>>>> +// Test that the dump to a user-defined file works correctly.
>>>>>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>>>>>> +
>>>>>> +void test (int *b, int *e, int stride)
>>>>>> +  {
>>>>>> +    for (int *p = b; p != e; p += stride)
>>>>>> +      *p = 1;
>>>>>> +  }
>>>>>> +
>>>>>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>>>>>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>>>>>
>>>>>>
>>>>>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>> [...]
>>>>>>>
>>>>>>>> +@item -fdump-rtl-all=stderr
>>>>>>>> +@opindex fdump-rtl-all=stderr
>>>>>>>
>>>>>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>>>>>> Rather, expand the description to state this in all the documentation
>>>>>>> for -fdump-xxx=yyy.
>>>>>>>
>>>>>>> [...]
>>>>>>>
>>>>>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>>>>>> +   stderr stream.  */
>>>>>>>> +
>>>>>>>> +static int
>>>>>>>> +dump_stream_p (const char *user_filename)
>>>>>>>> +{
>>>>>>>> +  if (user_filename)
>>>>>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>>>>>> +      !strncmp ("stdout", user_filename, 6);
>>>>>>>> +  else
>>>>>>>> +    return 0;
>>>>>>>> +}
>>>>>>>
>>>>>>> The name is ambiguous.
>>>>>>> This function is testing whether its string argument designates one of
>>>>>>> the *standard* output streams.  Name it to reflect that..
>>>>>>> Have it take the dump state context. Also the coding convention: the binary
>>>>>>> operator "||" should be on next line.  In fact the thing could be
>>>>>>> simpler.   Instead of
>>>>>>> testing over and over again against "stderr" (once in this function, then again
>>>>>>> later), just return the corresponding standard FILE* pointer.
>>>>>>> Also, this is a case of overuse of strncmp.  If you name the function
>>>>>>> dump_get_standard_stream:
>>>>>>>
>>>>>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>>>>>       ? stderr
>>>>>>>        : stdcmp("stdout", dfi->use_filename)
>>>>>>>        ?  stdout
>>>>>>>        : NULL;
>>>>>>>
>>>>>>> you can simplify:
>>>>>>>
>>>>>>>> -  name = get_dump_file_name (phase);
>>>>>>>>   dfi = get_dump_file_info (phase);
>>>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>> -  if (!stream)
>>>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>>>> +  if (dump_stream_p (dfi->user_filename))
>>>>>>>> +    {
>>>>>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>>>>>> +        stream = stderr;
>>>>>>>> +      else
>>>>>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>>>>>> +          stream = stdout;
>>>>>>>> +        else
>>>>>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>>>>>> +      dfi->state = 1;
>>>>>>>> +    }
>>>>>>>>   else
>>>>>>>> -    dfi->state = 1;
>>>>>>>> -  free (name);
>>>>>>>> +    {
>>>>>>>> +      name = get_dump_file_name (phase);
>>>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>> +      if (!stream)
>>>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>>>> +      else
>>>>>>>> +        dfi->state = 1;
>>>>>>>> +      free (name);
>>>>>>>> +    }
>>>>>>>>
>>>>>>>>   if (flag_ptr)
>>>>>>>>     *flag_ptr = dfi->flags;
>>>>>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>>>>>    dump_begin.  */
>>>>>>>>
>>>>>>>>  void
>>>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>>>  {
>>>>>>>> -  fclose (stream);
>>>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>>>>>> +    fclose (stream);
>>>>>>>>  }
>>>>>>>>
>>>>>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>>>
>>>>>>>>  static int
>>>>>>>> -dump_enable_all (int flags)
>>>>>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>>>>>  {
>>>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>>>   int n = 0;
>>>>>>>>   size_t i;
>>>>>>>>
>>>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>>>> -      {
>>>>>>>> -        dump_files[i].state = -1;
>>>>>>>> -        dump_files[i].flags |= flags;
>>>>>>>> -        n++;
>>>>>>>> -      }
>>>>>>>> +    {
>>>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>>>> +        {
>>>>>>>> +          dump_files[i].state = -1;
>>>>>>>> +          dump_files[i].flags |= flags;
>>>>>>>> +          n++;
>>>>>>>> +        }
>>>>>>>> +      if (user_filename)
>>>>>>>> +        dump_files[i].user_filename = user_filename;
>>>>>>>> +    }
>>>>>>>>
>>>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>> -      {
>>>>>>>> -        extra_dump_files[i].state = -1;
>>>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>>>> -       n++;
>>>>>>>> -      }
>>>>>>>> +    {
>>>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>> +        {
>>>>>>>> +          extra_dump_files[i].state = -1;
>>>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>>>> +          n++;
>>>>>>>> +        }
>>>>>>>> +      if (user_filename)
>>>>>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>>>>>> +    }
>>>>>>>>
>>>>>>>>   return n;
>>>>>>>>  }
>>>>>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>   if (!option_value)
>>>>>>>>     return 0;
>>>>>>>>
>>>>>>>> -  if (*option_value && *option_value != '-')
>>>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>>>     return 0;
>>>>>>>>
>>>>>>>>   ptr = option_value;
>>>>>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>       while (*ptr == '-')
>>>>>>>>        ptr++;
>>>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>>>> +
>>>>>>>>       if (!end_ptr)
>>>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>>>       length = end_ptr - ptr;
>>>>>>>>
>>>>>>>> +      if (*ptr == '=')
>>>>>>>> +        {
>>>>>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>>>>>> +             user provided filename overrides generated dump names as
>>>>>>>> +             well as other command line filenames.  */
>>>>>>>> +          flags |= TDF_USER_FILENAME;
>>>>>>>> +          if (dfi->user_filename)
>>>>>>>> +            free (dfi->user_filename);
>>>>>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>>>>>> +          break;
>>>>>>>> +        }
>>>>>>>> +
>>>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>>>> -         {
>>>>>>>> -           flags |= option_ptr->value;
>>>>>>>> +          {
>>>>>>>> +            flags |= option_ptr->value;
>>>>>>>>            goto found;
>>>>>>>> -         }
>>>>>>>> +          }
>>>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>>>               length, ptr, dfi->swtch);
>>>>>>>>     found:;
>>>>>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>>>      known dumps.  */
>>>>>>>>   if (dfi->suffix == NULL)
>>>>>>>> -    dump_enable_all (dfi->flags);
>>>>>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>>>>>
>>>>>>>>   return 1;
>>>>>>>>  }
>>>>>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>>>>>  bool
>>>>>>>>  enable_rtl_dump_file (void)
>>>>>>>>  {
>>>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>>>  }
>>>>>>>> Index: tree-pass.h
>>>>>>>> ===================================================================
>>>>>>>> --- tree-pass.h (revision 187265)
>>>>>>>> +++ tree-pass.h (working copy)
>>>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>>>>>> +                                           instead of constructing one. */
>>>>>>>>
>>>>>>>> -
>>>>>>>>  /* In tree-dump.c */
>>>>>>>>
>>>>>>>>  extern char *get_dump_file_name (int);
>>>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>>>   const char *swtch;            /* command line switch */
>>>>>>>>   const char *glob;             /* command line glob  */
>>>>>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>>
>>>>>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>>>>>
>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-11 18:12               ` Xinliang David Li
@ 2012-05-12 10:31                 ` Richard Guenther
  2012-05-12 16:06                   ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-05-12 10:31 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

On Fri, May 11, 2012 at 8:11 PM, Xinliang David Li <davidxl@google.com> wrote:
> To be more specific, does the following match what your envisioned?
>
> 1) when multiple streams are specified for dumping, the information
> will be dumped to all streams IF the new dumping interfaces are used
> (see below). For legacy code, the default dump file will still be used
> and the user specified file (including stderr) will be silently
> ignored. This is of course temporary until all dumping sites are
> converted

Yes, that sounds reasonable.

> 2) Define the following new dumping interfaces which will honor all
> streams specified
>
>  dump_printf (const char*, ....);   // for raw string dumping
>  dump_generic_expr (...); //  wrapper to print_generic_expr without
> taking FILE*
>  dump_node (...); // wrapper to print_node
>  dump_gimple_stmt(...); // wrapper to print_gimple_stmt

Yes.  Please add a classification argument to each of the wrappers
to allow selective filtering (I'd simply use the existing TDF_* flags
for now - in the future they should be made more granular than
0 vs. TDF_details).

The existing if (dump_file && (dump_flags & ...)) checks need to be
adjusted, of course.  if (dump_enabled_p ()) or if (dump_enabled_p (flags)).

>  dump_inform (...); //wrapper to inform (..) method, but is aware of
> of the dumping streams and modify global_dc appropriately.

inform () is not part of the dumping infrastructure, thus passes should not
use it.  The dumping implementation, if re-directed via -fopt-report, might
use inform () to print messages though.

> 3) Implement -fopt-info=N, and take -ftree-vectorizer-verbose as the
> first guinea pig to use the new dumping interfaces.

Yes, I think all of 1) to 2) do not make sense without 3), so I'd prefer
to see all that (well, the relevant bits of 2) to make 3) work) together.

> After the infrastructure is ready, gradually deprecate the use of the
> original dumper interfaces.

Yes, passes can be converted independently.

> what do you think?

That plan sounds good to me.

Thanks,
Richard.

> thanks,
>
> David
>
> On Fri, May 11, 2012 at 9:06 AM, Xinliang David Li <davidxl@google.com> wrote:
>> On Fri, May 11, 2012 at 1:49 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Thu, May 10, 2012 at 6:28 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>> I like your suggestion and support the end goal you have.  I don't
>>>> like the -fopt-info behavior to interfere with regular -fdump-xxx
>>>> options either.
>>>>
>>>> I think we should stage the changes in multiple steps as originally
>>>> planned. Is Sharad's change good to be checked in for the first stage?
>>>
>>> Well - I don't think the change walks in the direction we want to go, so I don't
>>> see a good reason to make that change.
>>
>> Is your direction misunderstood or you want everything to be changed
>> in one single patch (including replacement of all fprintf (dump_file,
>> ...)? If the former, please clarify. If the latter, it can be done.
>>
>> thanks,
>>
>> David
>>
>>>
>>>> After this one is checked in, the new dump interfaces will be worked
>>>> on (and to allow multiple streams). Most of the remaining changes will
>>>> be massive text replacement.
>>>>
>>>> thanks,
>>>>
>>>> David
>>>>
>>>>
>>>> On Thu, May 10, 2012 at 1:18 AM, Richard Guenther
>>>> <richard.guenther@gmail.com> wrote:
>>>>> On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>> Bummer.  I was thinking to reserve '=' for selective  dumping:
>>>>>>
>>>>>> -fdump-tree-pre=<func_list_regexp>
>>>>>>
>>>>>> I guess this can be achieved via @
>>>>>>
>>>>>> -fdump-tree-pre@<func_list>
>>>>>>
>>>>>> -fdump-tree-pre=<file_name>@<func_list>
>>>>>>
>>>>>>
>>>>>> Another issue -- I don't think the current precedence rule is correct.
>>>>>> Consider that -fopt-info=2 will be mapped to
>>>>>>
>>>>>> -fdump-tree-all-transform-verbose2=stderr
>>>>>> -fdump-rtl-all-transform-verbose2=stderr
>>>>>>
>>>>>> then
>>>>>>
>>>>>> the current precedence rule will cause surprise when the following is used
>>>>>>
>>>>>> -fopt-info -fdump-tree-pre
>>>>>>
>>>>>> The PRE dump will be emitted to stderr which is not what user wants.
>>>>>> In short, special streams should be treated as 'weak' the same way as
>>>>>> your previous implementation.
>>>>>
>>>>> Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
>>>>> With -fopt-info -fdump-tree-pre I do not want some information to be
>>>>> present only on stderr or in the dump file!  I want it in _both_ places!
>>>>> (-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
>>>>> information :()
>>>>>
>>>>> Thus, the information where dumping goes has to be done differently
>>>>> (which is why I asked for some re-org originally, so that passes no
>>>>> longer explicitely reference dump_file - dump_file may be different
>>>>> for different kind of information it dumps!).  Passes should, instead of
>>>>>
>>>>>  fprintf (dump_file, "...", ...)
>>>>>
>>>>> do
>>>>>
>>>>>  dump_printf (TDF_scev, "...", ...)
>>>>>
>>>>> thus, specify the kind of information they dump (would be mostly
>>>>> TDF_details vs. 0 today I guess).  The dump_printf routine would
>>>>> then properly direct to one or more places to dump at.
>>>>>
>>>>> I realize this needs some more dispatchers for dumping expressions
>>>>> and statements (but it should not be too many).  Dumping to
>>>>> dump_file would in any case dump to the passes private dump file
>>>>> only (unqualified stuff would never be useful for -fopt-info).
>>>>>
>>>>> The perfect candidate to convert to this kind of scheme is obviously
>>>>> the vectorizer with its existing -fvectorizer-verbose.
>>>>>
>>>>> If the patch doesn't work towards this kind of end-result I'd rather
>>>>> not have it.
>>>>>
>>>>> Thanks,
>>>>> Richard.
>>>>>
>>>>>> thanks,
>>>>>>
>>>>>> David
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>> Thanks for your suggestions/comments. I have updated the patch and
>>>>>>> documentation. It supports the following usage:
>>>>>>>
>>>>>>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>>>>>>> -fdump-rtl-ira=ira.dump
>>>>>>>
>>>>>>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>>>>>>> goes to stdout and the IRA dump goes to ira.dump.
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sharad
>>>>>>>
>>>>>>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>>>>>>
>>>>>>>        * doc/invoke.texi: Add documentation for the new option.
>>>>>>>        * tree-dump.c (dump_get_standard_stream): New function.
>>>>>>>        (dump_files): Update for new field.
>>>>>>>        (dump_switch_p_1): Handle dump filenames.
>>>>>>>        (dump_begin): Likewise.
>>>>>>>        (get_dump_file_name): Likewise.
>>>>>>>        (dump_end): Remove attribute.
>>>>>>>        (dump_enable_all): Add new parameter FILENAME.
>>>>>>>        All callers updated.
>>>>>>>        (enable_rtl_dump_file):
>>>>>>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>>>>>>        (struct dump_file_info): Add new field FILENAME.
>>>>>>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>>>>>>
>>>>>>> Index: doc/invoke.texi
>>>>>>> ===================================================================
>>>>>>> --- doc/invoke.texi     (revision 187265)
>>>>>>> +++ doc/invoke.texi     (working copy)
>>>>>>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>>>>>>
>>>>>>>  @item -d@var{letters}
>>>>>>>  @itemx -fdump-rtl-@var{pass}
>>>>>>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>>>>>>  @opindex d
>>>>>>>  Says to make debugging dumps during compilation at times specified by
>>>>>>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>>>>>>  compiler.  The file names for most of the dumps are made by appending
>>>>>>>  a pass number and a word to the @var{dumpname}, and the files are
>>>>>>> -created in the directory of the output file.  Note that the pass
>>>>>>> -number is computed statically as passes get registered into the pass
>>>>>>> -manager.  Thus the numbering is not related to the dynamic order of
>>>>>>> -execution of passes.  In particular, a pass installed by a plugin
>>>>>>> -could have a number over 200 even if it executed quite early.
>>>>>>> -@var{dumpname} is generated from the name of the output file, if
>>>>>>> -explicitly specified and it is not an executable, otherwise it is the
>>>>>>> -basename of the source file. These switches may have different effects
>>>>>>> -when @option{-E} is used for preprocessing.
>>>>>>> +created in the directory of the output file. If the
>>>>>>> +@option{=@var{filename}} is appended to the longer form of the dump
>>>>>>> +option then the dump is done on that file instead of numbered
>>>>>>> +files. Note that the pass number is computed statically as passes get
>>>>>>> +registered into the pass manager.  Thus the numbering is not related
>>>>>>> +to the dynamic order of execution of passes.  In particular, a pass
>>>>>>> +installed by a plugin could have a number over 200 even if it executed
>>>>>>> +quite early.  @var{dumpname} is generated from the name of the output
>>>>>>> +file, if explicitly specified and it is not an executable, otherwise
>>>>>>> +it is the basename of the source file. These switches may have
>>>>>>> +different effects when @option{-E} is used for preprocessing.
>>>>>>>
>>>>>>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>>>>>>  @option{-d} option @var{letters}.  Here are the possible
>>>>>>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>>>>>>
>>>>>>>  @item -fdump-tree-@var{switch}
>>>>>>>  @itemx -fdump-tree-@var{switch}-@var{options}
>>>>>>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>>>>>>  @opindex fdump-tree
>>>>>>>  Control the dumping at various stages of processing the intermediate
>>>>>>>  language tree to a file.  The file name is generated by appending a
>>>>>>>  switch specific suffix to the source file name, and the file is
>>>>>>> -created in the same directory as the output file.  If the
>>>>>>> -@samp{-@var{options}} form is used, @var{options} is a list of
>>>>>>> -@samp{-} separated options which control the details of the dump.  Not
>>>>>>> -all options are applicable to all dumps; those that are not
>>>>>>> -meaningful are ignored.  The following options are available
>>>>>>> +created in the same directory as the output file. In case of
>>>>>>> +@option{=@var{filename}} option, the dump is output on the given file
>>>>>>> +name instead.  If the @samp{-@var{options}} form is used,
>>>>>>> +@var{options} is a list of @samp{-} separated options which control
>>>>>>> +the details or location of the dump.  Not all options are applicable
>>>>>>> +to all dumps; those that are not meaningful are ignored.  The
>>>>>>> +following options are available
>>>>>>>
>>>>>>>  @table @samp
>>>>>>>  @item address
>>>>>>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>>>>>>  Enable showing the EH region number holding each statement.
>>>>>>>  @item scev
>>>>>>>  Enable showing scalar evolution analysis details.
>>>>>>> +@item slim
>>>>>>> +Inhibit dumping of members of a scope or body of a function merely
>>>>>>> +because that scope has been reached.  Only dump such items when they
>>>>>>> +are directly reachable by some other path.  When dumping pretty-printed
>>>>>>> +trees, this option inhibits dumping the bodies of control structures.
>>>>>>> +@item =@var{filename}
>>>>>>> +Instead of using an auto generated dump file name, use the given file
>>>>>>> +name. The file names @file{stdout} and @file{stderr} are treated
>>>>>>> +specially and are considered already open standard streams. For
>>>>>>> +example:
>>>>>>> +
>>>>>>> +@smallexample
>>>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>>>>>>> +@end smallexample
>>>>>>> +
>>>>>>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>>>>>>> +file named @file{ira.txt}.
>>>>>>> +
>>>>>>> +In case of any conflicts, the command line file name takes precedence
>>>>>>> +over generated file names. For example:
>>>>>>> +
>>>>>>> +@smallexample
>>>>>>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>>>>>>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>>>>>>> +@end smallexample
>>>>>>> +
>>>>>>> +Both of the above output the PRE dump on @file{stdout}. However, if
>>>>>>> +there are multiple command line file names are applicable then the
>>>>>>> +last one is used. Thus the command
>>>>>>> +
>>>>>>> +@smallexample
>>>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>>>>>>> +@end smallexample
>>>>>>> +
>>>>>>> +outputs all the dumps in @file{all.txt} because the stderr option for
>>>>>>> +PRE dump is overridden by a later option.
>>>>>>> +
>>>>>>>  @item all
>>>>>>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>>>>>> -and @option{lineno}.
>>>>>>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>>>>>>> +@option{lineno}.
>>>>>>>  @end table
>>>>>>>
>>>>>>>  The following tree dumps are possible:
>>>>>>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>>>>>>  @item all
>>>>>>>  @opindex fdump-tree-all
>>>>>>>  Enable all the available tree dumps with the flags provided in this option.
>>>>>>> +
>>>>>>>  @end table
>>>>>>>
>>>>>>>  @item -ftree-vectorizer-verbose=@var{n}
>>>>>>> Index: tree-dump.c
>>>>>>> ===================================================================
>>>>>>> --- tree-dump.c (revision 187265)
>>>>>>> +++ tree-dump.c (working copy)
>>>>>>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>>>>>>    tree_dump_index enumeration in tree-pass.h.  */
>>>>>>>  static struct dump_file_info dump_files[TDI_end] =
>>>>>>>  {
>>>>>>> -  {NULL, NULL, NULL, 0, 0, 0},
>>>>>>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>>>>>>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>>>>>>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>>>>>>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>>>>>>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>>>>>>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>>>>>>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>>>>>>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>>>>>>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>>>>>>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>>>>>>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>>>>>>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>>>>>>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>>>>>>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>>>>>>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>>>>>>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>>>>>>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>>>>>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>>>>>>
>>>>>>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>>>>>>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>>>>>>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>>>>>>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>>>>>>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>>>>>>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>>>>>>  };
>>>>>>>
>>>>>>>  /* Dynamically registered tree dump files and switches.  */
>>>>>>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>>>>>>  };
>>>>>>>
>>>>>>>  /* Table of dump options. This must be consistent with the TDF_* flags
>>>>>>> -   in tree.h */
>>>>>>> +   in tree-pass.h */
>>>>>>>  static const struct dump_option_value_info dump_options[] =
>>>>>>>  {
>>>>>>>   {"address", TDF_ADDRESS},
>>>>>>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>>>>>>   if (dfi->state == 0)
>>>>>>>     return NULL;
>>>>>>>
>>>>>>> +  if (dfi->filename)
>>>>>>> +    return xstrdup (dfi->filename);
>>>>>>> +
>>>>>>>   if (dfi->num < 0)
>>>>>>>     dump_id[0] = '\0';
>>>>>>>   else
>>>>>>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>>>>>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>>>>>>  }
>>>>>>>
>>>>>>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>>>>>>> +   return that stream, NULL otherwise.  */
>>>>>>> +
>>>>>>> +static FILE *
>>>>>>> +dump_get_standard_stream (struct dump_file_info *dfi)
>>>>>>> +{
>>>>>>> +  if (!dfi->filename)
>>>>>>> +    return NULL;
>>>>>>> +
>>>>>>> +  return strcmp("stderr", dfi->filename) == 0
>>>>>>> +    ? stderr
>>>>>>> +    : strcmp("stdout", dfi->filename) == 0
>>>>>>> +    ?  stdout
>>>>>>> +    : NULL;
>>>>>>> +}
>>>>>>> +
>>>>>>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>>>>>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>>>>>>    enabled, returns NULL.
>>>>>>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>>>>>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>>>>>>     return NULL;
>>>>>>>
>>>>>>> -  name = get_dump_file_name (phase);
>>>>>>>   dfi = get_dump_file_info (phase);
>>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>> -  if (!stream)
>>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>>> +  stream = dump_get_standard_stream (dfi);
>>>>>>> +  if (stream)
>>>>>>> +    dfi->state = 1;
>>>>>>>   else
>>>>>>> -    dfi->state = 1;
>>>>>>> -  free (name);
>>>>>>> +    {
>>>>>>> +      name = get_dump_file_name (phase);
>>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>> +      if (!stream)
>>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>>> +      else
>>>>>>> +        dfi->state = 1;
>>>>>>> +      free (name);
>>>>>>> +    }
>>>>>>>
>>>>>>>   if (flag_ptr)
>>>>>>>     *flag_ptr = dfi->flags;
>>>>>>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>>>>>>    dump_begin.  */
>>>>>>>
>>>>>>>  void
>>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>>  {
>>>>>>> -  fclose (stream);
>>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>>> +  if (!dump_get_standard_stream (dfi))
>>>>>>> +    fclose (stream);
>>>>>>>  }
>>>>>>>
>>>>>>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>>>>>>> +   enabled tree dumps.  */
>>>>>>>
>>>>>>>  static int
>>>>>>> -dump_enable_all (int flags)
>>>>>>> +dump_enable_all (int flags, const char *filename)
>>>>>>>  {
>>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>>   int n = 0;
>>>>>>>   size_t i;
>>>>>>>
>>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>>> -      {
>>>>>>> -        dump_files[i].state = -1;
>>>>>>> -        dump_files[i].flags |= flags;
>>>>>>> -        n++;
>>>>>>> -      }
>>>>>>> +    {
>>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>>> +        {
>>>>>>> +          dump_files[i].state = -1;
>>>>>>> +          dump_files[i].flags |= flags;
>>>>>>> +          n++;
>>>>>>> +          if (filename)
>>>>>>> +            dump_files[i].filename = xstrdup (filename);
>>>>>>> +        }
>>>>>>> +    }
>>>>>>>
>>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>> -      {
>>>>>>> -        extra_dump_files[i].state = -1;
>>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>>> -       n++;
>>>>>>> -      }
>>>>>>> +    {
>>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>> +        {
>>>>>>> +          extra_dump_files[i].state = -1;
>>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>>> +          n++;
>>>>>>> +          if (filename)
>>>>>>> +            extra_dump_files[i].filename = xstrdup (filename);
>>>>>>> +        }
>>>>>>> +    }
>>>>>>>
>>>>>>>   return n;
>>>>>>>  }
>>>>>>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>   if (!option_value)
>>>>>>>     return 0;
>>>>>>>
>>>>>>> -  if (*option_value && *option_value != '-')
>>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>>     return 0;
>>>>>>>
>>>>>>>   ptr = option_value;
>>>>>>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>       while (*ptr == '-')
>>>>>>>        ptr++;
>>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>>> +
>>>>>>>       if (!end_ptr)
>>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>>       length = end_ptr - ptr;
>>>>>>>
>>>>>>> +      if (*ptr == '=')
>>>>>>> +        {
>>>>>>> +          /* Interpret rest of the argument as a dump filename.  This
>>>>>>> +             filename overrides generated dump names as well as other
>>>>>>> +             command line filenames.  */
>>>>>>> +          flags |= TDF_FILENAME;
>>>>>>> +          if (dfi->filename)
>>>>>>> +            free (dfi->filename);
>>>>>>> +          dfi->filename = xstrdup (ptr + 1);
>>>>>>> +          break;
>>>>>>> +        }
>>>>>>> +
>>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>>> -         {
>>>>>>> -           flags |= option_ptr->value;
>>>>>>> +          {
>>>>>>> +            flags |= option_ptr->value;
>>>>>>>            goto found;
>>>>>>> -         }
>>>>>>> +          }
>>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>>               length, ptr, dfi->swtch);
>>>>>>>     found:;
>>>>>>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>>      known dumps.  */
>>>>>>>   if (dfi->suffix == NULL)
>>>>>>> -    dump_enable_all (dfi->flags);
>>>>>>> +    dump_enable_all (dfi->flags, dfi->filename);
>>>>>>>
>>>>>>>   return 1;
>>>>>>>  }
>>>>>>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>>>>>>  bool
>>>>>>>  enable_rtl_dump_file (void)
>>>>>>>  {
>>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>>  }
>>>>>>> Index: tree-pass.h
>>>>>>> ===================================================================
>>>>>>> --- tree-pass.h (revision 187265)
>>>>>>> +++ tree-pass.h (working copy)
>>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>>>>>>> +                                           instead of constructing one. */
>>>>>>>
>>>>>>> -
>>>>>>>  /* In tree-dump.c */
>>>>>>>
>>>>>>>  extern char *get_dump_file_name (int);
>>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>>   const char *swtch;            /* command line switch */
>>>>>>>   const char *glob;             /* command line glob  */
>>>>>>> +  const char *filename;         /* use this filename instead of making
>>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>>   int flags;                    /* user flags */
>>>>>>>   int state;                    /* state of play */
>>>>>>>   int num;                      /* dump file number */
>>>>>>> Index: testsuite/g++.dg/other/dump-filename-1.C
>>>>>>> ===================================================================
>>>>>>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>>>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>>>> @@ -0,0 +1,11 @@
>>>>>>> +// Test that the dump to a user-defined file works correctly.
>>>>>>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>>>>>>> +
>>>>>>> +void test (int *b, int *e, int stride)
>>>>>>> +  {
>>>>>>> +    for (int *p = b; p != e; p += stride)
>>>>>>> +      *p = 1;
>>>>>>> +  }
>>>>>>> +
>>>>>>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>>>>>>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>>>>>>
>>>>>>>
>>>>>>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>>> [...]
>>>>>>>>
>>>>>>>>> +@item -fdump-rtl-all=stderr
>>>>>>>>> +@opindex fdump-rtl-all=stderr
>>>>>>>>
>>>>>>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>>>>>>> Rather, expand the description to state this in all the documentation
>>>>>>>> for -fdump-xxx=yyy.
>>>>>>>>
>>>>>>>> [...]
>>>>>>>>
>>>>>>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>>>>>>> +   stderr stream.  */
>>>>>>>>> +
>>>>>>>>> +static int
>>>>>>>>> +dump_stream_p (const char *user_filename)
>>>>>>>>> +{
>>>>>>>>> +  if (user_filename)
>>>>>>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>>>>>>> +      !strncmp ("stdout", user_filename, 6);
>>>>>>>>> +  else
>>>>>>>>> +    return 0;
>>>>>>>>> +}
>>>>>>>>
>>>>>>>> The name is ambiguous.
>>>>>>>> This function is testing whether its string argument designates one of
>>>>>>>> the *standard* output streams.  Name it to reflect that..
>>>>>>>> Have it take the dump state context. Also the coding convention: the binary
>>>>>>>> operator "||" should be on next line.  In fact the thing could be
>>>>>>>> simpler.   Instead of
>>>>>>>> testing over and over again against "stderr" (once in this function, then again
>>>>>>>> later), just return the corresponding standard FILE* pointer.
>>>>>>>> Also, this is a case of overuse of strncmp.  If you name the function
>>>>>>>> dump_get_standard_stream:
>>>>>>>>
>>>>>>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>>>>>>       ? stderr
>>>>>>>>        : stdcmp("stdout", dfi->use_filename)
>>>>>>>>        ?  stdout
>>>>>>>>        : NULL;
>>>>>>>>
>>>>>>>> you can simplify:
>>>>>>>>
>>>>>>>>> -  name = get_dump_file_name (phase);
>>>>>>>>>   dfi = get_dump_file_info (phase);
>>>>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>>> -  if (!stream)
>>>>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>>>>> +  if (dump_stream_p (dfi->user_filename))
>>>>>>>>> +    {
>>>>>>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>>>>>>> +        stream = stderr;
>>>>>>>>> +      else
>>>>>>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>>>>>>> +          stream = stdout;
>>>>>>>>> +        else
>>>>>>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>>>>>>> +      dfi->state = 1;
>>>>>>>>> +    }
>>>>>>>>>   else
>>>>>>>>> -    dfi->state = 1;
>>>>>>>>> -  free (name);
>>>>>>>>> +    {
>>>>>>>>> +      name = get_dump_file_name (phase);
>>>>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>>> +      if (!stream)
>>>>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>>>>> +      else
>>>>>>>>> +        dfi->state = 1;
>>>>>>>>> +      free (name);
>>>>>>>>> +    }
>>>>>>>>>
>>>>>>>>>   if (flag_ptr)
>>>>>>>>>     *flag_ptr = dfi->flags;
>>>>>>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>>>>>>    dump_begin.  */
>>>>>>>>>
>>>>>>>>>  void
>>>>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>>>>  {
>>>>>>>>> -  fclose (stream);
>>>>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>>>>>>> +    fclose (stream);
>>>>>>>>>  }
>>>>>>>>>
>>>>>>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>>>>
>>>>>>>>>  static int
>>>>>>>>> -dump_enable_all (int flags)
>>>>>>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>>>>>>  {
>>>>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>>>>   int n = 0;
>>>>>>>>>   size_t i;
>>>>>>>>>
>>>>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>>>>> -      {
>>>>>>>>> -        dump_files[i].state = -1;
>>>>>>>>> -        dump_files[i].flags |= flags;
>>>>>>>>> -        n++;
>>>>>>>>> -      }
>>>>>>>>> +    {
>>>>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>>>>> +        {
>>>>>>>>> +          dump_files[i].state = -1;
>>>>>>>>> +          dump_files[i].flags |= flags;
>>>>>>>>> +          n++;
>>>>>>>>> +        }
>>>>>>>>> +      if (user_filename)
>>>>>>>>> +        dump_files[i].user_filename = user_filename;
>>>>>>>>> +    }
>>>>>>>>>
>>>>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>>> -      {
>>>>>>>>> -        extra_dump_files[i].state = -1;
>>>>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>>>>> -       n++;
>>>>>>>>> -      }
>>>>>>>>> +    {
>>>>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>>> +        {
>>>>>>>>> +          extra_dump_files[i].state = -1;
>>>>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>>>>> +          n++;
>>>>>>>>> +        }
>>>>>>>>> +      if (user_filename)
>>>>>>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>>>>>>> +    }
>>>>>>>>>
>>>>>>>>>   return n;
>>>>>>>>>  }
>>>>>>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>>   if (!option_value)
>>>>>>>>>     return 0;
>>>>>>>>>
>>>>>>>>> -  if (*option_value && *option_value != '-')
>>>>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>>>>     return 0;
>>>>>>>>>
>>>>>>>>>   ptr = option_value;
>>>>>>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>>       while (*ptr == '-')
>>>>>>>>>        ptr++;
>>>>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>>>>> +
>>>>>>>>>       if (!end_ptr)
>>>>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>>>>       length = end_ptr - ptr;
>>>>>>>>>
>>>>>>>>> +      if (*ptr == '=')
>>>>>>>>> +        {
>>>>>>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>>>>>>> +             user provided filename overrides generated dump names as
>>>>>>>>> +             well as other command line filenames.  */
>>>>>>>>> +          flags |= TDF_USER_FILENAME;
>>>>>>>>> +          if (dfi->user_filename)
>>>>>>>>> +            free (dfi->user_filename);
>>>>>>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>>>>>>> +          break;
>>>>>>>>> +        }
>>>>>>>>> +
>>>>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>>>>> -         {
>>>>>>>>> -           flags |= option_ptr->value;
>>>>>>>>> +          {
>>>>>>>>> +            flags |= option_ptr->value;
>>>>>>>>>            goto found;
>>>>>>>>> -         }
>>>>>>>>> +          }
>>>>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>>>>               length, ptr, dfi->swtch);
>>>>>>>>>     found:;
>>>>>>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>>>>      known dumps.  */
>>>>>>>>>   if (dfi->suffix == NULL)
>>>>>>>>> -    dump_enable_all (dfi->flags);
>>>>>>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>>>>>>
>>>>>>>>>   return 1;
>>>>>>>>>  }
>>>>>>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>>>>>>  bool
>>>>>>>>>  enable_rtl_dump_file (void)
>>>>>>>>>  {
>>>>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>>>>  }
>>>>>>>>> Index: tree-pass.h
>>>>>>>>> ===================================================================
>>>>>>>>> --- tree-pass.h (revision 187265)
>>>>>>>>> +++ tree-pass.h (working copy)
>>>>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>>>>>>> +                                           instead of constructing one. */
>>>>>>>>>
>>>>>>>>> -
>>>>>>>>>  /* In tree-dump.c */
>>>>>>>>>
>>>>>>>>>  extern char *get_dump_file_name (int);
>>>>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>>>>   const char *swtch;            /* command line switch */
>>>>>>>>>   const char *glob;             /* command line glob  */
>>>>>>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>>>
>>>>>>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>>>>>>
>>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-12 10:31                 ` Richard Guenther
@ 2012-05-12 16:06                   ` Xinliang David Li
  2012-05-12 16:26                     ` Gabriel Dos Reis
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-05-12 16:06 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, reply, Andrew Pinski

Sounds good.

On Sat, May 12, 2012 at 3:31 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, May 11, 2012 at 8:11 PM, Xinliang David Li <davidxl@google.com> wrote:
>> To be more specific, does the following match what your envisioned?
>>
>> 1) when multiple streams are specified for dumping, the information
>> will be dumped to all streams IF the new dumping interfaces are used
>> (see below). For legacy code, the default dump file will still be used
>> and the user specified file (including stderr) will be silently
>> ignored. This is of course temporary until all dumping sites are
>> converted
>
> Yes, that sounds reasonable.
>
>> 2) Define the following new dumping interfaces which will honor all
>> streams specified
>>
>>  dump_printf (const char*, ....);   // for raw string dumping
>>  dump_generic_expr (...); //  wrapper to print_generic_expr without
>> taking FILE*
>>  dump_node (...); // wrapper to print_node
>>  dump_gimple_stmt(...); // wrapper to print_gimple_stmt
>
> Yes.  Please add a classification argument to each of the wrappers
> to allow selective filtering (I'd simply use the existing TDF_* flags
> for now - in the future they should be made more granular than
> 0 vs. TDF_details).
>
> The existing if (dump_file && (dump_flags & ...)) checks need to be
> adjusted, of course.  if (dump_enabled_p ()) or if (dump_enabled_p (flags)).
>
>>  dump_inform (...); //wrapper to inform (..) method, but is aware of
>> of the dumping streams and modify global_dc appropriately.
>
> inform () is not part of the dumping infrastructure, thus passes should not
> use it.  The dumping implementation, if re-directed via -fopt-report, might
> use inform () to print messages though.
>

The downside is that the dump file format will look different from the
stderr output which is less than ideal. Setting and restore
diagnostic_context's printter stream is just one-line change, what is
the main concern of doing that?

thanks,

David


>> 3) Implement -fopt-info=N, and take -ftree-vectorizer-verbose as the
>> first guinea pig to use the new dumping interfaces.
>
> Yes, I think all of 1) to 2) do not make sense without 3), so I'd prefer
> to see all that (well, the relevant bits of 2) to make 3) work) together.
>
>> After the infrastructure is ready, gradually deprecate the use of the
>> original dumper interfaces.
>
> Yes, passes can be converted independently.
>
>> what do you think?
>
> That plan sounds good to me.
>
> Thanks,
> Richard.
>
>> thanks,
>>
>> David
>>
>> On Fri, May 11, 2012 at 9:06 AM, Xinliang David Li <davidxl@google.com> wrote:
>>> On Fri, May 11, 2012 at 1:49 AM, Richard Guenther
>>> <richard.guenther@gmail.com> wrote:
>>>> On Thu, May 10, 2012 at 6:28 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> I like your suggestion and support the end goal you have.  I don't
>>>>> like the -fopt-info behavior to interfere with regular -fdump-xxx
>>>>> options either.
>>>>>
>>>>> I think we should stage the changes in multiple steps as originally
>>>>> planned. Is Sharad's change good to be checked in for the first stage?
>>>>
>>>> Well - I don't think the change walks in the direction we want to go, so I don't
>>>> see a good reason to make that change.
>>>
>>> Is your direction misunderstood or you want everything to be changed
>>> in one single patch (including replacement of all fprintf (dump_file,
>>> ...)? If the former, please clarify. If the latter, it can be done.
>>>
>>> thanks,
>>>
>>> David
>>>
>>>>
>>>>> After this one is checked in, the new dump interfaces will be worked
>>>>> on (and to allow multiple streams). Most of the remaining changes will
>>>>> be massive text replacement.
>>>>>
>>>>> thanks,
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> On Thu, May 10, 2012 at 1:18 AM, Richard Guenther
>>>>> <richard.guenther@gmail.com> wrote:
>>>>>> On Thu, May 10, 2012 at 2:31 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>> Bummer.  I was thinking to reserve '=' for selective  dumping:
>>>>>>>
>>>>>>> -fdump-tree-pre=<func_list_regexp>
>>>>>>>
>>>>>>> I guess this can be achieved via @
>>>>>>>
>>>>>>> -fdump-tree-pre@<func_list>
>>>>>>>
>>>>>>> -fdump-tree-pre=<file_name>@<func_list>
>>>>>>>
>>>>>>>
>>>>>>> Another issue -- I don't think the current precedence rule is correct.
>>>>>>> Consider that -fopt-info=2 will be mapped to
>>>>>>>
>>>>>>> -fdump-tree-all-transform-verbose2=stderr
>>>>>>> -fdump-rtl-all-transform-verbose2=stderr
>>>>>>>
>>>>>>> then
>>>>>>>
>>>>>>> the current precedence rule will cause surprise when the following is used
>>>>>>>
>>>>>>> -fopt-info -fdump-tree-pre
>>>>>>>
>>>>>>> The PRE dump will be emitted to stderr which is not what user wants.
>>>>>>> In short, special streams should be treated as 'weak' the same way as
>>>>>>> your previous implementation.
>>>>>>
>>>>>> Hm, this raises a similar concern I have with the -fvectorizer-verbose flag.
>>>>>> With -fopt-info -fdump-tree-pre I do not want some information to be
>>>>>> present only on stderr or in the dump file!  I want it in _both_ places!
>>>>>> (-fvectorizer-verbose makes the -fdump-tree-vect dump contain less
>>>>>> information :()
>>>>>>
>>>>>> Thus, the information where dumping goes has to be done differently
>>>>>> (which is why I asked for some re-org originally, so that passes no
>>>>>> longer explicitely reference dump_file - dump_file may be different
>>>>>> for different kind of information it dumps!).  Passes should, instead of
>>>>>>
>>>>>>  fprintf (dump_file, "...", ...)
>>>>>>
>>>>>> do
>>>>>>
>>>>>>  dump_printf (TDF_scev, "...", ...)
>>>>>>
>>>>>> thus, specify the kind of information they dump (would be mostly
>>>>>> TDF_details vs. 0 today I guess).  The dump_printf routine would
>>>>>> then properly direct to one or more places to dump at.
>>>>>>
>>>>>> I realize this needs some more dispatchers for dumping expressions
>>>>>> and statements (but it should not be too many).  Dumping to
>>>>>> dump_file would in any case dump to the passes private dump file
>>>>>> only (unqualified stuff would never be useful for -fopt-info).
>>>>>>
>>>>>> The perfect candidate to convert to this kind of scheme is obviously
>>>>>> the vectorizer with its existing -fvectorizer-verbose.
>>>>>>
>>>>>> If the patch doesn't work towards this kind of end-result I'd rather
>>>>>> not have it.
>>>>>>
>>>>>> Thanks,
>>>>>> Richard.
>>>>>>
>>>>>>> thanks,
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, May 9, 2012 at 4:56 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>>> Thanks for your suggestions/comments. I have updated the patch and
>>>>>>>> documentation. It supports the following usage:
>>>>>>>>
>>>>>>>> gcc .... -fdump-tree-all=tree.dump -fdump-tree-pre=stdout
>>>>>>>> -fdump-rtl-ira=ira.dump
>>>>>>>>
>>>>>>>> Here all tree dumps except the PRE are output into tree.dump, PRE dump
>>>>>>>> goes to stdout and the IRA dump goes to ira.dump.
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Sharad
>>>>>>>>
>>>>>>>> 2012-05-09   Sharad Singhai  <singhai@google.com>
>>>>>>>>
>>>>>>>>        * doc/invoke.texi: Add documentation for the new option.
>>>>>>>>        * tree-dump.c (dump_get_standard_stream): New function.
>>>>>>>>        (dump_files): Update for new field.
>>>>>>>>        (dump_switch_p_1): Handle dump filenames.
>>>>>>>>        (dump_begin): Likewise.
>>>>>>>>        (get_dump_file_name): Likewise.
>>>>>>>>        (dump_end): Remove attribute.
>>>>>>>>        (dump_enable_all): Add new parameter FILENAME.
>>>>>>>>        All callers updated.
>>>>>>>>        (enable_rtl_dump_file):
>>>>>>>>        * tree-pass.h (enum tree_dump_index): Add new constant.
>>>>>>>>        (struct dump_file_info): Add new field FILENAME.
>>>>>>>>        * testsuite/g++.dg/other/dump-filename-1.C: New test.
>>>>>>>>
>>>>>>>> Index: doc/invoke.texi
>>>>>>>> ===================================================================
>>>>>>>> --- doc/invoke.texi     (revision 187265)
>>>>>>>> +++ doc/invoke.texi     (working copy)
>>>>>>>> @@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
>>>>>>>>
>>>>>>>>  @item -d@var{letters}
>>>>>>>>  @itemx -fdump-rtl-@var{pass}
>>>>>>>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>>>>>>>  @opindex d
>>>>>>>>  Says to make debugging dumps during compilation at times specified by
>>>>>>>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>>>>>>>  compiler.  The file names for most of the dumps are made by appending
>>>>>>>>  a pass number and a word to the @var{dumpname}, and the files are
>>>>>>>> -created in the directory of the output file.  Note that the pass
>>>>>>>> -number is computed statically as passes get registered into the pass
>>>>>>>> -manager.  Thus the numbering is not related to the dynamic order of
>>>>>>>> -execution of passes.  In particular, a pass installed by a plugin
>>>>>>>> -could have a number over 200 even if it executed quite early.
>>>>>>>> -@var{dumpname} is generated from the name of the output file, if
>>>>>>>> -explicitly specified and it is not an executable, otherwise it is the
>>>>>>>> -basename of the source file. These switches may have different effects
>>>>>>>> -when @option{-E} is used for preprocessing.
>>>>>>>> +created in the directory of the output file. If the
>>>>>>>> +@option{=@var{filename}} is appended to the longer form of the dump
>>>>>>>> +option then the dump is done on that file instead of numbered
>>>>>>>> +files. Note that the pass number is computed statically as passes get
>>>>>>>> +registered into the pass manager.  Thus the numbering is not related
>>>>>>>> +to the dynamic order of execution of passes.  In particular, a pass
>>>>>>>> +installed by a plugin could have a number over 200 even if it executed
>>>>>>>> +quite early.  @var{dumpname} is generated from the name of the output
>>>>>>>> +file, if explicitly specified and it is not an executable, otherwise
>>>>>>>> +it is the basename of the source file. These switches may have
>>>>>>>> +different effects when @option{-E} is used for preprocessing.
>>>>>>>>
>>>>>>>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>>>>>>>  @option{-d} option @var{letters}.  Here are the possible
>>>>>>>> @@ -5719,15 +5722,18 @@ counters for each function compiled.
>>>>>>>>
>>>>>>>>  @item -fdump-tree-@var{switch}
>>>>>>>>  @itemx -fdump-tree-@var{switch}-@var{options}
>>>>>>>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>>>>>>>  @opindex fdump-tree
>>>>>>>>  Control the dumping at various stages of processing the intermediate
>>>>>>>>  language tree to a file.  The file name is generated by appending a
>>>>>>>>  switch specific suffix to the source file name, and the file is
>>>>>>>> -created in the same directory as the output file.  If the
>>>>>>>> -@samp{-@var{options}} form is used, @var{options} is a list of
>>>>>>>> -@samp{-} separated options which control the details of the dump.  Not
>>>>>>>> -all options are applicable to all dumps; those that are not
>>>>>>>> -meaningful are ignored.  The following options are available
>>>>>>>> +created in the same directory as the output file. In case of
>>>>>>>> +@option{=@var{filename}} option, the dump is output on the given file
>>>>>>>> +name instead.  If the @samp{-@var{options}} form is used,
>>>>>>>> +@var{options} is a list of @samp{-} separated options which control
>>>>>>>> +the details or location of the dump.  Not all options are applicable
>>>>>>>> +to all dumps; those that are not meaningful are ignored.  The
>>>>>>>> +following options are available
>>>>>>>>
>>>>>>>>  @table @samp
>>>>>>>>  @item address
>>>>>>>> @@ -5765,9 +5771,46 @@ Enable showing the tree dump for each statement.
>>>>>>>>  Enable showing the EH region number holding each statement.
>>>>>>>>  @item scev
>>>>>>>>  Enable showing scalar evolution analysis details.
>>>>>>>> +@item slim
>>>>>>>> +Inhibit dumping of members of a scope or body of a function merely
>>>>>>>> +because that scope has been reached.  Only dump such items when they
>>>>>>>> +are directly reachable by some other path.  When dumping pretty-printed
>>>>>>>> +trees, this option inhibits dumping the bodies of control structures.
>>>>>>>> +@item =@var{filename}
>>>>>>>> +Instead of using an auto generated dump file name, use the given file
>>>>>>>> +name. The file names @file{stdout} and @file{stderr} are treated
>>>>>>>> +specially and are considered already open standard streams. For
>>>>>>>> +example:
>>>>>>>> +
>>>>>>>> +@smallexample
>>>>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-rtl-ira=ira.txt ...
>>>>>>>> +@end smallexample
>>>>>>>> +
>>>>>>>> +outputs PRE dump on @file{stderr}, while the IRA dump is output in a
>>>>>>>> +file named @file{ira.txt}.
>>>>>>>> +
>>>>>>>> +In case of any conflicts, the command line file name takes precedence
>>>>>>>> +over generated file names. For example:
>>>>>>>> +
>>>>>>>> +@smallexample
>>>>>>>> +gcc -O2 -fdump-tree-pre=stdout -fdump-tree-pre ...
>>>>>>>> +gcc -O2 -fdump-tree-pre -fdump-tree-pre=stdout ...
>>>>>>>> +@end smallexample
>>>>>>>> +
>>>>>>>> +Both of the above output the PRE dump on @file{stdout}. However, if
>>>>>>>> +there are multiple command line file names are applicable then the
>>>>>>>> +last one is used. Thus the command
>>>>>>>> +
>>>>>>>> +@smallexample
>>>>>>>> +gcc -O2 -fdump-tree-pre=stderr -fdump-tree-all=all.txt
>>>>>>>> +@end smallexample
>>>>>>>> +
>>>>>>>> +outputs all the dumps in @file{all.txt} because the stderr option for
>>>>>>>> +PRE dump is overridden by a later option.
>>>>>>>> +
>>>>>>>>  @item all
>>>>>>>> -Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>>>>>>> -and @option{lineno}.
>>>>>>>> +Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
>>>>>>>> +@option{lineno}.
>>>>>>>>  @end table
>>>>>>>>
>>>>>>>>  The following tree dumps are possible:
>>>>>>>> @@ -5913,6 +5956,7 @@ is made by appending @file{.vrp} to the source fil
>>>>>>>>  @item all
>>>>>>>>  @opindex fdump-tree-all
>>>>>>>>  Enable all the available tree dumps with the flags provided in this option.
>>>>>>>> +
>>>>>>>>  @end table
>>>>>>>>
>>>>>>>>  @item -ftree-vectorizer-verbose=@var{n}
>>>>>>>> Index: tree-dump.c
>>>>>>>> ===================================================================
>>>>>>>> --- tree-dump.c (revision 187265)
>>>>>>>> +++ tree-dump.c (working copy)
>>>>>>>> @@ -773,20 +773,20 @@ dump_node (const_tree t, int flags, FILE *stream)
>>>>>>>>    tree_dump_index enumeration in tree-pass.h.  */
>>>>>>>>  static struct dump_file_info dump_files[TDI_end] =
>>>>>>>>  {
>>>>>>>> -  {NULL, NULL, NULL, 0, 0, 0},
>>>>>>>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>>>>>>>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>>>>>>>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>>>>>>>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>>>>>>>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>>>>>>>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>>>>>>>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>>>>>>>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>>>>>>>> +  {NULL, NULL, NULL, NULL, 0, 0, 0},
>>>>>>>> +  {".cgraph", "ipa-cgraph", NULL, NULL, TDF_IPA, 0,  0},
>>>>>>>> +  {".tu", "translation-unit", NULL, NULL, TDF_TREE, 0, 1},
>>>>>>>> +  {".class", "class-hierarchy", NULL, NULL, TDF_TREE, 0, 2},
>>>>>>>> +  {".original", "tree-original", NULL, NULL, TDF_TREE, 0, 3},
>>>>>>>> +  {".gimple", "tree-gimple", NULL, NULL, TDF_TREE, 0, 4},
>>>>>>>> +  {".nested", "tree-nested", NULL, NULL, TDF_TREE, 0, 5},
>>>>>>>> +  {".vcg", "tree-vcg", NULL, NULL, TDF_TREE, 0, 6},
>>>>>>>> +  {".ads", "ada-spec", NULL, NULL, 0, 0, 7},
>>>>>>>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>>>>>>>
>>>>>>>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>>>>>>>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>>>>>>>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>>>>>>>> +  {NULL, "tree-all", NULL, NULL, TDF_TREE, 0, 0},
>>>>>>>> +  {NULL, "rtl-all", NULL, NULL, TDF_RTL, 0, 0},
>>>>>>>> +  {NULL, "ipa-all", NULL, NULL, TDF_IPA, 0, 0},
>>>>>>>>  };
>>>>>>>>
>>>>>>>>  /* Dynamically registered tree dump files and switches.  */
>>>>>>>> @@ -802,7 +802,7 @@ struct dump_option_value_info
>>>>>>>>  };
>>>>>>>>
>>>>>>>>  /* Table of dump options. This must be consistent with the TDF_* flags
>>>>>>>> -   in tree.h */
>>>>>>>> +   in tree-pass.h */
>>>>>>>>  static const struct dump_option_value_info dump_options[] =
>>>>>>>>  {
>>>>>>>>   {"address", TDF_ADDRESS},
>>>>>>>> @@ -892,6 +892,9 @@ get_dump_file_name (int phase)
>>>>>>>>   if (dfi->state == 0)
>>>>>>>>     return NULL;
>>>>>>>>
>>>>>>>> +  if (dfi->filename)
>>>>>>>> +    return xstrdup (dfi->filename);
>>>>>>>> +
>>>>>>>>   if (dfi->num < 0)
>>>>>>>>     dump_id[0] = '\0';
>>>>>>>>   else
>>>>>>>> @@ -911,6 +914,22 @@ get_dump_file_name (int phase)
>>>>>>>>   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>>>>>>>  }
>>>>>>>>
>>>>>>>> +/* If the DFI dump output corresponds to stdout or stderr stream,
>>>>>>>> +   return that stream, NULL otherwise.  */
>>>>>>>> +
>>>>>>>> +static FILE *
>>>>>>>> +dump_get_standard_stream (struct dump_file_info *dfi)
>>>>>>>> +{
>>>>>>>> +  if (!dfi->filename)
>>>>>>>> +    return NULL;
>>>>>>>> +
>>>>>>>> +  return strcmp("stderr", dfi->filename) == 0
>>>>>>>> +    ? stderr
>>>>>>>> +    : strcmp("stdout", dfi->filename) == 0
>>>>>>>> +    ?  stdout
>>>>>>>> +    : NULL;
>>>>>>>> +}
>>>>>>>> +
>>>>>>>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>>>>>>>    *FLAG_PTR and returns a stream to write to. If the dump is not
>>>>>>>>    enabled, returns NULL.
>>>>>>>> @@ -926,14 +945,20 @@ dump_begin (int phase, int *flag_ptr)
>>>>>>>>   if (phase == TDI_none || !dump_enabled_p (phase))
>>>>>>>>     return NULL;
>>>>>>>>
>>>>>>>> -  name = get_dump_file_name (phase);
>>>>>>>>   dfi = get_dump_file_info (phase);
>>>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>> -  if (!stream)
>>>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>>>> +  stream = dump_get_standard_stream (dfi);
>>>>>>>> +  if (stream)
>>>>>>>> +    dfi->state = 1;
>>>>>>>>   else
>>>>>>>> -    dfi->state = 1;
>>>>>>>> -  free (name);
>>>>>>>> +    {
>>>>>>>> +      name = get_dump_file_name (phase);
>>>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>> +      if (!stream)
>>>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>>>> +      else
>>>>>>>> +        dfi->state = 1;
>>>>>>>> +      free (name);
>>>>>>>> +    }
>>>>>>>>
>>>>>>>>   if (flag_ptr)
>>>>>>>>     *flag_ptr = dfi->flags;
>>>>>>>> @@ -987,35 +1012,46 @@ dump_flag_name (int phase)
>>>>>>>>    dump_begin.  */
>>>>>>>>
>>>>>>>>  void
>>>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>>>  {
>>>>>>>> -  fclose (stream);
>>>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>>>> +  if (!dump_get_standard_stream (dfi))
>>>>>>>> +    fclose (stream);
>>>>>>>>  }
>>>>>>>>
>>>>>>>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>>>>>>>> +   enabled tree dumps.  */
>>>>>>>>
>>>>>>>>  static int
>>>>>>>> -dump_enable_all (int flags)
>>>>>>>> +dump_enable_all (int flags, const char *filename)
>>>>>>>>  {
>>>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>>>   int n = 0;
>>>>>>>>   size_t i;
>>>>>>>>
>>>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>>>> -      {
>>>>>>>> -        dump_files[i].state = -1;
>>>>>>>> -        dump_files[i].flags |= flags;
>>>>>>>> -        n++;
>>>>>>>> -      }
>>>>>>>> +    {
>>>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>>>> +        {
>>>>>>>> +          dump_files[i].state = -1;
>>>>>>>> +          dump_files[i].flags |= flags;
>>>>>>>> +          n++;
>>>>>>>> +          if (filename)
>>>>>>>> +            dump_files[i].filename = xstrdup (filename);
>>>>>>>> +        }
>>>>>>>> +    }
>>>>>>>>
>>>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>> -      {
>>>>>>>> -        extra_dump_files[i].state = -1;
>>>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>>>> -       n++;
>>>>>>>> -      }
>>>>>>>> +    {
>>>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>> +        {
>>>>>>>> +          extra_dump_files[i].state = -1;
>>>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>>>> +          n++;
>>>>>>>> +          if (filename)
>>>>>>>> +            extra_dump_files[i].filename = xstrdup (filename);
>>>>>>>> +        }
>>>>>>>> +    }
>>>>>>>>
>>>>>>>>   return n;
>>>>>>>>  }
>>>>>>>> @@ -1037,7 +1073,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>   if (!option_value)
>>>>>>>>     return 0;
>>>>>>>>
>>>>>>>> -  if (*option_value && *option_value != '-')
>>>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>>>     return 0;
>>>>>>>>
>>>>>>>>   ptr = option_value;
>>>>>>>> @@ -1052,17 +1088,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>       while (*ptr == '-')
>>>>>>>>        ptr++;
>>>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>>>> +
>>>>>>>>       if (!end_ptr)
>>>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>>>       length = end_ptr - ptr;
>>>>>>>>
>>>>>>>> +      if (*ptr == '=')
>>>>>>>> +        {
>>>>>>>> +          /* Interpret rest of the argument as a dump filename.  This
>>>>>>>> +             filename overrides generated dump names as well as other
>>>>>>>> +             command line filenames.  */
>>>>>>>> +          flags |= TDF_FILENAME;
>>>>>>>> +          if (dfi->filename)
>>>>>>>> +            free (dfi->filename);
>>>>>>>> +          dfi->filename = xstrdup (ptr + 1);
>>>>>>>> +          break;
>>>>>>>> +        }
>>>>>>>> +
>>>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>>>> -         {
>>>>>>>> -           flags |= option_ptr->value;
>>>>>>>> +          {
>>>>>>>> +            flags |= option_ptr->value;
>>>>>>>>            goto found;
>>>>>>>> -         }
>>>>>>>> +          }
>>>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>>>               length, ptr, dfi->swtch);
>>>>>>>>     found:;
>>>>>>>> @@ -1075,7 +1124,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>>>      known dumps.  */
>>>>>>>>   if (dfi->suffix == NULL)
>>>>>>>> -    dump_enable_all (dfi->flags);
>>>>>>>> +    dump_enable_all (dfi->flags, dfi->filename);
>>>>>>>>
>>>>>>>>   return 1;
>>>>>>>>  }
>>>>>>>> @@ -1124,5 +1173,5 @@ dump_function (int phase, tree fn)
>>>>>>>>  bool
>>>>>>>>  enable_rtl_dump_file (void)
>>>>>>>>  {
>>>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>>>  }
>>>>>>>> Index: tree-pass.h
>>>>>>>> ===================================================================
>>>>>>>> --- tree-pass.h (revision 187265)
>>>>>>>> +++ tree-pass.h (working copy)
>>>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>>>> +#define TDF_FILENAME    (1 << 25)      /* Dump on provided filename
>>>>>>>> +                                           instead of constructing one. */
>>>>>>>>
>>>>>>>> -
>>>>>>>>  /* In tree-dump.c */
>>>>>>>>
>>>>>>>>  extern char *get_dump_file_name (int);
>>>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>>>   const char *swtch;            /* command line switch */
>>>>>>>>   const char *glob;             /* command line glob  */
>>>>>>>> +  const char *filename;         /* use this filename instead of making
>>>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>>>   int flags;                    /* user flags */
>>>>>>>>   int state;                    /* state of play */
>>>>>>>>   int num;                      /* dump file number */
>>>>>>>> Index: testsuite/g++.dg/other/dump-filename-1.C
>>>>>>>> ===================================================================
>>>>>>>> --- testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>>>>> +++ testsuite/g++.dg/other/dump-filename-1.C    (revision 0)
>>>>>>>> @@ -0,0 +1,11 @@
>>>>>>>> +// Test that the dump to a user-defined file works correctly.
>>>>>>>> +/* { dg-options "-O2 -fdump-tree-original=foobar.dump" } */
>>>>>>>> +
>>>>>>>> +void test (int *b, int *e, int stride)
>>>>>>>> +  {
>>>>>>>> +    for (int *p = b; p != e; p += stride)
>>>>>>>> +      *p = 1;
>>>>>>>> +  }
>>>>>>>> +
>>>>>>>> +/* { dg-final { scan-file foobar.dump ";; Function void test" } } */
>>>>>>>> +/* { dg-final { remove-build-file "foobar.dump" } } */
>>>>>>>>
>>>>>>>>
>>>>>>>> On Wed, May 9, 2012 at 12:22 AM, Gabriel Dos Reis
>>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>>> On Wed, May 9, 2012 at 1:46 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>>>> [...]
>>>>>>>>>
>>>>>>>>>> +@item -fdump-rtl-all=stderr
>>>>>>>>>> +@opindex fdump-rtl-all=stderr
>>>>>>>>>
>>>>>>>>> You do not need to have a separate index entry for '=stderr' or '=stdout'.
>>>>>>>>> Rather, expand the description to state this in all the documentation
>>>>>>>>> for -fdump-xxx=yyy.
>>>>>>>>>
>>>>>>>>> [...]
>>>>>>>>>
>>>>>>>>>> +/* Return non-zero iff the USER_FILENAME corresponds to stdout or
>>>>>>>>>> +   stderr stream.  */
>>>>>>>>>> +
>>>>>>>>>> +static int
>>>>>>>>>> +dump_stream_p (const char *user_filename)
>>>>>>>>>> +{
>>>>>>>>>> +  if (user_filename)
>>>>>>>>>> +    return !strncmp ("stderr", user_filename, 6) ||
>>>>>>>>>> +      !strncmp ("stdout", user_filename, 6);
>>>>>>>>>> +  else
>>>>>>>>>> +    return 0;
>>>>>>>>>> +}
>>>>>>>>>
>>>>>>>>> The name is ambiguous.
>>>>>>>>> This function is testing whether its string argument designates one of
>>>>>>>>> the *standard* output streams.  Name it to reflect that..
>>>>>>>>> Have it take the dump state context. Also the coding convention: the binary
>>>>>>>>> operator "||" should be on next line.  In fact the thing could be
>>>>>>>>> simpler.   Instead of
>>>>>>>>> testing over and over again against "stderr" (once in this function, then again
>>>>>>>>> later), just return the corresponding standard FILE* pointer.
>>>>>>>>> Also, this is a case of overuse of strncmp.  If you name the function
>>>>>>>>> dump_get_standard_stream:
>>>>>>>>>
>>>>>>>>>    return strcmp("stderr", dfi->user_filename) == 0
>>>>>>>>>       ? stderr
>>>>>>>>>        : stdcmp("stdout", dfi->use_filename)
>>>>>>>>>        ?  stdout
>>>>>>>>>        : NULL;
>>>>>>>>>
>>>>>>>>> you can simplify:
>>>>>>>>>
>>>>>>>>>> -  name = get_dump_file_name (phase);
>>>>>>>>>>   dfi = get_dump_file_info (phase);
>>>>>>>>>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>>>> -  if (!stream)
>>>>>>>>>> -    error ("could not open dump file %qs: %m", name);
>>>>>>>>>> +  if (dump_stream_p (dfi->user_filename))
>>>>>>>>>> +    {
>>>>>>>>>> +      if (!strncmp ("stderr", dfi->user_filename, 6))
>>>>>>>>>> +        stream = stderr;
>>>>>>>>>> +      else
>>>>>>>>>> +        if (!strncmp ("stdout", dfi->user_filename, 6))
>>>>>>>>>> +          stream = stdout;
>>>>>>>>>> +        else
>>>>>>>>>> +          error ("unknown stream: %qs: %m", dfi->user_filename);
>>>>>>>>>> +      dfi->state = 1;
>>>>>>>>>> +    }
>>>>>>>>>>   else
>>>>>>>>>> -    dfi->state = 1;
>>>>>>>>>> -  free (name);
>>>>>>>>>> +    {
>>>>>>>>>> +      name = get_dump_file_name (phase);
>>>>>>>>>> +      stream = fopen (name, dfi->state < 0 ? "w" : "a");
>>>>>>>>>> +      if (!stream)
>>>>>>>>>> +        error ("could not open dump file %qs: %m", name);
>>>>>>>>>> +      else
>>>>>>>>>> +        dfi->state = 1;
>>>>>>>>>> +      free (name);
>>>>>>>>>> +    }
>>>>>>>>>>
>>>>>>>>>>   if (flag_ptr)
>>>>>>>>>>     *flag_ptr = dfi->flags;
>>>>>>>>>> @@ -987,35 +1017,45 @@ dump_flag_name (int phase)
>>>>>>>>>>    dump_begin.  */
>>>>>>>>>>
>>>>>>>>>>  void
>>>>>>>>>> -dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>>>>>>>>> +dump_end (int phase, FILE *stream)
>>>>>>>>>>  {
>>>>>>>>>> -  fclose (stream);
>>>>>>>>>> +  struct dump_file_info *dfi = get_dump_file_info (phase);
>>>>>>>>>> +  if (!dump_stream_p (dfi->user_filename))
>>>>>>>>>> +    fclose (stream);
>>>>>>>>>>  }
>>>>>>>>>>
>>>>>>>>>>  /* Enable all tree dumps.  Return number of enabled tree dumps.  */
>>>>>>>>>>
>>>>>>>>>>  static int
>>>>>>>>>> -dump_enable_all (int flags)
>>>>>>>>>> +dump_enable_all (int flags, const char *user_filename)
>>>>>>>>>>  {
>>>>>>>>>>   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>>>>>>>>>   int n = 0;
>>>>>>>>>>   size_t i;
>>>>>>>>>>
>>>>>>>>>>   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>>>>>>>>>> -    if ((dump_files[i].flags & ir_dump_type))
>>>>>>>>>> -      {
>>>>>>>>>> -        dump_files[i].state = -1;
>>>>>>>>>> -        dump_files[i].flags |= flags;
>>>>>>>>>> -        n++;
>>>>>>>>>> -      }
>>>>>>>>>> +    {
>>>>>>>>>> +      if ((dump_files[i].flags & ir_dump_type))
>>>>>>>>>> +        {
>>>>>>>>>> +          dump_files[i].state = -1;
>>>>>>>>>> +          dump_files[i].flags |= flags;
>>>>>>>>>> +          n++;
>>>>>>>>>> +        }
>>>>>>>>>> +      if (user_filename)
>>>>>>>>>> +        dump_files[i].user_filename = user_filename;
>>>>>>>>>> +    }
>>>>>>>>>>
>>>>>>>>>>   for (i = 0; i < extra_dump_files_in_use; i++)
>>>>>>>>>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>>>> -      {
>>>>>>>>>> -        extra_dump_files[i].state = -1;
>>>>>>>>>> -        extra_dump_files[i].flags |= flags;
>>>>>>>>>> -       n++;
>>>>>>>>>> -      }
>>>>>>>>>> +    {
>>>>>>>>>> +      if ((extra_dump_files[i].flags & ir_dump_type))
>>>>>>>>>> +        {
>>>>>>>>>> +          extra_dump_files[i].state = -1;
>>>>>>>>>> +          extra_dump_files[i].flags |= flags;
>>>>>>>>>> +          n++;
>>>>>>>>>> +        }
>>>>>>>>>> +      if (user_filename)
>>>>>>>>>> +        extra_dump_files[i].user_filename = user_filename;
>>>>>>>>>> +    }
>>>>>>>>>>
>>>>>>>>>>   return n;
>>>>>>>>>>  }
>>>>>>>>>> @@ -1037,7 +1077,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>>>   if (!option_value)
>>>>>>>>>>     return 0;
>>>>>>>>>>
>>>>>>>>>> -  if (*option_value && *option_value != '-')
>>>>>>>>>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>>>>>>>>>     return 0;
>>>>>>>>>>
>>>>>>>>>>   ptr = option_value;
>>>>>>>>>> @@ -1052,17 +1092,30 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>>>       while (*ptr == '-')
>>>>>>>>>>        ptr++;
>>>>>>>>>>       end_ptr = strchr (ptr, '-');
>>>>>>>>>> +
>>>>>>>>>>       if (!end_ptr)
>>>>>>>>>>        end_ptr = ptr + strlen (ptr);
>>>>>>>>>>       length = end_ptr - ptr;
>>>>>>>>>>
>>>>>>>>>> +      if (*ptr == '=')
>>>>>>>>>> +        {
>>>>>>>>>> +          /* Interpret rest of the argument as a dump filename.  The
>>>>>>>>>> +             user provided filename overrides generated dump names as
>>>>>>>>>> +             well as other command line filenames.  */
>>>>>>>>>> +          flags |= TDF_USER_FILENAME;
>>>>>>>>>> +          if (dfi->user_filename)
>>>>>>>>>> +            free (dfi->user_filename);
>>>>>>>>>> +          dfi->user_filename = xstrdup (ptr + 1);
>>>>>>>>>> +          break;
>>>>>>>>>> +        }
>>>>>>>>>> +
>>>>>>>>>>       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>>>>>>>>>        if (strlen (option_ptr->name) == length
>>>>>>>>>>            && !memcmp (option_ptr->name, ptr, length))
>>>>>>>>>> -         {
>>>>>>>>>> -           flags |= option_ptr->value;
>>>>>>>>>> +          {
>>>>>>>>>> +            flags |= option_ptr->value;
>>>>>>>>>>            goto found;
>>>>>>>>>> -         }
>>>>>>>>>> +          }
>>>>>>>>>>       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>>>>>>>>>>               length, ptr, dfi->swtch);
>>>>>>>>>>     found:;
>>>>>>>>>> @@ -1075,7 +1128,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>>>>>>>>>   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>>>>>>>>>      known dumps.  */
>>>>>>>>>>   if (dfi->suffix == NULL)
>>>>>>>>>> -    dump_enable_all (dfi->flags);
>>>>>>>>>> +    dump_enable_all (dfi->flags, dfi->user_filename);
>>>>>>>>>>
>>>>>>>>>>   return 1;
>>>>>>>>>>  }
>>>>>>>>>> @@ -1124,5 +1177,5 @@ dump_function (int phase, tree fn)
>>>>>>>>>>  bool
>>>>>>>>>>  enable_rtl_dump_file (void)
>>>>>>>>>>  {
>>>>>>>>>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>>>>>>>>>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>>>>>>>>>  }
>>>>>>>>>> Index: tree-pass.h
>>>>>>>>>> ===================================================================
>>>>>>>>>> --- tree-pass.h (revision 187265)
>>>>>>>>>> +++ tree-pass.h (working copy)
>>>>>>>>>> @@ -84,8 +84,9 @@ enum tree_dump_index
>>>>>>>>>>  #define TDF_ENUMERATE_LOCALS (1 << 22) /* Enumerate locals by uid.  */
>>>>>>>>>>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>>>>>>>>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>>>>>>>>> +#define TDF_USER_FILENAME    (1 << 25) /* Dump on user provided filename,
>>>>>>>>>> +                                           instead of constructing one. */
>>>>>>>>>>
>>>>>>>>>> -
>>>>>>>>>>  /* In tree-dump.c */
>>>>>>>>>>
>>>>>>>>>>  extern char *get_dump_file_name (int);
>>>>>>>>>> @@ -222,6 +223,8 @@ struct dump_file_info
>>>>>>>>>>   const char *suffix;           /* suffix to give output file.  */
>>>>>>>>>>   const char *swtch;            /* command line switch */
>>>>>>>>>>   const char *glob;             /* command line glob  */
>>>>>>>>>> +  const char *user_filename;    /* user provided filename instead of making
>>>>>>>>>> +                                   up one using dump_base_name + suffix.  */
>>>>>>>>>
>>>>>>>>> There is "no user" here: we are the users :-)  Just call it "filename".
>>>>>>>>>
>>>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-12 16:06                   ` Xinliang David Li
@ 2012-05-12 16:26                     ` Gabriel Dos Reis
  2012-05-12 16:39                       ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-05-12 16:26 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Richard Guenther, Sharad Singhai, gcc-patches, Andrew Pinski

On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:

> The downside is that the dump file format will look different from the
> stderr output which is less than ideal.

BTW, why do people want to use stderr for dumping internal IRs,
as opposed to stdout or other files?  That does not sound right.

-- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-12 16:26                     ` Gabriel Dos Reis
@ 2012-05-12 16:39                       ` Xinliang David Li
  2012-05-14  7:26                         ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-05-12 16:39 UTC (permalink / raw)
  To: Gabriel Dos Reis
  Cc: Richard Guenther, Sharad Singhai, gcc-patches, Andrew Pinski

On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>
>> The downside is that the dump file format will look different from the
>> stderr output which is less than ideal.
>
> BTW, why do people want to use stderr for dumping internal IRs,
> as opposed to stdout or other files?  That does not sound right.
>

I was talking about the transformation information difference. In
stderr (where diagnostics go to), we may have

foo.c: in function 'foo':
foo.c:5:6: note: loop was vectorized

but in dump file the format for the information may be different,
unless we want to duplicate the machinery in diagnostics.

David

> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-12 16:39                       ` Xinliang David Li
@ 2012-05-14  7:26                         ` Richard Guenther
  2012-06-07  6:16                           ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-05-14  7:26 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Gabriel Dos Reis, Sharad Singhai, gcc-patches, Andrew Pinski

On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>
>>> The downside is that the dump file format will look different from the
>>> stderr output which is less than ideal.
>>
>> BTW, why do people want to use stderr for dumping internal IRs,
>> as opposed to stdout or other files?  That does not sound right.
>>
>
> I was talking about the transformation information difference. In
> stderr (where diagnostics go to), we may have
>
> foo.c: in function 'foo':
> foo.c:5:6: note: loop was vectorized
>
> but in dump file the format for the information may be different,
> unless we want to duplicate the machinery in diagnostics.

So?  What's the problem with that ("different" diagnostics)?

Richard.

> David
>
>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-14  7:26                         ` Richard Guenther
@ 2012-06-07  6:16                           ` Sharad Singhai
  2012-06-07  8:08                             ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-06-07  6:16 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

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

Sorry about the delay. I have finally incorporated all the suggestions
and reorganized the dump infrastructure a bit. The attached patch
updates vectorizer passes so that instead of accessing global
dump_file directly, these passes call dump_printf (FLAG, format, ...).
The dump_printf can choose between two streams, one regular pass dump
file, and another optional command line provided file. Currently, it
doesn't discriminate and all the dump information goes to both the
streams.

Thus, for example,

g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3

will output the verbose vectorizer information in both *.vect file and
foo.v file. However, as I have converted only vectorizer passes so
far, there is additional information in *.vect file which is not
present in foo.v file. Once other passes are converted to use this
scheme, then these two dump files should have identical output.

Also note that in this patch -fdump-xxx=yyy format does not override
any auto named dump files as in my earlier patches. Instead the dump
information is output to both places when a command line dump file
option is provided.

To summarize:
- instead of using dump_begin () / dump_end (), the passes should use
dump_start ()/dump_finish (). These new variants do not return the
dump_file. However, they still set the global dump_file/dump_flags for
the benefit of other passes during the transition.
- instead of directly printing to the dump_file, as in
if (dump_file)
  fprintf (dump_file, ...);

The passes should do

dump_printf (dump_flag, ...);
This will output to dump file(s) only when dump_flag is enabled for a
given pass.

I have bootstrapped and tested it on x86_64. Does it look okay?

Thanks,
Sharad


On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>> <gdr@integrable-solutions.net> wrote:
>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>
>>>> The downside is that the dump file format will look different from the
>>>> stderr output which is less than ideal.
>>>
>>> BTW, why do people want to use stderr for dumping internal IRs,
>>> as opposed to stdout or other files?  That does not sound right.
>>>
>>
>> I was talking about the transformation information difference. In
>> stderr (where diagnostics go to), we may have
>>
>> foo.c: in function 'foo':
>> foo.c:5:6: note: loop was vectorized
>>
>> but in dump file the format for the information may be different,
>> unless we want to duplicate the machinery in diagnostics.
>
> So?  What's the problem with that ("different" diagnostics)?
>
> Richard.
>
>> David
>>
>>> -- Gaby

[-- Attachment #2: dump_vectorizer_verbose.diff --]
[-- Type: application/octet-stream, Size: 241716 bytes --]

2012-06-06  Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for the new option.
	* tree-dump.c (get_alternate_dump_file_name): New function.
	(get_dump_file_name): Use pstate instead of state.
	(dump_begin): ditto.
	(dump_open_alternate_stream): New function.
	(dump_gimple_stmt): ditto.
	(dump_generic_expr): ditto.
	(dump_set_alternate_stream): ditto.
	(dump_printf): New function for printing to dump files.
	(dump_start): New function as a replacement for dump_begin.
	(dump_finish): New function as a replacement for dump_end.
	(dump_enabled_p): Handle both pass and diagnostic streams.
	(dump_initialized_p): ditto.
	(dump_enable_all): Additional parameter for the diagnostic stream.
	(dump_switch_p_1): Handle dump filenames.
	(dump_function): Handle alternate dump stream.
	(dump_combine_total_stats): new function.
	(dump_combine_stats): New function.
	* tree-dump.h: New function declarations.
	* tree-pass.h: New function declarations.
	(struct dump_file_info): Add fields for alternate stream.
	* toplev.c (ALT_DUMP_FILE): Define new stream.
	* tree-vect-loop-manip.c: Use dump_printf instead of printing to file.
	* testsuite/g++.dg/other/dump-vectorizer-1.C (bar):
	(int main):
	* gimple-pretty-print.c: Rename dump_gimple_stmt to print_gimple_stmt_1.
	All callers updated.
	* gimple-pretty-print.h: ditto.
	* profile.c: Rename end_branch_prob to end_branch_prob_1. All callers
	upddated.
	(end_branch_prob): Call helper function to do the actual dump.
	* tree-vect-loop.c: Use dump_printf instead of directly printing to
	dump file.
	* tree-vectorizer.c: ditto.
	* tree-vect-data-refs.c: ditto.
	* tree-vect-patterns.c: ditto.
	* tree-vect-stmts.c: ditto.
	* tree-vect-slp.c: ditto.
	* rtl.h: Rename dump_combine_stats and dump_combine_total_stats.
	* combine.c: ditto.
	* system.h: Add declaration of ALT_DUMP_FILE.
	* passes.c (finish_optimization_passes): Use dump_start and dump_finish.
	(pass_init_dump_file): ditto.
	(pass_fini_dump_file): ditto.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 188212)
+++ doc/invoke.texi	(working copy)
@@ -5330,6 +5330,7 @@ Here are some examples showing uses of these optio
 
 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass}=@var{filename}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
@@ -5727,11 +5728,14 @@ counters for each function compiled.
 
 @item -fdump-tree-@var{switch}
 @itemx -fdump-tree-@var{switch}-@var{options}
+@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
+created in the same directory as the output file. In case of
+@option{=@var{filename}} option, the dump is output on the given file
+in addition to the auto named dump files.  If the
 @samp{-@var{options}} form is used, @var{options} is a list of
 @samp{-} separated options which control the details of the dump.  Not
 all options are applicable to all dumps; those that are not
@@ -5773,6 +5777,23 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item =@var{filename}
+In addition to an auto named dump file, output into the given file
+name. The file names @file{stdout} and @file{stderr} are treated
+specially and are considered already open standard streams. For
+example:
+
+@smallexample
+gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
+     -ftree-vectorizer-verbose=3
+@end smallexample
+
+outputs vectorizer dump into an auto named dump file as well as into
+@file{foo.dump}. Note this mechanism currently works only for the tree
+vectorizer which uses the new dump framework. Other passes would have
+the dump output only in the auto named dump files until those passes
+are converted to the new dump framework.
+
 @item all
 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
 and @option{lineno}.
@@ -5951,6 +5972,11 @@ For @var{n}=9, all the information the vectorizer
 analysis and transformation is reported.  This is the same verbosity level
 that @option{-fdump-tree-vect-details} uses.
 
+Note that by using the format @option{-fdump-tree-vect=filename} or
+@option{-fdump-tree-vect-details=filename}, the verbose dump
+information is output into the filename in addition to the auto named
+dump files.
+
 @item -frandom-seed=@var{string}
 @opindex frandom-seed
 This option provides a seed that GCC uses in place of
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 188212)
+++ tree-dump.c	(working copy)
@@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "gimple-pretty-print.h"
 #include "splay-tree.h"
 #include "filenames.h"
 #include "diagnostic-core.h"
+#include "rtl.h"
 #include "toplev.h"
 #include "tree-dump.h"
 #include "tree-pass.h"
@@ -770,23 +772,23 @@ dump_node (const_tree t, int flags, FILE *stream)
 \f
 
 /* Table of tree dump switches. This must be consistent with the
-   tree_dump_index enumeration in tree-pass.h.  */
+   TREE_DUMP_INDEX enumeration in tree-pass.h.  */
 static struct dump_file_info dump_files[TDI_end] =
 {
-  {NULL, NULL, NULL, 0, 0, 0},
-  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
-  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
-  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
-  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
-  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
-  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
-  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
-  {".ads", "ada-spec", NULL, 0, 0, 7},
+  {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0},
+  {".cgraph", "ipa-cgraph", NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0},
+  {".tu", "translation-unit", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 1},
+  {".class", "class-hierarchy", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 2},
+  {".original", "tree-original", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 3},
+  {".gimple", "tree-gimple", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 4},
+  {".nested", "tree-nested", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 5},
+  {".vcg", "tree-vcg", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 6},
+  {".ads", "ada-spec", NULL, NULL, NULL, NULL, 0, 0, 0, 7},
 #define FIRST_AUTO_NUMBERED_DUMP 8
 
-  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
-  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
-  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
+  {NULL, "tree-all", NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0},
+  {NULL, "rtl-all", NULL, NULL, NULL, NULL, TDF_RTL, 0, 0, 0},
+  {NULL, "ipa-all", NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0},
 };
 
 /* Dynamically registered tree dump files and switches.  */
@@ -802,7 +804,7 @@ struct dump_option_value_info
 };
 
 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in tree-pass.h */
 static const struct dump_option_value_info dump_options[] =
 {
   {"address", TDF_ADDRESS},
@@ -876,6 +878,20 @@ get_dump_file_info (int phase)
 }
 
 
+/* Return the name of the alternate dump file for the given phase.  If
+   the dump is not enabled, return NULL.  */
+
+const char *
+get_alternate_dump_file_name (int phase)
+{
+  struct dump_file_info *dfi;
+
+  if (phase < 0 || !dump_enabled_p (phase))
+    return NULL;
+  dfi = get_dump_file_info (phase);
+  return dfi->dfilename;
+}
+
 /* Return the name of the dump file for the given phase.
    If the dump is not enabled, returns NULL.  */
 
@@ -889,7 +905,7 @@ get_dump_file_name (int phase)
     return NULL;
 
   dfi = get_dump_file_info (phase);
-  if (dfi->state == 0)
+  if (dfi->pstate == 0)
     return NULL;
 
   if (dfi->num < 0)
@@ -911,6 +927,178 @@ get_dump_file_name (int phase)
   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }
 
+/* Open an alternate dump filename for PHASE (which could also be a
+   standard stream such as stdout/stderr). If the alternate dump file
+   cannot be opened, return NULL.  */
+
+static FILE *
+dump_open_alternate_stream (int phase)
+{
+  FILE *stream ;
+  struct dump_file_info *dfi;
+
+  dfi = get_dump_file_info (phase);
+  if (!dfi->dfilename)
+    return NULL;
+
+  if (dfi->dstream)
+    return dfi->dstream;
+
+  stream = strcmp("stderr", dfi->dfilename) == 0
+    ? stderr
+    : strcmp("stdout", dfi->dfilename) == 0
+    ?  stdout
+    : NULL;
+
+  if (!stream)
+    {
+      stream = fopen (dfi->dfilename, dfi->dstate < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", dfi->dfilename);
+    }
+
+  return stream;
+}
+
+/* Dump gimple statement GS with SPC indentantion spaces and FLAGS as
+   in print_gimple_stmt_1.  */
+
+void
+dump_gimple_stmt (int flags, gimple gs, int spc)
+{
+  if (dump_file)
+    print_gimple_stmt (dump_file, gs, spc, flags);
+  if (alt_dump_file)
+    print_gimple_stmt (alt_dump_file, gs, spc, flags);
+}
+
+/* Dump tree T using FLAGS on one or more dump streams.  */
+
+void
+dump_generic_expr (int flags, tree t)
+{
+  if (dump_file)
+    print_generic_expr (dump_file, t, flags);
+  if (alt_dump_file)
+    print_generic_expr (alt_dump_file, t, flags);
+}
+
+
+/* If dumping is enabled for PHASE, open the FILENAME and set
+   alternate dump stream for that phase.  Store user-supplied dump
+   flags in *FLAG_PTR.  */
+
+void
+dump_set_alternate_stream (int phase, const char *filename, int *flag_ptr)
+{
+  struct dump_file_info *dfi;
+
+  dfi = get_dump_file_info (phase);
+  if (dfi->dfilename)
+    free (CONST_CAST (char *, dfi->dfilename));
+  if (dfi->dstream)
+    fclose (dfi->dstream);
+  dfi->dfilename = xstrdup (filename);
+  dfi->dstream = dump_open_alternate_stream (phase);
+  dfi->dstate = 1;
+  alt_dump_file = dfi->dstream;
+  if (flag_ptr)
+    *flag_ptr = dfi->flags;
+}
+
+/* Output a formatted message using FORMAT on streams corresponding to
+   FLAG.  */
+
+void
+dump_printf (int flag, const char *format, ...)
+{
+  if (dump_file && (flag & dump_flags))
+    {
+      va_list ap;
+      va_start (ap, format);
+      vfprintf (dump_file, format, ap);
+      va_end (ap);
+    }
+
+  if (alt_dump_file && (flag & dump_flags))
+    {
+      va_list ap;
+      va_start (ap, format);
+      vfprintf (alt_dump_file, format, ap);
+      va_end (ap);
+    }
+}
+
+/* Start a dump for PHASE. Store user-supplied dump flags in *FLAG_PTR.
+   Return the number of streams opened.  Also set globals DUMP_FILE,
+   and ALT_DUMP_FILE to point to the opened streams.  */
+
+int
+dump_start (int phase, int *flag_ptr)
+{
+  int count = 0;
+  char *name;
+  struct dump_file_info *dfi;
+  FILE *stream;
+  if (phase == TDI_none || !dump_enabled_p (phase))
+    return 0;
+
+  dfi = get_dump_file_info (phase);
+  name = get_dump_file_name (phase);
+  if (name)
+    {
+      stream = fopen (name, dfi->pstate < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        {
+          dfi->pstate = 1;
+          count++;
+        }
+      free (name);
+      dfi->pstream = stream;
+      dump_file = dfi->pstream;
+    }
+
+  stream = dump_open_alternate_stream (phase);
+  if (stream)
+    {
+      dfi->dstream = stream;
+      dfi->dstate = 1;
+      count++;
+      alt_dump_file = dfi->dstream;
+    }
+
+  if (flag_ptr)
+    *flag_ptr = dfi->flags;
+  return count;
+}
+
+/* Finish a tree dump for PHASE and close associated dump streams.  Also
+   reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS.  */
+
+void
+dump_finish (int phase)
+{
+  struct dump_file_info *dfi;
+
+  if (phase < 0)
+    return;
+  dfi = get_dump_file_info (phase);
+  if (dfi->pstream)
+    fclose (dfi->pstream);
+
+  if (dfi->dstream && strcmp("stderr", dfi->dfilename) != 0
+      && strcmp("stdout", dfi->dfilename) != 0)
+    fclose (dfi->dstream);
+
+  dfi->dstream = NULL;
+  dfi->pstream = NULL;
+  dump_file = NULL;
+  alt_dump_file = NULL;
+  dump_flags = TDI_none;
+}
+
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
@@ -928,11 +1116,11 @@ dump_begin (int phase, int *flag_ptr)
 
   name = get_dump_file_name (phase);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
+  stream = fopen (name, dfi->pstate < 0 ? "w" : "a");
   if (!stream)
     error ("could not open dump file %qs: %m", name);
   else
-    dfi->state = 1;
+    dfi->pstate = 1;
   free (name);
 
   if (flag_ptr)
@@ -941,8 +1129,9 @@ dump_begin (int phase, int *flag_ptr)
   return stream;
 }
 
-/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
-   TDI_tree_all, return nonzero if any dump is enabled.  */
+/* Returns nonzero if dump PHASE is enabled for at least one stream.
+   If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
+   any phase.  */
 
 int
 dump_enabled_p (int phase)
@@ -951,17 +1140,17 @@ dump_enabled_p (int phase)
     {
       size_t i;
       for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-	if (dump_files[i].state)
+	if (dump_files[i].pstate || dump_files[i].dstate)
 	  return 1;
       for (i = 0; i < extra_dump_files_in_use; i++)
-	if (extra_dump_files[i].state)
+	if (extra_dump_files[i].pstate || extra_dump_files[i].dstate)
 	  return 1;
       return 0;
     }
   else
     {
       struct dump_file_info *dfi = get_dump_file_info (phase);
-      return dfi->state;
+      return dfi->pstate || dfi->dstate;
     }
 }
 
@@ -971,7 +1160,7 @@ int
 dump_initialized_p (int phase)
 {
   struct dump_file_info *dfi = get_dump_file_info (phase);
-  return dfi->state > 0;
+  return dfi->pstate > 0 || dfi->dstate > 0;
 }
 
 /* Returns the switch name of PHASE.  */
@@ -992,30 +1181,49 @@ dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream
   fclose (stream);
 }
 
-/* Enable all tree dumps.  Return number of enabled tree dumps.  */
+/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
+   enabled tree dumps.  */
 
 static int
-dump_enable_all (int flags)
+dump_enable_all (int flags, const char *filename)
 {
   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;
 
   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_dump_type))
-      {
-        dump_files[i].state = -1;
-        dump_files[i].flags |= flags;
-        n++;
-      }
+    {
+      if ((dump_files[i].flags & ir_dump_type))
+        {
+          const char *old_filename = dump_files[i].dfilename;
+          dump_files[i].pstate = -1;
+          dump_files[i].dstate = -1;
+          dump_files[i].flags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            dump_files[i].dfilename = xstrdup (filename);
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }
 
   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_dump_type))
-      {
-        extra_dump_files[i].state = -1;
-        extra_dump_files[i].flags |= flags;
-	n++;
-      }
+    {
+      if ((extra_dump_files[i].flags & ir_dump_type))
+        {
+          const char *old_filename = extra_dump_files[i].dfilename;
+          extra_dump_files[i].pstate = -1;
+          extra_dump_files[i].dstate = -1;
+          extra_dump_files[i].flags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            extra_dump_files[i].dfilename = xstrdup (filename);
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }
 
   return n;
 }
@@ -1037,7 +1245,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   if (!option_value)
     return 0;
 
-  if (*option_value && *option_value != '-')
+  if (*option_value && *option_value != '-' && *option_value != '=')
     return 0;
 
   ptr = option_value;
@@ -1047,11 +1255,17 @@ dump_switch_p_1 (const char *arg, struct dump_file
     {
       const struct dump_option_value_info *option_ptr;
       const char *end_ptr;
+      const char *eq_ptr;
       unsigned length;
 
       while (*ptr == '-')
 	ptr++;
       end_ptr = strchr (ptr, '-');
+      eq_ptr = strchr (ptr, '=');
+
+      if (eq_ptr)
+        end_ptr = eq_ptr;
+
       if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;
@@ -1059,23 +1273,35 @@ dump_switch_p_1 (const char *arg, struct dump_file
       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
-	  {
-	    flags |= option_ptr->value;
+          {
+            flags |= option_ptr->value;
 	    goto found;
-	  }
-      warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
-	       length, ptr, dfi->swtch);
+          }
+
+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  This
+             filename overrides other command line filenames.  */
+          if (dfi->dfilename)
+            free (CONST_CAST (char *, dfi->dfilename));
+          dfi->dfilename = xstrdup (ptr + 1);
+          break;
+        }
+      else
+        warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
+                 length, ptr, dfi->swtch);
     found:;
       ptr = end_ptr;
     }
 
-  dfi->state = -1;
+  dfi->pstate = -1;
+  dfi->dstate = -1;
   dfi->flags |= flags;
 
   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
      known dumps.  */
   if (dfi->suffix == NULL)
-    dump_enable_all (dfi->flags);
+    dump_enable_all (dfi->flags, dfi->dfilename);
 
   return 1;
 }
@@ -1110,19 +1336,52 @@ dump_switch_p (const char *arg)
 void
 dump_function (int phase, tree fn)
 {
-  FILE *stream;
+  FILE *streams[2];
   int flags;
+  unsigned i;
 
-  stream = dump_begin (phase, &flags);
-  if (stream)
+  streams[0] = dump_begin (phase, &flags);
+  streams[1] = dump_open_alternate_stream (phase);
+
+  for (i = 0; i < 2; i++)
     {
-      dump_function_to_file (fn, stream, flags);
-      dump_end (phase, stream);
+      FILE *stream = streams[i];
+      if (stream)
+        {
+          dump_function_to_file (fn, stream, flags);
+          dump_end (phase, stream);
+        }
     }
 }
 
 bool
 enable_rtl_dump_file (void)
 {
-  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
+  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
 }
+
+/* Dump combine statistics using FLAGS.  */
+
+void
+dump_combine_total_stats (int flags)
+{
+  if (flags & dump_flags)
+    {
+      if (dump_file)
+        print_combine_total_stats (dump_file);
+      if (alt_dump_file)
+        print_combine_total_stats (alt_dump_file);
+    }
+}
+
+DEBUG_FUNCTION void
+dump_combine_stats (int flags)
+{
+  if (flags & dump_flags)
+    {
+      if (dump_file)
+        print_combine_stats (dump_file);
+      if (alt_dump_file)
+        print_combine_stats (alt_dump_file);
+    }
+}
Index: tree-dump.h
===================================================================
--- tree-dump.h	(revision 188212)
+++ tree-dump.h	(working copy)
@@ -94,9 +94,15 @@ extern void dump_function_to_file (tree, FILE *, i
 extern void dump_enumerated_decls (FILE *, int);
 extern void debug_function (tree, int);
 extern int dump_flag (dump_info_p, int, const_tree);
+extern void dump_set_alternate_stream (int, const char *, int *);
+extern void dump_generic_expr (int, tree);
+extern void dump_gimple_stmt (int, gimple, int);
+extern void dump_combine_total_stats (int);
+extern void dump_combine_stats (int);
 
 extern unsigned int dump_register (const char *, const char *, const char *,
 				   int);
+extern void dump_printf (int flag, const char *format, ...) ATTRIBUTE_PRINTF_2;
 
 
 #endif /* ! GCC_TREE_DUMP_H */
Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 188212)
+++ tree-pass.h	(working copy)
@@ -85,20 +85,25 @@ enum tree_dump_index
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
 
-
 /* In tree-dump.c */
 
 extern char *get_dump_file_name (int);
+extern const char *get_alternate_dump_file_name (int);
 extern int dump_enabled_p (int);
 extern int dump_initialized_p (int);
 extern FILE *dump_begin (int, int *);
 extern void dump_end (int, FILE *);
+
+extern int dump_start (int, int *);
+extern void dump_finish (int);
+
 extern void dump_node (const_tree, int, FILE *);
 extern int dump_switch_p (const char *);
 extern const char *dump_flag_name (int);
 
 /* Global variables used to communicate with passes.  */
 extern FILE *dump_file;
+extern FILE *alt_dump_file;
 extern int dump_flags;
 extern const char *dump_file_name;
 
@@ -222,8 +227,13 @@ struct dump_file_info
   const char *suffix;           /* suffix to give output file.  */
   const char *swtch;            /* command line switch */
   const char *glob;             /* command line glob  */
+  const char *dfilename;        /* filename for the diagnostic stream  */
+  FILE *pstream;                /* private pass-specific dump stream  */
+  FILE *dstream;                /* diagnostic stream, it could be a
+                                   file or standard stream */
   int flags;                    /* user flags */
-  int state;                    /* state of play */
+  int pstate;                    /* state of pass-specific stream */
+  int dstate;                   /* state of the diagnostic stream */
   int num;                      /* dump file number */
 };
 
Index: toplev.c
===================================================================
--- toplev.c	(revision 188212)
+++ toplev.c	(working copy)
@@ -174,6 +174,7 @@ FILE *asm_out_file;
 FILE *aux_info_file;
 FILE *stack_usage_file = NULL;
 FILE *dump_file = NULL;
+FILE *alt_dump_file = NULL;
 const char *dump_file_name;
 
 /* The current working directory of a translation.  It's generally the
Index: tree-vect-loop-manip.c
===================================================================
--- tree-vect-loop-manip.c	(revision 188212)
+++ tree-vect-loop-manip.c	(working copy)
@@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
   gsi_remove (&loop_cond_gsi, true);
 
   loop_loc = find_loop_location (loop);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    {
-      if (loop_loc != UNKNOWN_LOC)
-        fprintf (dump_file, "\nloop at %s:%d: ",
+  if (loop_loc != UNKNOWN_LOC)
+    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
-    }
-
+  if (dump_flags & TDF_DETAILS)
+    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
   loop->nb_iterations = niters;
 }
 
@@ -1221,13 +1218,10 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
   if (!(new_loop = slpeel_tree_duplicate_loop_to_edge_cfg (loop, e)))
     {
       loop_loc = find_loop_location (loop);
-      if (dump_file && (dump_flags & TDF_DETAILS))
-        {
-          if (loop_loc != UNKNOWN_LOC)
-            fprintf (dump_file, "\n%s:%d: note: ",
+      if (loop_loc != UNKNOWN_LOC)
+        dump_printf (TDF_DETAILS, "\n%s:%d: note: ",
                      LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-          fprintf (dump_file, "tree_duplicate_loop_to_edge_cfg failed.\n");
-        }
+      dump_printf (TDF_DETAILS, "tree_duplicate_loop_to_edge_cfg failed.\n");
       return NULL;
     }
 
@@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
   /* Analyze phi functions of the loop header.  */
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_can_advance_ivs_p:");
+    dump_printf (TDF_TREE, "vect_can_advance_ivs_p:");
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       phi = gsi_stmt (gsi);
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "Analyze phi: ");
+          dump_gimple_stmt (TDF_SLIM, phi, 0);
 	}
 
       /* Skip virtual phi's. The data dependences that are associated with
@@ -1668,7 +1662,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (!is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (phi))))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "virtual phi. skip.");
+	    dump_printf (TDF_TREE, "virtual phi. skip.");
 	  continue;
 	}
 
@@ -1677,7 +1671,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc phi. skip.");
+            dump_printf (TDF_TREE, "reduc phi. skip.");
           continue;
         }
 
@@ -1689,14 +1683,14 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (!access_fn)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "No Access function.");
+	    dump_printf (TDF_TREE, "No Access function.");
 	  return false;
 	}
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-	  fprintf (vect_dump, "Access function of PHI: ");
-	  print_generic_expr (vect_dump, access_fn, TDF_SLIM);
+	  dump_printf (TDF_TREE, "Access function of PHI: ");
+	  dump_generic_expr (TDF_SLIM, access_fn);
         }
 
       evolution_part = evolution_part_in_loop_num (access_fn, loop->num);
@@ -1704,7 +1698,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (evolution_part == NULL_TREE)
         {
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "No evolution.");
+	    dump_printf (TDF_TREE, "No evolution.");
 	  return false;
         }
 
@@ -1790,15 +1784,15 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
       phi1 = gsi_stmt (gsi1);
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "vect_update_ivs_after_vectorizer: phi: ");
-	  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "vect_update_ivs_after_vectorizer: phi: ");
+	  dump_gimple_stmt (TDF_SLIM, phi, 0);
         }
 
       /* Skip virtual phi's.  */
       if (!is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (phi))))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "virtual phi. skip.");
+	    dump_printf (TDF_TREE, "virtual phi. skip.");
 	  continue;
 	}
 
@@ -1807,7 +1801,7 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
       if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc phi. skip.");
+            dump_printf (TDF_TREE, "reduc phi. skip.");
           continue;
         }
 
@@ -1870,7 +1864,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
   gimple_seq cond_expr_stmt_list = NULL;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
+    dump_printf (TDF_TREE, "=== vect_do_peeling_for_loop_bound ===");
 
   initialize_original_copy_tables ();
 
@@ -1915,9 +1909,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
   if (check_profitability)
     max_iter = MAX (max_iter, (int) th);
   record_niter_bound (new_loop, shwi_to_double_int (max_iter), false, true);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "Setting upper bound of nb iterations for epilogue "
-	     "loop to %d\n", max_iter);
+  dump_printf (TDF_DETAILS,
+               "Setting upper bound of nb iterations for epilogue "
+               "loop to %d\n", max_iter);
 
   /* After peeling we have to reset scalar evolution analyzer.  */
   scev_reset ();
@@ -1980,7 +1974,7 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
       int npeel = LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo);
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "known peeling = %d.", npeel);
+        dump_printf (TDF_TREE, "known peeling = %d.", npeel);
 
       iters = build_int_cst (niters_type, npeel);
     }
@@ -2031,8 +2025,8 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "niters for prolog loop: ");
-      print_generic_expr (vect_dump, iters, TDF_SLIM);
+      dump_printf (TDF_TREE, "niters for prolog loop: ");
+      dump_generic_expr (TDF_SLIM, iters);
     }
 
   var = create_tmp_var (niters_type, "prolog_loop_niters");
@@ -2088,7 +2082,7 @@ vect_update_inits_of_drs (loop_vec_info loop_vinfo
   struct data_reference *dr;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_update_inits_of_dr ===");
+    dump_printf (TDF_TREE, "=== vect_update_inits_of_dr ===");
 
   FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr)
     vect_update_init_of_dr (dr, niters);
@@ -2115,7 +2109,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
   int max_iter;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_alignment ===");
+    dump_printf (TDF_TREE, "=== vect_do_peeling_for_alignment ===");
 
   initialize_original_copy_tables ();
 
@@ -2137,9 +2131,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
   if (check_profitability)
     max_iter = MAX (max_iter, (int) th);
   record_niter_bound (new_loop, shwi_to_double_int (max_iter), false, true);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "Setting upper bound of nb iterations for prologue "
-	     "loop to %d\n", max_iter);
+  dump_printf (TDF_DETAILS,
+               "Setting upper bound of nb iterations for prologue "
+               "loop to %d\n", max_iter);
 
   /* Update number of times loop executes.  */
   n_iters = LOOP_VINFO_NITERS (loop_vinfo);
@@ -2434,11 +2428,11 @@ vect_create_cond_for_alias_checks (loop_vec_info l
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
 	{
-	  fprintf (vect_dump,
-		   "create runtime check for data references ");
-	  print_generic_expr (vect_dump, DR_REF (dr_a), TDF_SLIM);
-	  fprintf (vect_dump, " and ");
-	  print_generic_expr (vect_dump, DR_REF (dr_b), TDF_SLIM);
+	  dump_printf (TDF_TREE,
+                       "create runtime check for data references ");
+	  dump_generic_expr (TDF_SLIM, DR_REF (dr_a));
+	  dump_printf (TDF_TREE, " and ");
+	  dump_generic_expr (TDF_SLIM, DR_REF (dr_b));
 	}
 
       seg_a_min = addr_base_a;
@@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
     }
 
   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "created %u versioning for alias checks.\n",
-             VEC_length (ddr_p, may_alias_ddrs));
+    dump_printf (TDF_TREE, "created %u versioning for alias checks.\n",
+                 VEC_length (ddr_p, may_alias_ddrs));
 }
 
 
@@ -2566,4 +2560,3 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
 			     GSI_SAME_STMT);
     }
 }
-
Index: testsuite/g++.dg/other/dump-vectorizer-1.C
===================================================================
--- testsuite/g++.dg/other/dump-vectorizer-1.C	(revision 0)
+++ testsuite/g++.dg/other/dump-vectorizer-1.C	(revision 0)
@@ -0,0 +1,32 @@
+// Test that the dump to a user-defined file works correctly.
+// { dg-options "-O2 -ftree-vectorize -fdump-tree-vect=foo.dump -ftree-vectorizer-verbose=1" }
+
+#include <stdio.h>
+#include <stdlib.h>
+
+char a[17];
+char c[16];
+
+int
+bar (int times)
+{
+ for (int i = 0; i< 16; i++)
+   a[i] = 0;
+
+ char *b = a+1;
+ for (int i = 0; i< 16; i++)
+   c[i] = b[i];
+
+ return 255;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int a = bar (atoi(argv[1]));
+ printf("%d\n", a);
+ return a;
+}
+
+// dg-final { scan-file foo.dump "17: LOOP VECTORIZED." } }
+// { dg-final { remove-build-file "foo.dump" } }
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 188212)
+++ gimple-pretty-print.c	(working copy)
@@ -91,19 +91,19 @@ debug_gimple_stmt (gimple gs)
 
 
 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  */
+   FLAGS as in print_gimple_stmt_1.  */
 
 void
 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
 {
   maybe_init_pretty_print (file);
-  dump_gimple_stmt (&buffer, g, spc, flags);
+  print_gimple_stmt_1 (&buffer, g, spc, flags);
   pp_flush (&buffer);
 }
 
 
 /* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  Print only the right-hand side
+   FLAGS as in print_gimple_stmt_1.  Print only the right-hand side
    of the statement.  */
 
 void
@@ -111,12 +111,12 @@ print_gimple_expr (FILE *file, gimple g, int spc,
 {
   flags |= TDF_RHS_ONLY;
   maybe_init_pretty_print (file);
-  dump_gimple_stmt (&buffer, g, spc, flags);
+  print_gimple_stmt_1 (&buffer, g, spc, flags);
 }
 
 
 /* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
-   spaces and FLAGS as in dump_gimple_stmt.  */
+   spaces and FLAGS as in print_gimple_stmt_1.  */
 
 static void
 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
@@ -127,7 +127,7 @@ dump_gimple_seq (pretty_printer *buffer, gimple_se
     {
       gimple gs = gsi_stmt (i);
       INDENT (spc);
-      dump_gimple_stmt (buffer, gs, spc, flags);
+      print_gimple_stmt_1 (buffer, gs, spc, flags);
       if (!gsi_one_before_end_p (i))
 	pp_newline (buffer);
     }
@@ -135,7 +135,7 @@ dump_gimple_seq (pretty_printer *buffer, gimple_se
 
 
 /* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  */
+   FLAGS as in print_gimple_stmt_1.  */
 
 void
 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
@@ -244,7 +244,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc,
 
 
 /* Helper for dump_gimple_assign.  Print the unary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -328,7 +328,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs,
 
 
 /* Helper for dump_gimple_assign.  Print the binary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -382,7 +382,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs
 }
 
 /* Helper for dump_gimple_assign.  Print the ternary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -467,7 +467,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple g
 
 
 /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -518,7 +518,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple
 
 
 /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -618,7 +618,7 @@ pp_points_to_solution (pretty_printer *buffer, str
 }
 
 /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -751,7 +751,7 @@ dump_gimple_call (pretty_printer *buffer, gimple g
 
 
 /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -786,7 +786,7 @@ dump_gimple_switch (pretty_printer *buffer, gimple
 
 
 /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -1578,7 +1578,7 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs
 
 
 /* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
@@ -1810,7 +1810,7 @@ dump_gimple_omp_atomic_store (pretty_printer *buff
 
 
 /* Dump all the memory operands for statement GS.  BUFFER, SPC and
-   FLAGS are as in dump_gimple_stmt.  */
+   FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -1845,7 +1845,7 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimpl
    TDF_* in tree-pass.h).  */
 
 void
-dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
+print_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
 {
   if (!gs)
     return;
@@ -2303,7 +2303,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic
       curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
 
       INDENT (curr_indent);
-      dump_gimple_stmt (buffer, stmt, curr_indent, flags);
+      print_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
       pp_newline (buffer);
       dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
     }
Index: gimple-pretty-print.h
===================================================================
--- gimple-pretty-print.h	(revision 188212)
+++ gimple-pretty-print.h	(working copy)
@@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
 extern void print_gimple_stmt (FILE *, gimple, int, int);
 extern void print_gimple_expr (FILE *, gimple, int, int);
-extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
+extern void print_gimple_stmt_1 (pretty_printer *, gimple, int, int);
 
 #endif /* ! GCC_GIMPLE_PRETTY_PRINT_H */
Index: tree-vectorizer.c
===================================================================
--- tree-vectorizer.c	(revision 188212)
+++ tree-vectorizer.c	(working copy)
@@ -96,20 +96,18 @@ VEC(vec_void_p,heap) *stmt_vec_info_vec;
 static void
 vect_set_dump_settings (bool slp)
 {
-  vect_dump = dump_file;
-
   /* Check if the verbosity level was defined by the user:  */
   if (user_vect_verbosity_level != MAX_VERBOSITY_LEVEL)
     {
       vect_verbosity_level = user_vect_verbosity_level;
       /* Ignore user defined verbosity if dump flags require higher level of
          verbosity.  */
-      if (dump_file)
+      if (dump_enabled_p (current_pass->static_pass_number))
         {
           if (((dump_flags & TDF_DETAILS)
-                && vect_verbosity_level >= REPORT_DETAILS)
-  	       || ((dump_flags & TDF_STATS)
-	            && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
+               && vect_verbosity_level >= REPORT_DETAILS)
+              || ((dump_flags & TDF_STATS)
+                  && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
             return;
         }
       else
@@ -117,21 +115,21 @@ vect_set_dump_settings (bool slp)
           /* If there is no dump file, print to stderr in case of loop
              vectorization.  */
           if (!slp)
-            vect_dump = stderr;
-
+            dump_set_alternate_stream (current_pass->static_pass_number,
+                                       "stderr", &dump_flags);
           return;
         }
     }
 
   /* User didn't specify verbosity level:  */
-  if (dump_file && (dump_flags & TDF_DETAILS))
+  if (dump_flags & TDF_DETAILS)
     vect_verbosity_level = REPORT_DETAILS;
-  else if (dump_file && (dump_flags & TDF_STATS))
+  else if (dump_flags & TDF_STATS)
     vect_verbosity_level = REPORT_UNVECTORIZED_LOCATIONS;
-  else
+  else if (user_vect_verbosity_level == MAX_VERBOSITY_LEVEL)
     vect_verbosity_level = REPORT_NONE;
 
-  gcc_assert (dump_file || vect_verbosity_level == REPORT_NONE);
+  gcc_assert (dump_flags || vect_verbosity_level == REPORT_NONE);
 }
 
 
@@ -145,15 +143,15 @@ vect_print_dump_info (enum vect_verbosity_levels v
   if (vl > vect_verbosity_level)
     return false;
 
-  if (!current_function_decl || !vect_dump)
+  if (!current_function_decl)
     return false;
 
   if (vect_location == UNKNOWN_LOC)
-    fprintf (vect_dump, "\n%s:%d: note: ",
-	     DECL_SOURCE_FILE (current_function_decl),
-	     DECL_SOURCE_LINE (current_function_decl));
+    dump_printf (TDF_TREE, "\n%s:%d: note: ",
+                 DECL_SOURCE_FILE (current_function_decl),
+                 DECL_SOURCE_LINE (current_function_decl));
   else
-    fprintf (vect_dump, "\n%d: ", LOC_LINE (vect_location));
+    dump_printf (TDF_TREE, "\n%d: ", LOC_LINE (vect_location));
 
   return true;
 }
@@ -194,10 +192,9 @@ vectorize_loops (void)
 	loop_vec_info loop_vinfo;
 
 	vect_location = find_loop_location (loop);
-        if (vect_location != UNKNOWN_LOC
-            && vect_verbosity_level > REPORT_NONE)
-	  fprintf (vect_dump, "\nAnalyzing loop at %s:%d\n",
-            LOC_FILE (vect_location), LOC_LINE (vect_location));
+        if (vect_location != UNKNOWN_LOC && vect_verbosity_level > REPORT_NONE)
+	  dump_printf (TDF_TREE, "\nAnalyzing loop at %s:%d\n",
+                       LOC_FILE (vect_location), LOC_LINE (vect_location));
 
 	loop_vinfo = vect_analyze_loop (loop);
 	loop->aux = loop_vinfo;
@@ -205,10 +202,9 @@ vectorize_loops (void)
 	if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
 	  continue;
 
-        if (vect_location != UNKNOWN_LOC
-            && vect_verbosity_level > REPORT_NONE)
-          fprintf (vect_dump, "\n\nVectorizing loop at %s:%d\n",
-            LOC_FILE (vect_location), LOC_LINE (vect_location));
+        if (vect_location != UNKNOWN_LOC && vect_verbosity_level > REPORT_NONE)
+          dump_printf (TDF_TREE, "\n\nVectorizing loop at %s:%d\n",
+                       LOC_FILE (vect_location), LOC_LINE (vect_location));
 
 	vect_transform_loop (loop_vinfo);
 	num_vectorized_loops++;
@@ -220,8 +216,8 @@ vectorize_loops (void)
   if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)
       || (num_vectorized_loops > 0
 	  && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)))
-    fprintf (vect_dump, "vectorized %u loops in function.\n",
-	     num_vectorized_loops);
+    dump_printf (TDF_TREE, "vectorized %u loops in function.\n",
+                 num_vectorized_loops);
 
   /*  ----------- Finalize. -----------  */
 
@@ -266,7 +262,7 @@ execute_vect_slp (void)
           vect_slp_transform_bb (bb);
 
           if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-            fprintf (vect_dump, "basic block vectorized using SLP\n");
+            dump_printf (TDF_TREE, "basic block vectorized using SLP\n");
         }
     }
 
@@ -339,12 +335,9 @@ increase_alignment (void)
         {
           DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
           DECL_USER_ALIGN (decl) = 1;
-          if (dump_file)
-            {
-              fprintf (dump_file, "Increasing alignment of decl: ");
-              print_generic_expr (dump_file, decl, TDF_SLIM);
-	      fprintf (dump_file, "\n");
-            }
+          dump_printf (TDF_TREE, "Increasing alignment of decl: ");
+          dump_generic_expr (TDF_SLIM, decl);
+          dump_printf (TDF_TREE, "\n");
         }
     }
   return 0;
Index: profile.c
===================================================================
--- profile.c	(revision 188212)
+++ profile.c	(working copy)
@@ -101,6 +101,7 @@ static int total_num_branches;
 
 /* Forward declarations.  */
 static void find_spanning_tree (struct edge_list *);
+static void end_branch_prob_1 (FILE *);
 
 /* Add edge instrumentation code to the entire insn chain.
 
@@ -1419,6 +1420,16 @@ init_branch_prob (void)
 void
 end_branch_prob (void)
 {
+  end_branch_prob_1 (dump_file);
+  end_branch_prob_1 (alt_dump_file);
+}
+
+/* Helper function for file-level cleanup for DUMP_FILE after
+   branch-prob processing is completed. */
+
+static void
+end_branch_prob_1 (FILE *dump_file)
+{
   if (dump_file)
     {
       fprintf (dump_file, "\n");
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 188212)
+++ tree-vect-loop.c	(working copy)
@@ -186,7 +186,7 @@ vect_determine_vectorization_factor (loop_vec_info
   bool analyze_pattern_stmt = false;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_determine_vectorization_factor ===");
+    dump_printf (TDF_TREE, "=== vect_determine_vectorization_factor ===");
 
   for (i = 0; i < nbbs; i++)
     {
@@ -198,8 +198,8 @@ vect_determine_vectorization_factor (loop_vec_info
 	  stmt_info = vinfo_for_stmt (phi);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "==> examining phi: ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "==> examining phi: ");
+	      dump_gimple_stmt (TDF_SLIM, phi, 0);
 	    }
 
 	  gcc_assert (stmt_info);
@@ -211,8 +211,8 @@ vect_determine_vectorization_factor (loop_vec_info
 
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "get vectype for scalar type:  ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  dump_printf (TDF_TREE, "get vectype for scalar type:  ");
+		  dump_generic_expr (TDF_SLIM, scalar_type);
 		}
 
 	      vectype = get_vectype_for_scalar_type (scalar_type);
@@ -220,9 +220,9 @@ vect_determine_vectorization_factor (loop_vec_info
 		{
 		  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		    {
-		      fprintf (vect_dump,
-		               "not vectorized: unsupported data-type ");
-		      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		      dump_printf (TDF_TREE,
+                                   "not vectorized: unsupported data-type ");
+		      dump_generic_expr (TDF_SLIM, scalar_type);
 		    }
 		  return false;
 		}
@@ -230,13 +230,13 @@ vect_determine_vectorization_factor (loop_vec_info
 
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "vectype: ");
-		  print_generic_expr (vect_dump, vectype, TDF_SLIM);
+		  dump_printf (TDF_TREE, "vectype: ");
+		  dump_generic_expr (TDF_SLIM, vectype);
 		}
 
 	      nunits = TYPE_VECTOR_SUBPARTS (vectype);
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "nunits = %d", nunits);
+		dump_printf (TDF_TREE, "nunits = %d", nunits);
 
 	      if (!vectorization_factor
 		  || (nunits > vectorization_factor))
@@ -257,8 +257,8 @@ vect_determine_vectorization_factor (loop_vec_info
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "==> examining statement: ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "==> examining statement: ");
+	      dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  gcc_assert (stmt_info);
@@ -276,14 +276,15 @@ vect_determine_vectorization_factor (loop_vec_info
                   stmt_info = vinfo_for_stmt (pattern_stmt);
                   if (vect_print_dump_info (REPORT_DETAILS))
                     {
-                      fprintf (vect_dump, "==> examining pattern statement: ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf (TDF_TREE,
+                                   "==> examining pattern statement: ");
+                      dump_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
                 }
               else
 	        {
 	          if (vect_print_dump_info (REPORT_DETAILS))
-	            fprintf (vect_dump, "skip.");
+	            dump_printf (TDF_TREE, "skip.");
                   gsi_next (&si);
 	          continue;
                 }
@@ -324,10 +325,9 @@ vect_determine_vectorization_factor (loop_vec_info
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
 			{
-			  fprintf (vect_dump,
-				   "==> examining pattern def stmt: ");
-			  print_gimple_stmt (vect_dump, pattern_def_stmt, 0,
-					     TDF_SLIM);
+			  dump_printf (TDF_TREE,
+                                       "==> examining pattern def stmt: ");
+			  dump_gimple_stmt (TDF_SLIM, pattern_def_stmt, 0);
 			}
 
 		      stmt = pattern_def_stmt;
@@ -347,8 +347,8 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-	          fprintf (vect_dump, "not vectorized: irregular stmt.");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	          dump_printf (TDF_TREE, "not vectorized: irregular stmt.");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -357,8 +357,9 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 	        {
-	          fprintf (vect_dump, "not vectorized: vector stmt in loop:");
-	          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	          dump_printf (TDF_TREE,
+                               "not vectorized: vector stmt in loop:");
+	          dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	        }
 	      return false;
 	    }
@@ -380,17 +381,17 @@ vect_determine_vectorization_factor (loop_vec_info
 	      scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "get vectype for scalar type:  ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  dump_printf (TDF_TREE, "get vectype for scalar type:  ");
+		  dump_generic_expr (TDF_SLIM, scalar_type);
 		}
 	      vectype = get_vectype_for_scalar_type (scalar_type);
 	      if (!vectype)
 		{
 		  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		    {
-		      fprintf (vect_dump,
-			       "not vectorized: unsupported data-type ");
-		      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		      dump_printf (TDF_TREE,
+                                   "not vectorized: unsupported data-type ");
+		      dump_generic_expr (TDF_SLIM, scalar_type);
 		    }
 		  return false;
 		}
@@ -405,17 +406,17 @@ vect_determine_vectorization_factor (loop_vec_info
 						       &dummy);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "get vectype for scalar type:  ");
-	      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+	      dump_printf (TDF_TREE, "get vectype for scalar type:  ");
+	      dump_generic_expr (TDF_SLIM, scalar_type);
 	    }
 	  vf_vectype = get_vectype_for_scalar_type (scalar_type);
 	  if (!vf_vectype)
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: unsupported data-type ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "not vectorized: unsupported data-type ");
+		  dump_generic_expr (TDF_SLIM, scalar_type);
 		}
 	      return false;
 	    }
@@ -425,25 +426,25 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: different sized vector "
-			   "types in statement, ");
-		  print_generic_expr (vect_dump, vectype, TDF_SLIM);
-		  fprintf (vect_dump, " and ");
-		  print_generic_expr (vect_dump, vf_vectype, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "not vectorized: different sized vector "
+                               "types in statement, ");
+		  dump_generic_expr (TDF_SLIM, vectype);
+		  dump_printf (TDF_TREE, " and ");
+		  dump_generic_expr (TDF_SLIM, vf_vectype);
 		}
 	      return false;
 	    }
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "vectype: ");
-	      print_generic_expr (vect_dump, vf_vectype, TDF_SLIM);
+	      dump_printf (TDF_TREE, "vectype: ");
+	      dump_generic_expr (TDF_SLIM, vf_vectype);
 	    }
 
 	  nunits = TYPE_VECTOR_SUBPARTS (vf_vectype);
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "nunits = %d", nunits);
+	    dump_printf (TDF_TREE, "nunits = %d", nunits);
 
 	  if (!vectorization_factor
 	      || (nunits > vectorization_factor))
@@ -459,11 +460,12 @@ vect_determine_vectorization_factor (loop_vec_info
 
   /* TODO: Analyze cost. Decide if worth while to vectorize.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vectorization factor = %d", vectorization_factor);
+    dump_printf (TDF_TREE, "vectorization factor = %d",
+                 vectorization_factor);
   if (vectorization_factor <= 1)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported data-type");
+        dump_printf (TDF_TREE, "not vectorized: unsupported data-type");
       return false;
     }
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
@@ -500,10 +502,10 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tre
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "step: ");
-      print_generic_expr (vect_dump, step_expr, TDF_SLIM);
-      fprintf (vect_dump, ",  init: ");
-      print_generic_expr (vect_dump, init_expr, TDF_SLIM);
+      dump_printf (TDF_TREE, "step: ");
+      dump_generic_expr (TDF_SLIM, step_expr);
+      dump_printf (TDF_TREE, ",  init: ");
+      dump_generic_expr (TDF_SLIM, init_expr);
     }
 
   *init = init_expr;
@@ -512,7 +514,7 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tre
   if (TREE_CODE (step_expr) != INTEGER_CST)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "step unknown.");
+        dump_printf (TDF_TREE, "step unknown.");
       return false;
     }
 
@@ -536,7 +538,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
   bool double_reduc;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_scalar_cycles ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_scalar_cycles ===");
 
   /* First - identify all inductions.  Reduction detection assumes that all the
      inductions have been identified, therefore, this order must not be
@@ -550,8 +552,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
 
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "Analyze phi: ");
-	  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	  dump_printf (TDF_TREE, "Analyze phi: ");
+	  dump_gimple_stmt (TDF_SLIM, phi, 0);
 	}
 
       /* Skip virtual phi's.  The data dependences that are associated with
@@ -568,8 +570,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
 	  STRIP_NOPS (access_fn);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "Access function of PHI: ");
-	      print_generic_expr (vect_dump, access_fn, TDF_SLIM);
+	      dump_printf (TDF_TREE, "Access function of PHI: ");
+	      dump_generic_expr (TDF_SLIM, access_fn);
 	    }
 	  STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
 	    = evolution_part_in_loop_num (access_fn, loop->num);
@@ -585,7 +587,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
       gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) != NULL_TREE);
 
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Detected induction.");
+	dump_printf (TDF_TREE, "Detected induction.");
       STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_induction_def;
     }
 
@@ -601,8 +603,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "Analyze phi: ");
+          dump_gimple_stmt (TDF_SLIM, phi, 0);
         }
 
       gcc_assert (is_gimple_reg (SSA_NAME_VAR (def)));
@@ -616,7 +618,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
           if (double_reduc)
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Detected double reduction.");
+                dump_printf (TDF_TREE, "Detected double reduction.");
 
               STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_double_reduction_def;
               STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -627,7 +629,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
               if (nested_cycle)
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Detected vectorizable nested cycle.");
+                    dump_printf (TDF_TREE,
+                                 "Detected vectorizable nested cycle.");
 
                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_nested_cycle;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -636,7 +639,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
               else
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Detected reduction.");
+                    dump_printf (TDF_TREE, "Detected reduction.");
 
                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_reduction_def;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -651,7 +654,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
         }
       else
         if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Unknown def-use cycle pattern.");
+          dump_printf (TDF_TREE, "Unknown def-use cycle pattern.");
     }
 
   VEC_free (gimple, heap, worklist);
@@ -712,7 +715,7 @@ vect_get_loop_niters (struct loop *loop, tree *num
   tree niters;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== get_loop_niters ===");
+    dump_printf (TDF_TREE, "=== get_loop_niters ===");
 
   niters = number_of_exit_cond_executions (loop);
 
@@ -723,8 +726,8 @@ vect_get_loop_niters (struct loop *loop, tree *num
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "==> get_loop_niters:" );
-          print_generic_expr (vect_dump, *number_of_iterations, TDF_SLIM);
+          dump_printf (TDF_TREE, "==> get_loop_niters:" );
+          dump_generic_expr (TDF_SLIM, *number_of_iterations);
         }
     }
 
@@ -948,7 +951,7 @@ vect_analyze_loop_1 (struct loop *loop)
   loop_vec_info loop_vinfo;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===== analyze_loop_nest_1 =====");
+    dump_printf (TDF_TREE, "===== analyze_loop_nest_1 =====");
 
   /* Check the CFG characteristics of the loop (nesting, entry/exit, etc.  */
 
@@ -956,7 +959,7 @@ vect_analyze_loop_1 (struct loop *loop)
   if (!loop_vinfo)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bad inner-loop form.");
+        dump_printf (TDF_TREE, "bad inner-loop form.");
       return NULL;
     }
 
@@ -981,7 +984,7 @@ vect_analyze_loop_form (struct loop *loop)
   loop_vec_info inner_loop_vinfo = NULL;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_loop_form ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_loop_form ===");
 
   /* Different restrictions apply when we are considering an inner-most loop,
      vs. an outer (nested) loop.
@@ -1004,14 +1007,14 @@ vect_analyze_loop_form (struct loop *loop)
       if (loop->num_nodes != 2)
         {
           if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: control flow in loop.");
+            dump_printf (TDF_TREE, "not vectorized: control flow in loop.");
           return NULL;
         }
 
       if (empty_block_p (loop->header))
     {
           if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: empty loop.");
+            dump_printf (TDF_TREE, "not vectorized: empty loop.");
       return NULL;
     }
     }
@@ -1040,7 +1043,7 @@ vect_analyze_loop_form (struct loop *loop)
       if ((loop->inner)->inner || (loop->inner)->next)
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: multiple nested loops.");
+	    dump_printf (TDF_TREE, "not vectorized: multiple nested loops.");
 	  return NULL;
 	}
 
@@ -1049,7 +1052,7 @@ vect_analyze_loop_form (struct loop *loop)
       if (!inner_loop_vinfo)
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: Bad inner loop.");
+            dump_printf (TDF_TREE, "not vectorized: Bad inner loop.");
 	  return NULL;
 	}
 
@@ -1057,8 +1060,8 @@ vect_analyze_loop_form (struct loop *loop)
 					LOOP_VINFO_NITERS (inner_loop_vinfo)))
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump,
-		     "not vectorized: inner-loop count not invariant.");
+	    dump_printf (TDF_TREE,
+                         "not vectorized: inner-loop count not invariant.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}
@@ -1066,7 +1069,7 @@ vect_analyze_loop_form (struct loop *loop)
       if (loop->num_nodes != 5)
         {
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: control flow in loop.");
+	    dump_printf (TDF_TREE, "not vectorized: control flow in loop.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
         }
@@ -1081,13 +1084,14 @@ vect_analyze_loop_form (struct loop *loop)
 	  || single_exit (innerloop)->dest !=  EDGE_PRED (loop->latch, 0)->src)
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: unsupported outerloop form.");
+	    dump_printf (TDF_TREE,
+                         "not vectorized: unsupported outerloop form.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Considering outer-loop vectorization.");
+        dump_printf (TDF_TREE, "Considering outer-loop vectorization.");
     }
 
   if (!single_exit (loop)
@@ -1096,9 +1100,10 @@ vect_analyze_loop_form (struct loop *loop)
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
         {
           if (!single_exit (loop))
-            fprintf (vect_dump, "not vectorized: multiple exits.");
+            dump_printf (TDF_TREE, "not vectorized: multiple exits.");
           else if (EDGE_COUNT (loop->header->preds) != 2)
-            fprintf (vect_dump, "not vectorized: too many incoming edges.");
+            dump_printf (TDF_TREE,
+                         "not vectorized: too many incoming edges.");
         }
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
@@ -1113,7 +1118,7 @@ vect_analyze_loop_form (struct loop *loop)
         || !gimple_seq_empty_p (phi_nodes (loop->latch)))
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-        fprintf (vect_dump, "not vectorized: unexpected loop form.");
+        dump_printf (TDF_TREE, "not vectorized: unexpected loop form.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1127,12 +1132,13 @@ vect_analyze_loop_form (struct loop *loop)
 	{
 	  split_loop_exit_edge (e);
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "split exit edge.");
+	    dump_printf (TDF_TREE, "split exit edge.");
 	}
       else
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: abnormal loop exit edge.");
+	    dump_printf (TDF_TREE,
+                         "not vectorized: abnormal loop exit edge.");
 	  if (inner_loop_vinfo)
 	    destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
@@ -1143,7 +1149,8 @@ vect_analyze_loop_form (struct loop *loop)
   if (!loop_cond)
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	fprintf (vect_dump, "not vectorized: complicated exit condition.");
+	dump_printf (TDF_TREE,
+                     "not vectorized: complicated exit condition.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1152,8 +1159,9 @@ vect_analyze_loop_form (struct loop *loop)
   if (!number_of_iterations)
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	fprintf (vect_dump,
-		 "not vectorized: number of iterations cannot be computed.");
+	dump_printf (TDF_TREE,
+                     "not vectorized: number of iterations cannot be "
+                     "computed.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1162,7 +1170,7 @@ vect_analyze_loop_form (struct loop *loop)
   if (chrec_contains_undetermined (number_of_iterations))
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-        fprintf (vect_dump, "Infinite number of iterations.");
+        dump_printf (TDF_TREE, "Infinite number of iterations.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1172,14 +1180,15 @@ vect_analyze_loop_form (struct loop *loop)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "Symbolic number of iterations is ");
-          print_generic_expr (vect_dump, number_of_iterations, TDF_DETAILS);
+          dump_printf (TDF_TREE, "Symbolic number of iterations is ");
+          if (dump_flags & TDF_DETAILS)
+            dump_generic_expr (TDF_DETAILS, number_of_iterations);
         }
     }
   else if (TREE_INT_CST_LOW (number_of_iterations) == 0)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: number of iterations = 0.");
+        dump_printf (TDF_TREE, "not vectorized: number of iterations = 0.");
       if (inner_loop_vinfo)
         destroy_loop_vec_info (inner_loop_vinfo, false);
       return NULL;
@@ -1237,7 +1246,7 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   HOST_WIDE_INT max_niter;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_loop_operations ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_loop_operations ===");
 
   gcc_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo));
   vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -1272,8 +1281,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
 
       LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Updating vectorization factor to %d ",
-	 		    vectorization_factor);
+	dump_printf (TDF_TREE, "Updating vectorization factor to %d ",
+                     vectorization_factor);
     }
 
   for (i = 0; i < nbbs; i++)
@@ -1288,8 +1297,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
           stmt_info = vinfo_for_stmt (phi);
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "examining phi: ");
-              print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+              dump_printf (TDF_TREE, "examining phi: ");
+              dump_gimple_stmt (TDF_SLIM, phi, 0);
             }
 
           /* Inner-loop loop-closed exit phi in outer-loop vectorization
@@ -1306,8 +1315,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
                      != vect_double_reduction_def)
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump,
-                             "Unsupported loop-closed phi in outer-loop.");
+                    dump_printf (TDF_TREE,
+                                 "Unsupported loop-closed phi in outer-loop.");
                   return false;
                 }
 
@@ -1347,7 +1356,7 @@ vect_analyze_loop_operations (loop_vec_info loop_v
             {
               /* FORNOW: not yet supported.  */
               if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-                fprintf (vect_dump, "not vectorized: value used after loop.");
+                dump_printf (TDF_TREE, "not vectorized: value used after loop.");
               return false;
             }
 
@@ -1356,7 +1365,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
             {
               /* A scalar-dependence cycle that we don't support.  */
               if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-                fprintf (vect_dump, "not vectorized: scalar dependence cycle.");
+                dump_printf (TDF_TREE,
+                             "not vectorized: scalar dependence cycle.");
               return false;
             }
 
@@ -1371,9 +1381,9 @@ vect_analyze_loop_operations (loop_vec_info loop_v
             {
               if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
                 {
-                  fprintf (vect_dump,
-                           "not vectorized: relevant phi not supported: ");
-                  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+                  dump_printf (TDF_TREE,
+                               "not vectorized: relevant phi not supported: ");
+                  dump_gimple_stmt (TDF_SLIM, phi, 0);
                 }
               return false;
             }
@@ -1395,19 +1405,19 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   if (!need_to_vectorize)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump,
-                 "All the computation can be taken out of the loop.");
+        dump_printf (TDF_TREE,
+                     "All the computation can be taken out of the loop.");
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump,
-                 "not vectorized: redundant loop. no profit to vectorize.");
+        dump_printf (TDF_TREE,
+                     "not vectorized: redundant loop. no profit to vectorize.");
       return false;
     }
 
   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
       && vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump,
-        "vectorization_factor = %d, niters = " HOST_WIDE_INT_PRINT_DEC,
-        vectorization_factor, LOOP_VINFO_INT_NITERS (loop_vinfo));
+    dump_printf (TDF_TREE,
+                 "vectorization_factor = %d, niters = " HOST_WIDE_INT_PRINT_DEC,
+                 vectorization_factor, LOOP_VINFO_INT_NITERS (loop_vinfo));
 
   if ((LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
        && (LOOP_VINFO_INT_NITERS (loop_vinfo) < vectorization_factor))
@@ -1415,10 +1425,10 @@ vect_analyze_loop_operations (loop_vec_info loop_v
 	  && (unsigned HOST_WIDE_INT) max_niter < vectorization_factor))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: iteration count too small.");
+        dump_printf (TDF_TREE, "not vectorized: iteration count too small.");
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump,"not vectorized: iteration count smaller than "
-                 "vectorization factor.");
+        dump_printf (TDF_TREE,"not vectorized: iteration count smaller than "
+                     "vectorization factor.");
       return false;
     }
 
@@ -1434,10 +1444,11 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   if (min_profitable_iters < 0)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization not profitable.");
+        dump_printf (TDF_TREE, "not vectorized: vectorization not profitable.");
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not vectorized: vector version will never be "
-                 "profitable.");
+        dump_printf (TDF_TREE,
+                     "not vectorized: vector version will never be "
+                     "profitable.");
       return false;
     }
 
@@ -1457,12 +1468,13 @@ vect_analyze_loop_operations (loop_vec_info loop_v
       && LOOP_VINFO_INT_NITERS (loop_vinfo) <= th)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization not "
+        dump_printf (TDF_TREE, "not vectorized: vectorization not "
                  "profitable.");
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not vectorized: iteration count smaller than "
-                 "user specified loop bound parameter or minimum "
-                 "profitable iterations (whichever is more conservative).");
+        dump_printf (TDF_TREE,
+                     "not vectorized: iteration count smaller than "
+                     "user specified loop bound parameter or minimum "
+                     "profitable iterations (whichever is more conservative).");
       return false;
     }
 
@@ -1471,19 +1483,19 @@ vect_analyze_loop_operations (loop_vec_info loop_v
       || LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "epilog loop required.");
+        dump_printf (TDF_TREE, "epilog loop required.");
       if (!vect_can_advance_ivs_p (loop_vinfo))
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump,
-                     "not vectorized: can't create epilog loop 1.");
+            dump_printf (TDF_TREE,
+                         "not vectorized: can't create epilog loop 1.");
           return false;
         }
       if (!slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump,
-                     "not vectorized: can't create epilog loop 2.");
+            dump_printf (TDF_TREE,
+                         "not vectorized: can't create epilog loop 2.");
           return false;
         }
     }
@@ -1515,7 +1527,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data references.");
+	dump_printf (TDF_TREE, "bad data references.");
       return false;
     }
 
@@ -1532,7 +1544,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "unexpected pattern.");
+	dump_printf (TDF_TREE, "unexpected pattern.");
       return false;
     }
 
@@ -1546,7 +1558,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
       || max_vf < min_vf)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data dependence.");
+	dump_printf (TDF_TREE, "bad data dependence.");
       return false;
     }
 
@@ -1554,13 +1566,13 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "can't determine vectorization factor.");
+        dump_printf (TDF_TREE, "can't determine vectorization factor.");
       return false;
     }
   if (max_vf < LOOP_VINFO_VECT_FACTOR (loop_vinfo))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data dependence.");
+	dump_printf (TDF_TREE, "bad data dependence.");
       return false;
     }
 
@@ -1571,7 +1583,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data alignment.");
+	dump_printf (TDF_TREE, "bad data alignment.");
       return false;
     }
 
@@ -1582,7 +1594,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data access.");
+	dump_printf (TDF_TREE, "bad data access.");
       return false;
     }
 
@@ -1593,8 +1605,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "too long list of versioning for alias "
-			    "run-time tests.");
+	dump_printf (TDF_TREE, "too long list of versioning for alias "
+                     "run-time tests.");
       return false;
     }
 
@@ -1605,7 +1617,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bad data alignment.");
+        dump_printf (TDF_TREE, "bad data alignment.");
       return false;
     }
 
@@ -1629,7 +1641,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad operation or unsupported loop bound.");
+	dump_printf (TDF_TREE, "bad operation or unsupported loop bound.");
       return false;
     }
 
@@ -1652,14 +1664,14 @@ vect_analyze_loop (struct loop *loop)
   vector_sizes = targetm.vectorize.autovectorize_vector_sizes ();
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===== analyze_loop_nest =====");
+    dump_printf (TDF_TREE, "===== analyze_loop_nest =====");
 
   if (loop_outer (loop)
       && loop_vec_info_for_loop (loop_outer (loop))
       && LOOP_VINFO_VECTORIZABLE_P (loop_vec_info_for_loop (loop_outer (loop))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "outer-loop already vectorized.");
+	dump_printf (TDF_TREE, "outer-loop already vectorized.");
       return NULL;
     }
 
@@ -1670,7 +1682,7 @@ vect_analyze_loop (struct loop *loop)
       if (!loop_vinfo)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "bad loop form.");
+	    dump_printf (TDF_TREE, "bad loop form.");
 	  return NULL;
 	}
 
@@ -1691,7 +1703,7 @@ vect_analyze_loop (struct loop *loop)
       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "***** Re-trying analysis with "
+	dump_printf (TDF_TREE, "***** Re-trying analysis with "
 		 "vector size %d\n", current_vector_size);
     }
 }
@@ -1748,8 +1760,8 @@ reduction_code_for_scalar_code (enum tree_code cod
 static void
 report_vect_op (gimple stmt, const char *msg)
 {
-  fprintf (vect_dump, "%s", msg);
-  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+  dump_printf (TDF_TREE, "%s", msg);
+  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 }
 
 
@@ -1923,8 +1935,8 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
   	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "swapping oprnds: ");
-		  print_gimple_stmt (vect_dump, next_stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE, "swapping oprnds: ");
+		  dump_gimple_stmt (TDF_SLIM, next_stmt, 0);
 		}
 
 	      swap_tree_operands (next_stmt,
@@ -2021,7 +2033,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "intermediate value used outside loop.");
+            dump_printf (TDF_TREE, "intermediate value used outside loop.");
 
           return NULL;
         }
@@ -2032,7 +2044,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (nloop_uses > 1)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduction used in loop.");
+            dump_printf (TDF_TREE, "reduction used in loop.");
           return NULL;
         }
     }
@@ -2041,8 +2053,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
     {
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "reduction: not ssa_name: ");
-	  print_generic_expr (vect_dump, loop_arg, TDF_SLIM);
+	  dump_printf (TDF_TREE, "reduction: not ssa_name: ");
+	  dump_generic_expr (TDF_SLIM, loop_arg);
 	}
       return NULL;
     }
@@ -2051,14 +2063,14 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
   if (!def_stmt)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "reduction: no def_stmt.");
+	dump_printf (TDF_TREE, "reduction: no def_stmt.");
       return NULL;
     }
 
   if (!is_gimple_assign (def_stmt) && gimple_code (def_stmt) != GIMPLE_PHI)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        print_gimple_stmt (vect_dump, def_stmt, 0, TDF_SLIM);
+        dump_gimple_stmt (TDF_SLIM, def_stmt, 0);
       return NULL;
     }
 
@@ -2086,7 +2098,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (nloop_uses > 1)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "reduction used in loop.");
+	    dump_printf (TDF_TREE, "reduction used in loop.");
 	  return NULL;
 	}
     }
@@ -2101,7 +2113,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
           || TREE_CODE (op1) != SSA_NAME)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "unsupported phi node definition.");
+            dump_printf (TDF_TREE, "unsupported phi node definition.");
 
           return NULL;
         }
@@ -2197,22 +2209,23 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "reduction: multiple types: operation type: ");
-          print_generic_expr (vect_dump, type, TDF_SLIM);
-          fprintf (vect_dump, ", operands types: ");
-          print_generic_expr (vect_dump, TREE_TYPE (op1), TDF_SLIM);
-          fprintf (vect_dump, ",");
-          print_generic_expr (vect_dump, TREE_TYPE (op2), TDF_SLIM);
+          dump_printf (TDF_TREE,
+                       "reduction: multiple types: operation type: ");
+          dump_generic_expr (TDF_SLIM, type);
+          dump_printf (TDF_TREE, ", operands types: ");
+          dump_generic_expr (TDF_SLIM, TREE_TYPE (op1));
+          dump_printf (TDF_TREE, ",");
+          dump_generic_expr (TDF_SLIM, TREE_TYPE (op2));
           if (op3)
             {
-              fprintf (vect_dump, ",");
-              print_generic_expr (vect_dump, TREE_TYPE (op3), TDF_SLIM);
+              dump_printf (TDF_TREE, ",");
+              dump_generic_expr (TDF_SLIM, TREE_TYPE (op3));
             }
 
           if (op4)
             {
-              fprintf (vect_dump, ",");
-              print_generic_expr (vect_dump, TREE_TYPE (op4), TDF_SLIM);
+              dump_printf (TDF_TREE, ",");
+              dump_generic_expr (TDF_SLIM, TREE_TYPE (op4));
             }
         }
 
@@ -2460,9 +2473,9 @@ vect_get_known_peeling_cost (loop_vec_info loop_vi
     {
       *peel_iters_epilogue = vf/2;
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                            "epilogue peel iters set to vf/2 because "
-                            "loop iterations are unknown .");
+        dump_printf (TDF_TREE, "cost model: "
+                     "epilogue peel iters set to vf/2 because "
+                     "loop iterations are unknown .");
 
       /* If peeled iterations are known but number of scalar loop
          iterations are unknown, count a taken branch per peeled loop.  */
@@ -2519,7 +2532,7 @@ vect_estimate_min_profitable_iters (loop_vec_info
   if (!flag_vect_cost_model)
     {
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model disabled.");
+        dump_printf (TDF_TREE, "cost model disabled.");
       return 0;
     }
 
@@ -2530,8 +2543,8 @@ vect_estimate_min_profitable_iters (loop_vec_info
       vec_outside_cost +=
 	VEC_length (gimple, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo));
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: Adding cost of checks for loop "
-                 "versioning to treat misalignment.\n");
+        dump_printf (TDF_TREE, "cost model: Adding cost of checks for loop "
+                     "versioning to treat misalignment.\n");
     }
 
   /* Requires loop versioning with alias checks.  */
@@ -2541,8 +2554,8 @@ vect_estimate_min_profitable_iters (loop_vec_info
       vec_outside_cost +=
         VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo));
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: Adding cost of checks for loop "
-                 "versioning aliasing.\n");
+        dump_printf (TDF_TREE, "cost model: Adding cost of checks for loop "
+                     "versioning aliasing.\n");
     }
 
   if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo)
@@ -2633,16 +2646,16 @@ vect_estimate_min_profitable_iters (loop_vec_info
     {
       peel_iters_prologue = vf/2;
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                 "prologue peel iters set to vf/2.");
+        dump_printf (TDF_TREE, "cost model: "
+                     "prologue peel iters set to vf/2.");
 
       /* If peeling for alignment is unknown, loop bound of main loop becomes
          unknown.  */
       peel_iters_epilogue = vf/2;
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                 "epilogue peel iters set to vf/2 because "
-                 "peeling for alignment is unknown .");
+        dump_printf (TDF_TREE, "cost model: "
+                     "epilogue peel iters set to vf/2 because "
+                     "peeling for alignment is unknown .");
 
       /* If peeled iterations are unknown, count a taken branch and a not taken
          branch per peeled loop. Even if scalar loop iterations are known,
@@ -2775,29 +2788,31 @@ vect_estimate_min_profitable_iters (loop_vec_info
   else
     {
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: the vector iteration cost = %d "
-		 "divided by the scalar iteration cost = %d "
-		 "is greater or equal to the vectorization factor = %d.",
-                 vec_inside_cost, scalar_single_iter_cost, vf);
+        dump_printf (TDF_TREE, "cost model: the vector iteration cost = %d "
+                     "divided by the scalar iteration cost = %d "
+                     "is greater or equal to the vectorization factor = %d.",
+                     vec_inside_cost, scalar_single_iter_cost, vf);
       return -1;
     }
 
   if (vect_print_dump_info (REPORT_COST))
     {
-      fprintf (vect_dump, "Cost model analysis: \n");
-      fprintf (vect_dump, "  Vector inside of loop cost: %d\n",
-	       vec_inside_cost);
-      fprintf (vect_dump, "  Vector outside of loop cost: %d\n",
-	       vec_outside_cost);
-      fprintf (vect_dump, "  Scalar iteration cost: %d\n",
-	       scalar_single_iter_cost);
-      fprintf (vect_dump, "  Scalar outside cost: %d\n", scalar_outside_cost);
-      fprintf (vect_dump, "  prologue iterations: %d\n",
-               peel_iters_prologue);
-      fprintf (vect_dump, "  epilogue iterations: %d\n",
-               peel_iters_epilogue);
-      fprintf (vect_dump, "  Calculated minimum iters for profitability: %d\n",
-	       min_profitable_iters);
+      dump_printf (TDF_TREE, "Cost model analysis: \n");
+      dump_printf (TDF_TREE, "  Vector inside of loop cost: %d\n",
+                   vec_inside_cost);
+      dump_printf (TDF_TREE, "  Vector outside of loop cost: %d\n",
+                   vec_outside_cost);
+      dump_printf (TDF_TREE, "  Scalar iteration cost: %d\n",
+                   scalar_single_iter_cost);
+      dump_printf (TDF_TREE, "  Scalar outside cost: %d\n",
+                   scalar_outside_cost);
+      dump_printf (TDF_TREE, "  prologue iterations: %d\n",
+                   peel_iters_prologue);
+      dump_printf (TDF_TREE, "  epilogue iterations: %d\n",
+                   peel_iters_epilogue);
+      dump_printf (TDF_TREE,
+                   "  Calculated minimum iters for profitability: %d\n",
+                   min_profitable_iters);
     }
 
   min_profitable_iters =
@@ -2809,8 +2824,8 @@ vect_estimate_min_profitable_iters (loop_vec_info
   min_profitable_iters--;
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "  Profitability threshold = %d\n",
-	     min_profitable_iters);
+    dump_printf (TDF_TREE, "  Profitability threshold = %d\n",
+                 min_profitable_iters);
 
   return min_profitable_iters;
 }
@@ -2870,8 +2885,8 @@ vect_model_reduction_cost (stmt_vec_info stmt_info
     {
       if (vect_print_dump_info (REPORT_COST))
         {
-          fprintf (vect_dump, "unsupported data-type ");
-          print_generic_expr (vect_dump, TREE_TYPE (reduction_op), TDF_SLIM);
+          dump_printf (TDF_TREE, "unsupported data-type ");
+          dump_generic_expr (TDF_SLIM, TREE_TYPE (reduction_op));
         }
       return false;
    }
@@ -2927,9 +2942,11 @@ vect_model_reduction_cost (stmt_vec_info stmt_info
   STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info) = outer_cost;
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_reduction_cost: inside_cost = %d, "
-             "outside_cost = %d .", STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
-             STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
+    dump_printf (TDF_TREE,
+                 "vect_model_reduction_cost: inside_cost = %d, "
+                 "outside_cost = %d .",
+                 STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
+                 STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
 
   return true;
 }
@@ -2950,9 +2967,10 @@ vect_model_induction_cost (stmt_vec_info stmt_info
     = 2 * vect_get_cost (scalar_to_vec);
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_induction_cost: inside_cost = %d, "
-             "outside_cost = %d .", STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
-             STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
+    dump_printf (TDF_TREE, "vect_model_induction_cost: inside_cost = %d, "
+                 "outside_cost = %d .",
+                 STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
+                 STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
 }
 
 
@@ -3082,8 +3100,8 @@ get_initial_def_for_induction (gimple iv_phi)
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "created new init_stmt: ");
-	      print_gimple_stmt (vect_dump, init_stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "created new init_stmt: ");
+	      dump_gimple_stmt (TDF_SLIM, init_stmt, 0);
 	    }
 	  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
 	}
@@ -3225,8 +3243,9 @@ get_initial_def_for_induction (gimple iv_phi)
 	  STMT_VINFO_VEC_STMT (stmt_vinfo) = new_stmt;
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "vector of inductions after inner-loop:");
-	      print_gimple_stmt (vect_dump, new_stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE,
+                           "vector of inductions after inner-loop:");
+	      dump_gimple_stmt (TDF_SLIM, new_stmt, 0);
 	    }
 	}
     }
@@ -3234,10 +3253,10 @@ get_initial_def_for_induction (gimple iv_phi)
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "transform induction: created def-use cycle: ");
-      print_gimple_stmt (vect_dump, induction_phi, 0, TDF_SLIM);
-      fprintf (vect_dump, "\n");
-      print_gimple_stmt (vect_dump, SSA_NAME_DEF_STMT (vec_def), 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "transform induction: created def-use cycle: ");
+      dump_gimple_stmt (TDF_SLIM, induction_phi, 0);
+      dump_printf (TDF_TREE, "\n");
+      dump_gimple_stmt (TDF_SLIM, SSA_NAME_DEF_STMT (vec_def), 0);
     }
 
   STMT_VINFO_VEC_STMT (phi_info) = induction_phi;
@@ -3640,12 +3659,11 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
 
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "transform reduction: created def-use"
-                                  " cycle: ");
-              print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
-              fprintf (vect_dump, "\n");
-              print_gimple_stmt (vect_dump, SSA_NAME_DEF_STMT (def), 0,
-                                 TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "transform reduction: created def-use cycle: ");
+              dump_gimple_stmt (TDF_SLIM, phi, 0);
+              dump_printf (TDF_TREE, "\n");
+              dump_gimple_stmt (TDF_SLIM, SSA_NAME_DEF_STMT (def), 0);
             }
 
           phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi));
@@ -3840,7 +3858,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
            v_out2 = reduc_expr <v_out1>  */
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Reduce using direct vector reduction.");
+        dump_printf (TDF_TREE, "Reduce using direct vector reduction.");
 
       vec_dest = vect_create_destination_var (scalar_dest, vectype);
       tmp = build1 (reduc_code, vectype, new_phi_result);
@@ -3890,7 +3908,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
                 }  */
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Reduce using vector shifts");
+            dump_printf (TDF_TREE, "Reduce using vector shifts");
 
           vec_dest = vect_create_destination_var (scalar_dest, vectype);
           new_temp = new_phi_result;
@@ -3930,7 +3948,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
                }  */
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Reduce using scalar code. ");
+            dump_printf (TDF_TREE, "Reduce using scalar code. ");
 
           vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1);
           FOR_EACH_VEC_ELT (gimple, new_phis, i, new_phi)
@@ -4020,7 +4038,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
       tree rhs;
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "extract scalar result");
+        dump_printf (TDF_TREE, "extract scalar result");
 
       if (BYTES_BIG_ENDIAN)
         bitpos = size_binop (MULT_EXPR,
@@ -4259,9 +4277,9 @@ vect_finalize_reduction:
                                loop_latch_edge (outer_loop), UNKNOWN_LOCATION);
                   if (vect_print_dump_info (REPORT_DETAILS))
                     {
-                      fprintf (vect_dump, "created double reduction phi "
-                                          "node: ");
-                      print_gimple_stmt (vect_dump, vect_phi, 0, TDF_SLIM);
+                      dump_printf (TDF_TREE, "created double reduction phi "
+                                   "node: ");
+                      dump_gimple_stmt (TDF_SLIM, vect_phi, 0);
                     }
 
                   vect_phi_res = PHI_RESULT (vect_phi);
@@ -4608,7 +4626,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!vectorizable_condition (stmt, gsi, NULL, ops[reduc_index], 0, NULL))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "unsupported condition in reduction");
+            dump_printf (TDF_TREE, "unsupported condition in reduction");
 
             return false;
         }
@@ -4622,7 +4640,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!optab)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no optab.");
+            dump_printf (TDF_TREE, "no optab.");
 
           return false;
         }
@@ -4630,7 +4648,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (optab_handler (optab, vec_mode) == CODE_FOR_nothing)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "op not supported by target.");
+            dump_printf (TDF_TREE, "op not supported by target.");
 
           if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
               || LOOP_VINFO_VECT_FACTOR (loop_vinfo)
@@ -4638,7 +4656,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
             return false;
 
           if (vect_print_dump_info (REPORT_DETAILS))
-  	    fprintf (vect_dump, "proceeding using word mode.");
+  	    dump_printf (TDF_TREE, "proceeding using word mode.");
         }
 
       /* Worthwhile without SIMD support?  */
@@ -4647,7 +4665,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
    	     < vect_min_worthwhile_factor (code))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "not worthwhile without SIMD support.");
+	    dump_printf (TDF_TREE, "not worthwhile without SIMD support.");
 
           return false;
         }
@@ -4727,7 +4745,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!reduc_optab)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no optab for reduction.");
+            dump_printf (TDF_TREE, "no optab for reduction.");
 
           epilog_reduc_code = ERROR_MARK;
         }
@@ -4736,7 +4754,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
           && optab_handler (reduc_optab, vec_mode) == CODE_FOR_nothing)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc op not supported by target.");
+            dump_printf (TDF_TREE, "reduc op not supported by target.");
 
           epilog_reduc_code = ERROR_MARK;
         }
@@ -4746,7 +4764,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!nested_cycle || double_reduc)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no reduc code for scalar code.");
+            dump_printf (TDF_TREE, "no reduc code for scalar code.");
 
           return false;
         }
@@ -4755,7 +4773,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
   if (double_reduc && ncopies > 1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in double reduction");
+        dump_printf (TDF_TREE, "multiple types in double reduction");
 
       return false;
     }
@@ -4773,7 +4791,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       else
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "invalid types in dot-prod");
+            dump_printf (TDF_TREE, "invalid types in dot-prod");
 
           return false;
         }
@@ -4790,7 +4808,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform reduction.");
+    dump_printf (TDF_TREE, "transform reduction.");
 
   /* FORNOW: Multiple types are not supported for condition.  */
   if (code == COND_EXPR)
@@ -5076,7 +5094,7 @@ vectorizable_induction (gimple phi, gimple_stmt_it
       if (ncopies > 1)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple types in nested loop.");
+	    dump_printf (TDF_TREE, "multiple types in nested loop.");
 	  return false;
 	}
 
@@ -5099,8 +5117,9 @@ vectorizable_induction (gimple phi, gimple_stmt_it
 		&& !STMT_VINFO_LIVE_P (exit_phi_vinfo)))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "inner-loop induction only used outside "
-			 "of the outer vectorized loop.");
+		dump_printf (TDF_TREE,
+                             "inner-loop induction only used outside "
+                             "of the outer vectorized loop.");
 	      return false;
 	    }
 	}
@@ -5122,7 +5141,7 @@ vectorizable_induction (gimple phi, gimple_stmt_it
     {
       STMT_VINFO_TYPE (stmt_info) = induc_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_induction ===");
+        dump_printf (TDF_TREE, "=== vectorizable_induction ===");
       vect_model_induction_cost (stmt_info, ncopies);
       return true;
     }
@@ -5130,7 +5149,7 @@ vectorizable_induction (gimple phi, gimple_stmt_it
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform induction phi.");
+    dump_printf (TDF_TREE, "transform induction phi.");
 
   vec_def = get_initial_def_for_induction (phi);
   *vec_stmt = SSA_NAME_DEF_STMT (vec_def);
@@ -5195,7 +5214,7 @@ vectorizable_live_operation (gimple stmt,
 				  &dt))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "use not simple.");
+            dump_printf (TDF_TREE, "use not simple.");
           return false;
         }
 
@@ -5233,7 +5252,7 @@ vect_loop_kill_debug_uses (struct loop *loop, gimp
 	      if (gimple_debug_bind_p (ustmt))
 		{
 		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "killing debug use");
+		    dump_printf (TDF_TREE, "killing debug use");
 
 		  gimple_debug_bind_reset_value (ustmt);
 		  update_stmt (ustmt);
@@ -5272,7 +5291,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   int th;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vec_transform_loop ===");
+    dump_printf (TDF_TREE, "=== vec_transform_loop ===");
 
   /* Use the more conservative vectorization threshold.  If the number
      of iterations is constant assume the cost check has been performed
@@ -5286,8 +5305,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
       && !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
       if (vect_print_dump_info (REPORT_COST))
-	fprintf (vect_dump,
-		 "Profitability threshold is %d loop iterations.", th);
+	dump_printf (TDF_TREE,
+                     "Profitability threshold is %d loop iterations.", th);
       check_profitability = true;
     }
 
@@ -5348,8 +5367,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	  phi = gsi_stmt (si);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "------>vectorizing phi: ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "------>vectorizing phi: ");
+	      dump_gimple_stmt (TDF_SLIM, phi, 0);
 	    }
 	  stmt_info = vinfo_for_stmt (phi);
 	  if (!stmt_info)
@@ -5365,12 +5384,12 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	  if ((TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info))
 	        != (unsigned HOST_WIDE_INT) vectorization_factor)
 	      && vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple-types.");
+	    dump_printf (TDF_TREE, "multiple-types.");
 
 	  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "transform phi.");
+		dump_printf (TDF_TREE, "transform phi.");
 	      vect_transform_stmt (phi, NULL, NULL, NULL, NULL);
 	    }
 	}
@@ -5387,8 +5406,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "------>vectorizing statement: ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "------>vectorizing statement: ");
+	      dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  stmt_info = vinfo_for_stmt (stmt);
@@ -5458,10 +5477,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
 			{
-			  fprintf (vect_dump, "==> vectorizing pattern def"
-					      " stmt: ");
-			  print_gimple_stmt (vect_dump, pattern_def_stmt, 0,
-					     TDF_SLIM);
+			  dump_printf (TDF_TREE,
+                                       "==> vectorizing pattern def stmt: ");
+			  dump_gimple_stmt (TDF_SLIM, pattern_def_stmt, 0);
 			}
 
 		      stmt = pattern_def_stmt;
@@ -5485,7 +5503,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
               && vect_print_dump_info (REPORT_DETAILS))
 	    /* For SLP VF is set according to unrolling factor, and not to
 	       vector size, hence for SLP this print is not valid.  */
-            fprintf (vect_dump, "multiple-types.");
+            dump_printf (TDF_TREE, "multiple-types.");
 
 	  /* SLP. Schedule all the SLP instances when the first SLP stmt is
 	     reached.  */
@@ -5496,7 +5514,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		  slp_scheduled = true;
 
 		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "=== scheduling SLP instances ===");
+		    dump_printf (TDF_TREE,
+                                 "=== scheduling SLP instances ===");
 
 		  vect_schedule_slp (loop_vinfo, NULL);
 		}
@@ -5515,10 +5534,11 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 
 	  /* -------- vectorize statement ------------ */
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "transform statement.");
+	    dump_printf (TDF_TREE, "transform statement.");
 
 	  grouped_store = false;
-	  is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL, NULL);
+	  is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL,
+                                          NULL);
           if (is_store)
             {
 	      if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
@@ -5558,7 +5578,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   update_ssa (TODO_update_ssa);
 
   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "LOOP VECTORIZED.");
+    dump_printf (TDF_TREE, "LOOP VECTORIZED.");
   if (loop->inner && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "OUTER LOOP VECTORIZED.");
+    dump_printf (TDF_TREE, "OUTER LOOP VECTORIZED.");
 }
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c	(revision 188212)
+++ tree-vect-data-refs.c	(working copy)
@@ -61,22 +61,23 @@ vect_lanes_optab_supported_p (const char *name, co
   if (array_mode == BLKmode)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "no array mode for %s[" HOST_WIDE_INT_PRINT_DEC "]",
-		 GET_MODE_NAME (mode), count);
+	dump_printf (TDF_TREE,
+                     "no array mode for %s[" HOST_WIDE_INT_PRINT_DEC "]",
+                     GET_MODE_NAME (mode), count);
       return false;
     }
 
   if (convert_optab_handler (optab, array_mode, mode) == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "cannot use %s<%s><%s>",
-		 name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+	dump_printf (TDF_TREE, "cannot use %s<%s><%s>",
+                     name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
       return false;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "can use %s<%s><%s>",
-	     name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+    dump_printf (TDF_TREE, "can use %s<%s><%s>",
+                 name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
 
   return true;
 }
@@ -438,10 +439,10 @@ vect_check_interleaving (struct data_reference *dr
 	  vect_update_interleaving_chain (drb, dra);
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "Detected interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf (TDF_TREE, "Detected interleaving ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (dra));
+	      dump_printf (TDF_TREE, " and ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 	  return true;
 	}
@@ -460,10 +461,10 @@ vect_check_interleaving (struct data_reference *dr
 	  vect_update_interleaving_chain (dra, drb);
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "Detected interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf (TDF_TREE, "Detected interleaving ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (dra));
+	      dump_printf (TDF_TREE, " and ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 	  return true;
 	}
@@ -521,16 +522,17 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
 
   if (vect_print_dump_info (REPORT_DR_DETAILS))
     {
-      fprintf (vect_dump, "mark for run-time aliasing test between ");
-      print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
-      fprintf (vect_dump, " and ");
-      print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+      dump_printf (TDF_TREE, "mark for run-time aliasing test between ");
+      dump_generic_expr (TDF_SLIM, DR_REF (DDR_A (ddr)));
+      dump_printf (TDF_TREE, " and ");
+      dump_generic_expr (TDF_SLIM, DR_REF (DDR_B (ddr)));
     }
 
   if (optimize_loop_nest_for_size_p (loop))
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not supported when optimizing for size.");
+	dump_printf (TDF_TREE,
+                     "versioning not supported when optimizing for size.");
       return false;
     }
 
@@ -538,7 +540,8 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
   if (loop->inner)
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not yet supported for outer-loops.");
+	dump_printf (TDF_TREE,
+                     "versioning not yet supported for outer-loops.");
       return false;
     }
 
@@ -548,8 +551,9 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
       || TREE_CODE (DR_STEP (DDR_B (ddr))) != INTEGER_CST)
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not yet supported for non-constant "
-		 "step");
+	dump_printf (TDF_TREE,
+                     "versioning not yet supported for non-constant "
+                     "step");
       return false;
     }
 
@@ -604,11 +608,11 @@ vect_analyze_data_ref_dependence (struct data_depe
         {
           if (vect_print_dump_info (REPORT_DR_DETAILS))
             {
-              fprintf (vect_dump, "versioning for alias required: "
+              dump_printf (TDF_TREE, "versioning for alias required: "
                                   "can't determine dependence between ");
-              print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-              fprintf (vect_dump, " and ");
-              print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+              dump_generic_expr (TDF_SLIM, DR_REF (dra));
+              dump_printf (TDF_TREE, " and ");
+              dump_generic_expr (TDF_SLIM, DR_REF (drb));
             }
 
           /* Add to list of ddrs that need to be tested at run-time.  */
@@ -627,10 +631,10 @@ vect_analyze_data_ref_dependence (struct data_depe
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "can't determine dependence between ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          dump_printf (TDF_TREE, "can't determine dependence between ");
+          dump_generic_expr (TDF_SLIM, DR_REF (dra));
+          dump_printf (TDF_TREE, " and ");
+          dump_generic_expr (TDF_SLIM, DR_REF (drb));
         }
 
       /* We do not vectorize basic blocks with write-write dependencies.  */
@@ -655,17 +659,17 @@ vect_analyze_data_ref_dependence (struct data_depe
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "determined dependence between ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          dump_printf (TDF_TREE, "determined dependence between ");
+          dump_generic_expr (TDF_SLIM, DR_REF (dra));
+          dump_printf (TDF_TREE, " and ");
+          dump_generic_expr (TDF_SLIM, DR_REF (drb));
         }
 
       /* Do not vectorize basic blcoks with write-write dependences.  */
       if (DR_IS_WRITE (dra) && DR_IS_WRITE (drb))
         return true;
 
-      /* Check if this dependence is allowed in basic block vectorization.  */ 
+      /* Check if this dependence is allowed in basic block vectorization.  */
       return vect_drs_dependent_in_basic_block (dra, drb);
     }
 
@@ -674,10 +678,11 @@ vect_analyze_data_ref_dependence (struct data_depe
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "versioning for alias required: bad dist vector for ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          dump_printf (TDF_TREE,
+                       "versioning for alias required: bad dist vector for ");
+          dump_generic_expr (TDF_SLIM, DR_REF (dra));
+          dump_printf (TDF_TREE, " and ");
+          dump_generic_expr (TDF_SLIM, DR_REF (drb));
         }
       /* Add to list of ddrs that need to be tested at run-time.  */
       return !vect_mark_for_runtime_alias_test (ddr, loop_vinfo);
@@ -689,16 +694,16 @@ vect_analyze_data_ref_dependence (struct data_depe
       int dist = dist_v[loop_depth];
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "dependence distance  = %d.", dist);
+	dump_printf (TDF_TREE, "dependence distance  = %d.", dist);
 
       if (dist == 0)
 	{
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "dependence distance == 0 between ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf (TDF_TREE, "dependence distance == 0 between ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (dra));
+	      dump_printf (TDF_TREE, " and ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 
           /* For interleaving, mark that there is a read-write dependency if
@@ -720,7 +725,7 @@ vect_analyze_data_ref_dependence (struct data_depe
 	     reversed (to make distance vector positive), and the actual
 	     distance is negative.  */
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "dependence distance negative.");
+	    dump_printf (TDF_TREE, "dependence distance negative.");
 	  continue;
 	}
 
@@ -731,8 +736,9 @@ vect_analyze_data_ref_dependence (struct data_depe
 	     vectorization factor.  */
 	  *max_vf = abs (dist);
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "adjusting maximal vectorization factor to %i",
-		     *max_vf);
+	    dump_printf (TDF_TREE,
+                         "adjusting maximal vectorization factor to %i",
+                         *max_vf);
 	}
 
       if (abs (dist) >= *max_vf)
@@ -740,17 +746,17 @@ vect_analyze_data_ref_dependence (struct data_depe
 	  /* Dependence distance does not create dependence, as far as
 	     vectorization is concerned, in this case.  */
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "dependence distance >= VF.");
+	    dump_printf (TDF_TREE, "dependence distance >= VF.");
 	  continue;
 	}
 
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 	{
-	  fprintf (vect_dump, "not vectorized, possible dependence "
-    		              "between data-refs ");
-	  print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	  fprintf (vect_dump, " and ");
-	  print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	  dump_printf (TDF_TREE, "not vectorized, possible dependence "
+                       "between data-refs ");
+	  dump_generic_expr (TDF_SLIM, DR_REF (dra));
+	  dump_printf (TDF_TREE, " and ");
+	  dump_generic_expr (TDF_SLIM, DR_REF (drb));
 	}
 
       return true;
@@ -774,7 +780,7 @@ vect_analyze_data_ref_dependences (loop_vec_info l
   struct data_dependence_relation *ddr;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_dependences ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_dependences ===");
 
   if (loop_vinfo)
     ddrs = LOOP_VINFO_DDRS (loop_vinfo);
@@ -816,7 +822,7 @@ vect_compute_data_ref_alignment (struct data_refer
   tree aligned_to, alignment;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_compute_data_ref_alignment:");
+    dump_printf (TDF_TREE, "vect_compute_data_ref_alignment:");
 
   if (loop_vinfo)
     loop = LOOP_VINFO_LOOP (loop_vinfo);
@@ -848,7 +854,7 @@ vect_compute_data_ref_alignment (struct data_refer
       if (dr_step % GET_MODE_SIZE (TYPE_MODE (vectype)) == 0)
         {
           if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "inner step divides the vector-size.");
+            dump_printf (TDF_TREE, "inner step divides the vector-size.");
 	  misalign = STMT_VINFO_DR_INIT (stmt_info);
 	  aligned_to = STMT_VINFO_DR_ALIGNED_TO (stmt_info);
 	  base_addr = STMT_VINFO_DR_BASE_ADDRESS (stmt_info);
@@ -856,7 +862,8 @@ vect_compute_data_ref_alignment (struct data_refer
       else
 	{
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "inner step doesn't divide the vector-size.");
+	    dump_printf (TDF_TREE,
+                         "inner step doesn't divide the vector-size.");
 	  misalign = NULL_TREE;
 	}
     }
@@ -869,8 +876,8 @@ vect_compute_data_ref_alignment (struct data_refer
     {
       if (vect_print_dump_info (REPORT_ALIGNMENT))
 	{
-	  fprintf (vect_dump, "Unknown alignment for access: ");
-	  print_generic_expr (vect_dump, base, TDF_SLIM);
+	  dump_printf (TDF_TREE, "Unknown alignment for access: ");
+	  dump_generic_expr (TDF_SLIM, base);
 	}
       return true;
     }
@@ -898,8 +905,8 @@ vect_compute_data_ref_alignment (struct data_refer
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "can't force alignment of ref: ");
-	      print_generic_expr (vect_dump, ref, TDF_SLIM);
+	      dump_printf (TDF_TREE, "can't force alignment of ref: ");
+	      dump_generic_expr (TDF_SLIM, ref);
 	    }
 	  return true;
 	}
@@ -909,8 +916,8 @@ vect_compute_data_ref_alignment (struct data_refer
 	 the analysis phase, before deciding to vectorize the loop.  */
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "force alignment of ");
-          print_generic_expr (vect_dump, ref, TDF_SLIM);
+          dump_printf (TDF_TREE, "force alignment of ");
+          dump_generic_expr (TDF_SLIM, ref);
         }
 
       DECL_ALIGN (base) = TYPE_ALIGN (vectype);
@@ -942,7 +949,7 @@ vect_compute_data_ref_alignment (struct data_refer
     {
       /* Negative or overflowed misalignment value.  */
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "unexpected misalign value");
+	dump_printf (TDF_TREE, "unexpected misalign value");
       return false;
     }
 
@@ -950,8 +957,9 @@ vect_compute_data_ref_alignment (struct data_refer
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
-      print_generic_expr (vect_dump, ref, TDF_SLIM);
+      dump_printf (TDF_TREE,
+                   "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
+      dump_generic_expr (TDF_SLIM, ref);
     }
 
   return true;
@@ -1048,7 +1056,7 @@ vect_update_misalignment_for_peel (struct data_ref
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "Setting misalignment to -1.");
+    dump_printf (TDF_TREE, "Setting misalignment to -1.");
   SET_DR_MISALIGNMENT (dr, -1);
 }
 
@@ -1094,19 +1102,19 @@ vect_verify_datarefs_alignment (loop_vec_info loop
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
               if (DR_IS_READ (dr))
-                fprintf (vect_dump,
-                         "not vectorized: unsupported unaligned load.");
+                dump_printf (TDF_TREE,
+                             "not vectorized: unsupported unaligned load.");
               else
-                fprintf (vect_dump,
-                         "not vectorized: unsupported unaligned store.");
+                dump_printf (TDF_TREE,
+                             "not vectorized: unsupported unaligned store.");
 
-              print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
+              dump_generic_expr (TDF_SLIM, DR_REF (dr));
             }
           return false;
         }
       if (supportable_dr_alignment != dr_aligned
           && vect_print_dump_info (REPORT_ALIGNMENT))
-        fprintf (vect_dump, "Vectorizing an unaligned access.");
+        dump_printf (TDF_TREE, "Vectorizing an unaligned access.");
     }
   return true;
 }
@@ -1151,13 +1159,16 @@ vector_alignment_reachable_p (struct data_referenc
 		int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
-	  fprintf (vect_dump, ". misalignment = %d. ", DR_MISALIGNMENT (dr));
+	  dump_printf (TDF_TREE,
+                       "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
+	  dump_printf (TDF_TREE,
+                       ". misalignment = %d. ", DR_MISALIGNMENT (dr));
 	}
       if (DR_MISALIGNMENT (dr) % elmsize)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "data size does not divide the misalignment.\n");
+	    dump_printf (TDF_TREE,
+                         "data size does not divide the misalignment.\n");
 	  return false;
 	}
     }
@@ -1171,7 +1182,8 @@ vector_alignment_reachable_p (struct data_referenc
 	is_packed = true;
 
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Unknown misalignment, is_packed = %d",is_packed);
+	dump_printf (TDF_TREE,
+                     "Unknown misalignment, is_packed = %d",is_packed);
       if (targetm.vectorize.vector_alignment_reachable (type, is_packed))
 	return true;
       else
@@ -1208,8 +1220,9 @@ vect_get_data_access_cost (struct data_reference *
     }
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_get_data_access_cost: inside_cost = %d, "
-             "outside_cost = %d.", *inside_cost, *outside_cost);
+    dump_printf (TDF_TREE,
+                 "vect_get_data_access_cost: inside_cost = %d, "
+                 "outside_cost = %d.", *inside_cost, *outside_cost);
 }
 
 
@@ -1480,7 +1493,7 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
   unsigned int nelements, mis, same_align_drs_max = 0;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_enhance_data_refs_alignment ===");
+    dump_printf (TDF_TREE, "=== vect_enhance_data_refs_alignment ===");
 
   /* While cost model enhancements are expected in the future, the high level
      view of the code at this time is as follows:
@@ -1534,7 +1547,7 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
       if (STMT_VINFO_STRIDE_LOAD_P (stmt_info))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "strided load prevents peeling");
+	    dump_printf (TDF_TREE, "strided load prevents peeling");
 	  do_peeling = false;
 	  break;
 	}
@@ -1649,8 +1662,8 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
           if (!aligned_access_p (dr))
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "vector alignment may not be reachable");
-
+                dump_printf (TDF_TREE,
+                             "vector alignment may not be reachable");
               break;
             }
         }
@@ -1786,7 +1799,7 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
 	    npeel /= GROUP_SIZE (stmt_info);
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Try peeling by %d", npeel);
+            dump_printf (TDF_TREE, "Try peeling by %d", npeel);
         }
 
       /* Ensure that all data refs can be vectorized after the peel.  */
@@ -1851,10 +1864,12 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
             LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo) = DR_MISALIGNMENT (dr0);
 	  SET_DR_MISALIGNMENT (dr0, 0);
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "Alignment of access forced using peeling.");
+            dump_printf (TDF_TREE,
+                         "Alignment of access forced using peeling.");
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Peeling for alignment will be applied.");
+            dump_printf (TDF_TREE,
+                         "Peeling for alignment will be applied.");
 
 	  stat = vect_verify_datarefs_alignment (loop_vinfo, NULL);
 	  gcc_assert (stat);
@@ -1960,11 +1975,13 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
           dr = STMT_VINFO_DATA_REF (stmt_info);
 	  SET_DR_MISALIGNMENT (dr, 0);
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "Alignment of access forced using versioning.");
+            dump_printf (TDF_TREE,
+                         "Alignment of access forced using versioning.");
         }
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Versioning for alignment will be applied.");
+        dump_printf (TDF_TREE,
+                     "Versioning for alignment will be applied.");
 
       /* Peeling and versioning can't be done together at this time.  */
       gcc_assert (! (do_peeling && do_versioning));
@@ -2029,7 +2046,7 @@ vect_find_same_alignment_drs (struct data_dependen
       int dist = dist_v[loop_depth];
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "dependence distance  = %d.", dist);
+	dump_printf (TDF_TREE, "dependence distance  = %d.", dist);
 
       /* Same loop iteration.  */
       if (dist == 0
@@ -2039,13 +2056,14 @@ vect_find_same_alignment_drs (struct data_dependen
 	  VEC_safe_push (dr_p, heap, STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_a), drb);
 	  VEC_safe_push (dr_p, heap, STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_b), dra);
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "accesses have the same alignment.");
+	    dump_printf (TDF_TREE, "accesses have the same alignment.");
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "dependence distance modulo vf == 0 between ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf (TDF_TREE,
+                           "dependence distance modulo vf == 0 between ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (dra));
+	      dump_printf (TDF_TREE, " and ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 	}
     }
@@ -2062,7 +2080,7 @@ vect_analyze_data_refs_alignment (loop_vec_info lo
                                   bb_vec_info bb_vinfo)
 {
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_refs_alignment ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_data_refs_alignment ===");
 
   /* Mark groups of data references with same alignment using
      data dependence information.  */
@@ -2079,8 +2097,8 @@ vect_analyze_data_refs_alignment (loop_vec_info lo
   if (!vect_compute_data_refs_alignment (loop_vinfo, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	fprintf (vect_dump,
-		 "not vectorized: can't calculate alignment for data ref.");
+	dump_printf (TDF_TREE,
+                     "not vectorized: can't calculate alignment for data ref.");
       return false;
     }
 
@@ -2132,22 +2150,24 @@ vect_analyze_group_access (struct data_reference *
 	  GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "Detected single element interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
-	      fprintf (vect_dump, " step ");
-	      print_generic_expr (vect_dump, step, TDF_SLIM);
+	      dump_printf (TDF_TREE,
+                           "Detected single element interleaving ");
+	      dump_generic_expr (TDF_SLIM, DR_REF (dr));
+	      dump_printf (TDF_TREE, " step ");
+	      dump_generic_expr (TDF_SLIM, step);
 	    }
 
 	  if (loop_vinfo)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "Data access with gaps requires scalar "
-				    "epilogue loop");
+		dump_printf (TDF_TREE,
+                             "Data access with gaps requires scalar "
+                             "epilogue loop");
               if (loop->inner)
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Peeling for outer loop is not"
-                                        " supported");
+                    dump_printf (TDF_TREE, "Peeling for outer loop is not"
+                                 " supported");
                   return false;
                 }
 
@@ -2159,8 +2179,8 @@ vect_analyze_group_access (struct data_reference *
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
- 	  fprintf (vect_dump, "not consecutive access ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+ 	  dump_printf (TDF_TREE, "not consecutive access ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       if (bb_vinfo)
@@ -2169,7 +2189,7 @@ vect_analyze_group_access (struct data_reference *
           STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) = false;
           return true;
         }
-    
+
       return false;
     }
 
@@ -2197,7 +2217,8 @@ vect_analyze_group_access (struct data_reference *
               if (DR_IS_WRITE (data_ref))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Two store stmts share the same dr.");
+                    dump_printf (TDF_TREE,
+                                 "Two store stmts share the same dr.");
                   return false;
                 }
 
@@ -2207,8 +2228,8 @@ vect_analyze_group_access (struct data_reference *
                   || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump,
-                             "READ_WRITE dependence in interleaving.");
+                    dump_printf (TDF_TREE,
+                                 "READ_WRITE dependence in interleaving.");
                   return false;
                 }
 
@@ -2227,7 +2248,8 @@ vect_analyze_group_access (struct data_reference *
           if (tree_int_cst_compare (step, next_step))
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "not consecutive access in interleaving");
+                dump_printf (TDF_TREE,
+                             "not consecutive access in interleaving");
               return false;
             }
 
@@ -2243,7 +2265,7 @@ vect_analyze_group_access (struct data_reference *
 	      if (DR_IS_WRITE (data_ref))
 		{
 		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "interleaved store with gaps");
+		    dump_printf (TDF_TREE, "interleaved store with gaps");
 		  return false;
 		}
 
@@ -2272,8 +2294,9 @@ vect_analyze_group_access (struct data_reference *
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "interleaving size is greater than step for ");
-              print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "interleaving size is greater than step for ");
+              dump_generic_expr (TDF_SLIM, DR_REF (dr));
             }
           return false;
         }
@@ -2293,7 +2316,7 @@ vect_analyze_group_access (struct data_reference *
           else
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "interleaved store with gaps");
+                dump_printf (TDF_TREE, "interleaved store with gaps");
               return false;
             }
         }
@@ -2303,11 +2326,11 @@ vect_analyze_group_access (struct data_reference *
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "step is not a multiple of type size: step ");
-              print_generic_expr (vect_dump, step, TDF_SLIM);
-              fprintf (vect_dump, " size ");
-              print_generic_expr (vect_dump, TYPE_SIZE_UNIT (scalar_type),
-                                  TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "step is not a multiple of type size: step ");
+              dump_generic_expr (TDF_SLIM, step);
+              dump_printf (TDF_TREE, " size ");
+              dump_generic_expr (TDF_SLIM, TYPE_SIZE_UNIT (scalar_type));
             }
           return false;
         }
@@ -2317,7 +2340,8 @@ vect_analyze_group_access (struct data_reference *
 
       GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Detected interleaving of size %d", (int)groupsize);
+        dump_printf (TDF_TREE,
+                     "Detected interleaving of size %d", (int)groupsize);
 
       /* SLP: create an SLP data structure for every interleaving group of
 	 stores for further analysis in vect_analyse_slp.  */
@@ -2335,12 +2359,13 @@ vect_analyze_group_access (struct data_reference *
       if (groupsize - last_accessed_element > 0 && loop_vinfo)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "Data access with gaps requires scalar "
-				"epilogue loop");
+	    dump_printf (TDF_TREE, "Data access with gaps requires scalar "
+                         "epilogue loop");
           if (loop->inner)
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Peeling for outer loop is not supported");
+                dump_printf (TDF_TREE,
+                             "Peeling for outer loop is not supported");
               return false;
             }
 
@@ -2372,7 +2397,7 @@ vect_analyze_data_ref_access (struct data_referenc
   if (loop_vinfo && !step)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data-ref access in loop");
+	dump_printf (TDF_TREE, "bad data-ref access in loop");
       return false;
     }
 
@@ -2394,7 +2419,7 @@ vect_analyze_data_ref_access (struct data_referenc
       if (integer_zerop (step))
 	{
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "zero step in outer loop.");
+	    dump_printf (TDF_TREE, "zero step in outer loop.");
 	  if (DR_IS_READ (dr))
   	    return true;
 	  else
@@ -2419,7 +2444,7 @@ vect_analyze_data_ref_access (struct data_referenc
   if (loop && nested_in_vect_loop_p (loop, stmt))
     {
       if (vect_print_dump_info (REPORT_ALIGNMENT))
-	fprintf (vect_dump, "grouped access in outer loop.");
+	dump_printf (TDF_TREE, "grouped access in outer loop.");
       return false;
     }
 
@@ -2449,7 +2474,7 @@ vect_analyze_data_ref_accesses (loop_vec_info loop
   struct data_reference *dr;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_ref_accesses ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_data_ref_accesses ===");
 
   if (loop_vinfo)
     datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
@@ -2461,7 +2486,8 @@ vect_analyze_data_ref_accesses (loop_vec_info loop
         && !vect_analyze_data_ref_access (dr))
       {
 	if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	  fprintf (vect_dump, "not vectorized: complicated access pattern.");
+	  dump_printf (TDF_TREE,
+                       "not vectorized: complicated access pattern.");
 
         if (bb_vinfo)
           {
@@ -2490,7 +2516,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info
   unsigned i, j;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_prune_runtime_alias_test_list ===");
+    dump_printf (TDF_TREE, "=== vect_prune_runtime_alias_test_list ===");
 
   for (i = 0; i < VEC_length (ddr_p, ddrs); )
     {
@@ -2508,14 +2534,14 @@ vect_prune_runtime_alias_test_list (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_DR_DETAILS))
 		{
-		  fprintf (vect_dump, "found equal ranges ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr_i)), TDF_SLIM);
-		  fprintf (vect_dump, ", ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr_i)), TDF_SLIM);
-		  fprintf (vect_dump, " and ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr_j)), TDF_SLIM);
-		  fprintf (vect_dump, ", ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr_j)), TDF_SLIM);
+		  dump_printf (TDF_TREE, "found equal ranges ");
+		  dump_generic_expr (TDF_SLIM, DR_REF (DDR_A (ddr_i)));
+		  dump_printf (TDF_TREE, ", ");
+		  dump_generic_expr (TDF_SLIM, DR_REF (DDR_B (ddr_i)));
+		  dump_printf (TDF_TREE, " and ");
+		  dump_generic_expr (TDF_SLIM, DR_REF (DDR_A (ddr_j)));
+		  dump_printf (TDF_TREE, ", ");
+		  dump_generic_expr (TDF_SLIM, DR_REF (DDR_B (ddr_j)));
 		}
 	      found = true;
 	      break;
@@ -2535,9 +2561,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
 	{
-	  fprintf (vect_dump,
-		   "disable versioning for alias - max number of generated "
-		   "checks exceeded.");
+	  dump_printf (TDF_TREE,
+                       "disable versioning for alias - max number of generated "
+                       "checks exceeded.");
 	}
 
       VEC_truncate (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), 0);
@@ -2821,7 +2847,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
   bool res, stop_bb_analysis = false;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_refs ===\n");
+    dump_printf (TDF_TREE, "=== vect_analyze_data_refs ===\n");
 
   if (loop_vinfo)
     {
@@ -2835,8 +2861,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (!res)
 	{
 	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: loop contains function calls"
-		     " or data references that cannot be analyzed");
+	    dump_printf (TDF_TREE,
+                         "not vectorized: loop contains function calls"
+                         " or data references that cannot be analyzed");
 	  return false;
 	}
 
@@ -2851,8 +2878,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (!res)
 	{
 	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: basic block contains function"
-		     " calls or data references that cannot be analyzed");
+	    dump_printf (TDF_TREE,
+                         "not vectorized: basic block contains function"
+                         " calls or data references that cannot be analyzed");
 	  return false;
 	}
 
@@ -2873,7 +2901,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (!dr || !DR_REF (dr))
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: unhandled data-ref ");
+	    dump_printf (TDF_TREE, "not vectorized: unhandled data-ref ");
 
           return false;
         }
@@ -2920,9 +2948,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump, "not vectorized: data ref analysis "
-				      "failed ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE, "not vectorized: data ref analysis "
+                               "failed ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      if (bb_vinfo)
@@ -2939,8 +2967,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (TREE_CODE (DR_BASE_ADDRESS (dr)) == INTEGER_CST)
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump, "not vectorized: base addr of dr is a "
-                     "constant");
+            dump_printf (TDF_TREE, "not vectorized: base addr of dr is a "
+                         "constant");
 
           if (bb_vinfo)
             {
@@ -2958,8 +2986,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump, "not vectorized: volatile type ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE, "not vectorized: volatile type ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -2976,9 +3004,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump, "not vectorized: statement can throw an "
-                       "exception ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "not vectorized: statement can throw an "
+                           "exception ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -2998,9 +3027,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	{
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump, "not vectorized: statement is bitfield "
-                       "access ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE, "not vectorized: statement is bitfield "
+                           "access ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -3023,8 +3052,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	{
 	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 	    {
-	      fprintf (vect_dump, "not vectorized: dr in a call ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "not vectorized: dr in a call ");
+	      dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  if (bb_vinfo)
@@ -3065,8 +3094,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "analyze in outer-loop: ");
-	      print_generic_expr (vect_dump, inner_base, TDF_SLIM);
+	      dump_printf (TDF_TREE, "analyze in outer-loop: ");
+	      dump_generic_expr (TDF_SLIM, inner_base);
 	    }
 
 	  outer_base = get_inner_reference (inner_base, &pbitsize, &pbitpos,
@@ -3076,7 +3105,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	  if (pbitpos % BITS_PER_UNIT != 0)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "failed: bit offset alignment.\n");
+		dump_printf (TDF_TREE, "failed: bit offset alignment.\n");
 	      return false;
 	    }
 
@@ -3085,7 +3114,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
                           &base_iv, false))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "failed: evolution of base is not affine.\n");
+		dump_printf (TDF_TREE,
+                             "failed: evolution of base is not affine.\n");
 	      return false;
 	    }
 
@@ -3107,7 +3137,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
                                &offset_iv, false))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-	        fprintf (vect_dump, "evolution of offset is not affine.\n");
+	        dump_printf (TDF_TREE,
+                             "evolution of offset is not affine.\n");
 	      return false;
 	    }
 
@@ -3132,16 +3163,17 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "\touter base_address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_BASE_ADDRESS (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter offset from base address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_OFFSET (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter constant offset from base address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_INIT (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter step: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_STEP (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter aligned to: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_ALIGNED_TO (stmt_info), TDF_SLIM);
+	      dump_printf (TDF_TREE, "\touter base_address: ");
+	      dump_generic_expr (TDF_SLIM, STMT_VINFO_DR_BASE_ADDRESS (stmt_info));
+	      dump_printf (TDF_TREE, "\n\touter offset from base address: ");
+	      dump_generic_expr (TDF_SLIM, STMT_VINFO_DR_OFFSET (stmt_info));
+	      dump_printf (TDF_TREE,
+                           "\n\touter constant offset from base address: ");
+	      dump_generic_expr (TDF_SLIM, STMT_VINFO_DR_INIT (stmt_info));
+	      dump_printf (TDF_TREE, "\n\touter step: ");
+	      dump_generic_expr (TDF_SLIM, STMT_VINFO_DR_STEP (stmt_info));
+	      dump_printf (TDF_TREE, "\n\touter aligned to: ");
+	      dump_generic_expr (TDF_SLIM, STMT_VINFO_DR_ALIGNED_TO (stmt_info));
 	    }
 	}
 
@@ -3149,9 +3181,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump,
-                       "not vectorized: more than one data ref in stmt: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "not vectorized: more than one data ref in stmt: ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -3176,11 +3208,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump,
-                       "not vectorized: no vectype for stmt: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
-              fprintf (vect_dump, " scalar_type: ");
-              print_generic_expr (vect_dump, scalar_type, TDF_DETAILS);
+              dump_printf (TDF_TREE,
+                           "not vectorized: no vectype for stmt: ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
+              dump_printf (TDF_TREE, " scalar_type: ");
+              if (dump_flags & TDF_DETAILS)
+                dump_generic_expr (TDF_DETAILS, scalar_type);
             }
 
           if (bb_vinfo)
@@ -3224,9 +3257,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: not suitable for gather load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "not vectorized: not suitable for gather load ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3276,10 +3309,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: data dependence conflict"
-			   " prevents gather load");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "not vectorized: data dependence conflict"
+                               " prevents gather load");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3297,9 +3330,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: not suitable for strided load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "not vectorized: not suitable for strided "
+                               "load ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3492,8 +3526,8 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "created ");
-      print_generic_expr (vect_dump, vec_stmt, TDF_SLIM);
+      dump_printf (TDF_TREE, "created ");
+      dump_generic_expr (TDF_SLIM, vec_stmt);
     }
 
   return vec_stmt;
@@ -3615,17 +3649,17 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_t
   if (vect_print_dump_info (REPORT_DETAILS))
     {
       tree data_ref_base = base_name;
-      fprintf (vect_dump, "create %s-pointer variable to type: ",
+      dump_printf (TDF_TREE, "create %s-pointer variable to type: ",
 	       tree_code_name[(int) TREE_CODE (aggr_type)]);
-      print_generic_expr (vect_dump, aggr_type, TDF_SLIM);
+      dump_generic_expr (TDF_SLIM, aggr_type);
       if (TREE_CODE (data_ref_base) == VAR_DECL
           || TREE_CODE (data_ref_base) == ARRAY_REF)
-        fprintf (vect_dump, "  vectorizing an array ref: ");
+        dump_printf (TDF_TREE, "  vectorizing an array ref: ");
       else if (TREE_CODE (data_ref_base) == COMPONENT_REF)
-        fprintf (vect_dump, "  vectorizing a record based array ref: ");
+        dump_printf (TDF_TREE, "  vectorizing a record based array ref: ");
       else if (TREE_CODE (data_ref_base) == SSA_NAME)
-        fprintf (vect_dump, "  vectorizing a pointer ref: ");
-      print_generic_expr (vect_dump, base_name, TDF_SLIM);
+        dump_printf (TDF_TREE, "  vectorizing a pointer ref: ");
+      dump_generic_expr (TDF_SLIM, base_name);
     }
 
   /* (1) Create the new aggregate-pointer variable.  */
@@ -3947,8 +3981,8 @@ vect_grouped_store_supported (tree vectype, unsign
   if (exact_log2 (count) == -1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "the size of the group of accesses"
-		 " is not a power of 2");
+	dump_printf (TDF_TREE, "the size of the group of accesses"
+                     " is not a power of 2");
       return false;
     }
 
@@ -3972,7 +4006,7 @@ vect_grouped_store_supported (tree vectype, unsign
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "interleave op not supported by target.");
+    dump_printf (TDF_TREE, "interleave op not supported by target.");
   return false;
 }
 
@@ -4397,8 +4431,8 @@ vect_grouped_load_supported (tree vectype, unsigne
   if (exact_log2 (count) == -1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "the size of the group of accesses"
-		 " is not a power of 2");
+	dump_printf (TDF_TREE, "the size of the group of accesses"
+                     " is not a power of 2");
       return false;
     }
 
@@ -4420,7 +4454,7 @@ vect_grouped_load_supported (tree vectype, unsigne
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "extract even/odd not supported by target");
+    dump_printf (TDF_TREE, "extract even/odd not supported by target");
   return false;
 }
 
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c	(revision 188212)
+++ tree-vect-patterns.c	(working copy)
@@ -422,8 +422,8 @@ vect_recog_dot_prod_pattern (VEC (gimple, heap) **
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_recog_dot_prod_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "vect_recog_dot_prod_pattern: detected: ");
+      dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   /* We don't allow changing the order of the computation in the inner-loop
@@ -683,7 +683,7 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap)
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_widen_mult_pattern: detected: ");
+    dump_printf (TDF_TREE, "vect_recog_widen_mult_pattern: detected: ");
 
   /* Check target support  */
   vectype = get_vectype_for_scalar_type (half_type0);
@@ -705,7 +705,7 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap)
 					       oprnd1);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -919,8 +919,8 @@ vect_recog_widen_sum_pattern (VEC (gimple, heap) *
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_recog_widen_sum_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "vect_recog_widen_sum_pattern: detected: ");
+      dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   /* We don't allow changing the order of the computation in the inner-loop
@@ -1222,8 +1222,8 @@ vect_recog_over_widening_pattern (VEC (gimple, hea
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "created pattern stmt: ");
-          print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "created pattern stmt: ");
+          dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
         }
 
       type = gimple_expr_type (stmt);
@@ -1291,8 +1291,8 @@ vect_recog_over_widening_pattern (VEC (gimple, hea
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_recog_over_widening_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "vect_recog_over_widening_pattern: detected: ");
+      dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   return pattern_stmt;
@@ -1426,7 +1426,7 @@ vect_recog_widen_shift_pattern (VEC (gimple, heap)
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_widen_shift_pattern: detected: ");
+    dump_printf (TDF_TREE, "vect_recog_widen_shift_pattern: detected: ");
 
   /* Check target support.  */
   vectype = get_vectype_for_scalar_type (half_type0);
@@ -1450,7 +1450,7 @@ vect_recog_widen_shift_pattern (VEC (gimple, heap)
     gimple_build_assign_with_ops (WIDEN_LSHIFT_EXPR, var, oprnd0, oprnd1);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -1572,14 +1572,15 @@ vect_recog_vector_vector_shift_pattern (VEC (gimpl
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_vector_vector_shift_pattern: detected: ");
+    dump_printf (TDF_TREE,
+                 "vect_recog_vector_vector_shift_pattern: detected: ");
 
   /* Pattern supported.  Create a stmt to be used to replace the pattern.  */
   var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL);
   pattern_stmt = gimple_build_assign_with_ops (rhs_code, var, oprnd0, def);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -1682,7 +1683,7 @@ vect_recog_sdivmod_pow2_pattern (VEC (gimple, heap
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_sdivmod_pow2_pattern: detected: ");
+    dump_printf (TDF_TREE, "vect_recog_sdivmod_pow2_pattern: detected: ");
 
   cond = build2 (LT_EXPR, boolean_type_node, oprnd0, build_int_cst (itype, 0));
   if (rhs_code == TRUNC_DIV_EXPR)
@@ -1779,7 +1780,7 @@ vect_recog_sdivmod_pow2_pattern (VEC (gimple, heap
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
 
@@ -1943,7 +1944,7 @@ vect_recog_mixed_size_cond_pattern (VEC (gimple, h
   *type_out = vectype;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_mixed_size_cond_pattern: detected: ");
+    dump_printf (TDF_TREE, "vect_recog_mixed_size_cond_pattern: detected: ");
 
   return pattern_stmt;
 }
@@ -2335,7 +2336,7 @@ vect_recog_bool_pattern (VEC (gimple, heap) **stmt
       *type_in = vectype;
       VEC_safe_push (gimple, heap, *stmts, last_stmt);
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_bool_pattern: detected: ");
+	dump_printf (TDF_TREE, "vect_recog_bool_pattern: detected: ");
 
       return pattern_stmt;
     }
@@ -2380,7 +2381,7 @@ vect_recog_bool_pattern (VEC (gimple, heap) **stmt
       *type_in = vectype;
       VEC_safe_push (gimple, heap, *stmts, last_stmt);
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_bool_pattern: detected: ");
+	dump_printf (TDF_TREE, "vect_recog_bool_pattern: detected: ");
       return pattern_stmt;
     }
   else
@@ -2530,8 +2531,8 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
   /* Found a vectorizable pattern.  */
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "pattern recognized: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "pattern recognized: ");
+      dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   /* Mark the stmts that are involved in the pattern. */
@@ -2555,8 +2556,8 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
       pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "additional pattern stmt: ");
-          print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "additional pattern stmt: ");
+          dump_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
         }
 
       vect_mark_pattern_stmts (stmt, pattern_stmt, NULL_TREE);
@@ -2654,7 +2655,7 @@ vect_pattern_recog (loop_vec_info loop_vinfo, bb_v
   gimple stmt;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_pattern_recog ===");
+    dump_printf (TDF_TREE, "=== vect_pattern_recog ===");
 
   if (loop_vinfo)
     {
Index: rtl.h
===================================================================
--- rtl.h	(revision 188212)
+++ rtl.h	(working copy)
@@ -2456,8 +2456,8 @@ extern bool validate_subreg (enum machine_mode, en
 /* In combine.c  */
 extern unsigned int extended_count (const_rtx, enum machine_mode, int);
 extern rtx remove_death (unsigned int, rtx);
-extern void dump_combine_stats (FILE *);
-extern void dump_combine_total_stats (FILE *);
+extern void print_combine_stats (FILE *);
+extern void print_combine_total_stats (FILE *);
 
 /* In cfgcleanup.c  */
 extern void delete_dead_jumptables (void);
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c	(revision 188212)
+++ tree-vect-stmts.c	(working copy)
@@ -129,7 +129,7 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
   gimple pattern_stmt;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "mark relevant %d, live %d.", relevant, live_p);
+    dump_printf (TDF_TREE, "mark relevant %d, live %d.", relevant, live_p);
 
   /* If this stmt is an original stmt in a pattern, we might need to mark its
      related pattern stmt instead of the original stmt.  However, such stmts
@@ -184,7 +184,7 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
           pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "last stmt in pattern. don't mark"
+            dump_printf (TDF_TREE, "last stmt in pattern. don't mark"
                                 " relevant/live.");
           stmt_info = vinfo_for_stmt (pattern_stmt);
           gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == stmt);
@@ -202,7 +202,7 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
       && STMT_VINFO_LIVE_P (stmt_info) == save_live_p)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "already marked relevant/live.");
+        dump_printf (TDF_TREE, "already marked relevant/live.");
       return;
     }
 
@@ -246,7 +246,7 @@ vect_stmt_relevant_p (gimple stmt, loop_vec_info l
     if (gimple_vdef (stmt))
       {
 	if (vect_print_dump_info (REPORT_DETAILS))
-	  fprintf (vect_dump, "vec_stmt_relevant_p: stmt has vdefs.");
+	  dump_printf (TDF_TREE, "vec_stmt_relevant_p: stmt has vdefs.");
 	*relevant = vect_used_in_scope;
       }
 
@@ -259,7 +259,8 @@ vect_stmt_relevant_p (gimple stmt, loop_vec_info l
 	  if (!flow_bb_inside_loop_p (loop, bb))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "vec_stmt_relevant_p: used out of loop.");
+		dump_printf (TDF_TREE,
+                             "vec_stmt_relevant_p: used out of loop.");
 
 	      if (is_gimple_debug (USE_STMT (use_p)))
 		continue;
@@ -371,7 +372,7 @@ process_use (gimple stmt, tree use, loop_vec_info
   if (!vect_is_simple_use (use, stmt, loop_vinfo, NULL, &def_stmt, &def, &dt))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported use in stmt.");
+        dump_printf (TDF_TREE, "not vectorized: unsupported use in stmt.");
       return false;
     }
 
@@ -382,7 +383,7 @@ process_use (gimple stmt, tree use, loop_vec_info
   if (!flow_bb_inside_loop_p (loop, def_bb))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "def_stmt is out of loop.");
+	dump_printf (TDF_TREE, "def_stmt is out of loop.");
       return true;
     }
 
@@ -400,7 +401,8 @@ process_use (gimple stmt, tree use, loop_vec_info
       && bb->loop_father == def_bb->loop_father)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "reduc-stmt defining reduc-phi in the same nest.");
+	dump_printf (TDF_TREE,
+                     "reduc-stmt defining reduc-phi in the same nest.");
       if (STMT_VINFO_IN_PATTERN_P (dstmt_vinfo))
 	dstmt_vinfo = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (dstmt_vinfo));
       gcc_assert (STMT_VINFO_RELEVANT (dstmt_vinfo) < vect_used_by_reduction);
@@ -419,7 +421,8 @@ process_use (gimple stmt, tree use, loop_vec_info
   if (flow_loop_nested_p (def_bb->loop_father, bb->loop_father))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "outer-loop def-stmt defining inner-loop stmt.");
+	dump_printf (TDF_TREE,
+                     "outer-loop def-stmt defining inner-loop stmt.");
 
       switch (relevant)
 	{
@@ -456,7 +459,8 @@ process_use (gimple stmt, tree use, loop_vec_info
   else if (flow_loop_nested_p (bb->loop_father, def_bb->loop_father))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "inner-loop def-stmt defining outer-loop stmt.");
+	dump_printf (TDF_TREE,
+                     "inner-loop def-stmt defining outer-loop stmt.");
 
       switch (relevant)
         {
@@ -519,7 +523,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
   enum vect_def_type def_type;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_mark_stmts_to_be_vectorized ===");
+    dump_printf (TDF_TREE, "=== vect_mark_stmts_to_be_vectorized ===");
 
   worklist = VEC_alloc (gimple, heap, 64);
 
@@ -532,8 +536,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
 	  phi = gsi_stmt (si);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "init: phi relevant? ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "init: phi relevant? ");
+	      dump_gimple_stmt (TDF_SLIM, phi, 0);
 	    }
 
 	  if (vect_stmt_relevant_p (phi, loop_vinfo, &relevant, &live_p))
@@ -544,8 +548,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
 	  stmt = gsi_stmt (si);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "init: stmt relevant? ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE, "init: stmt relevant? ");
+	      dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  if (vect_stmt_relevant_p (stmt, loop_vinfo, &relevant, &live_p))
@@ -562,8 +566,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
       stmt = VEC_pop (gimple, worklist);
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-          fprintf (vect_dump, "worklist: examine stmt: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "worklist: examine stmt: ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	}
 
       /* Examine the USEs of STMT. For each USE, mark the stmt that defines it
@@ -606,7 +610,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
 
 	        default:
 	          if (vect_print_dump_info (REPORT_DETAILS))
-	            fprintf (vect_dump, "unsupported use of reduction.");
+	            dump_printf (TDF_TREE, "unsupported use of reduction.");
 
   	          VEC_free (gimple, heap, worklist);
 	          return false;
@@ -621,7 +625,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
                 && tmp_relevant != vect_used_in_outer)
               {
                 if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported use of nested cycle.");
+                  dump_printf (TDF_TREE, "unsupported use of nested cycle.");
 
                 VEC_free (gimple, heap, worklist);
                 return false;
@@ -635,7 +639,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
                 && tmp_relevant != vect_used_by_reduction)
               {
                 if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported use of double reduction.");
+                  dump_printf (TDF_TREE,
+                               "unsupported use of double reduction.");
 
                 VEC_free (gimple, heap, worklist);
                 return false;
@@ -796,7 +801,7 @@ vect_model_simple_cost (stmt_vec_info stmt_info, i
     }
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_simple_cost: inside_cost = %d, "
+    dump_printf (TDF_TREE, "vect_model_simple_cost: inside_cost = %d, "
              "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs either in STMT_INFO or SLP_NODE (if exists).  */
@@ -837,8 +842,9 @@ vect_model_promotion_demotion_cost (stmt_vec_info
     }
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_promotion_demotion_cost: inside_cost = %d, "
-             "outside_cost = %d .", inside_cost, outside_cost);
+    dump_printf (TDF_TREE,
+                 "vect_model_promotion_demotion_cost: inside_cost = %d, "
+                 "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs in STMT_INFO.  */
   stmt_vinfo_set_inside_of_loop_cost (stmt_info, NULL, inside_cost);
@@ -919,16 +925,17 @@ vect_model_store_cost (stmt_vec_info stmt_info, in
         * vect_get_stmt_cost (vec_perm);
 
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "vect_model_store_cost: strided group_size = %d .",
-                 group_size);
+        dump_printf (TDF_TREE,
+                     "vect_model_store_cost: strided group_size = %d .",
+                     group_size);
     }
 
   /* Costs of the stores.  */
   vect_get_store_cost (first_dr, ncopies, &inside_cost);
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_store_cost: inside_cost = %d, "
-             "outside_cost = %d .", inside_cost, outside_cost);
+    dump_printf (TDF_TREE, "vect_model_store_cost: inside_cost = %d, "
+                 "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs either in STMT_INFO or SLP_NODE (if exists).  */
   stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
@@ -950,7 +957,7 @@ vect_get_store_cost (struct data_reference *dr, in
         *inside_cost += ncopies * vect_get_stmt_cost (vector_store);
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: aligned.");
+          dump_printf (TDF_TREE, "vect_model_store_cost: aligned.");
 
         break;
       }
@@ -967,8 +974,9 @@ vect_get_store_cost (struct data_reference *dr, in
                                  vectype, DR_MISALIGNMENT (dr));
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: unaligned supported by "
-                   "hardware.");
+          dump_printf (TDF_TREE,
+                       "vect_model_store_cost: unaligned supported by "
+                       "hardware.");
 
         break;
       }
@@ -1024,8 +1032,9 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
 	* vect_get_stmt_cost (vec_perm);
 
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "vect_model_load_cost: strided group_size = %d .",
-                 group_size);
+        dump_printf (TDF_TREE,
+                     "vect_model_load_cost: strided group_size = %d .",
+                     group_size);
     }
 
   /* The loads themselves.  */
@@ -1044,8 +1053,8 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
 			&inside_cost, &outside_cost);
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_load_cost: inside_cost = %d, "
-             "outside_cost = %d .", inside_cost, outside_cost);
+    dump_printf (TDF_TREE, "vect_model_load_cost: inside_cost = %d, "
+                 "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs either in STMT_INFO or SLP_NODE (if exists).  */
   stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
@@ -1068,7 +1077,7 @@ vect_get_load_cost (struct data_reference *dr, int
         *inside_cost += ncopies * vect_get_stmt_cost (vector_load); 
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: aligned.");
+          dump_printf (TDF_TREE, "vect_model_load_cost: aligned.");
 
         break;
       }
@@ -1083,8 +1092,9 @@ vect_get_load_cost (struct data_reference *dr, int
           * targetm.vectorize.builtin_vectorization_cost (unaligned_load,
                                            vectype, DR_MISALIGNMENT (dr));
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unaligned supported by "
-                   "hardware.");
+          dump_printf (TDF_TREE,
+                       "vect_model_load_cost: unaligned supported by "
+                       "hardware.");
 
         break;
       }
@@ -1100,15 +1110,17 @@ vect_get_load_cost (struct data_reference *dr, int
           *inside_cost += vect_get_stmt_cost (vector_stmt);
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: explicit realign");
+          dump_printf (TDF_TREE,
+                       "vect_model_load_cost: explicit realign");
 
         break;
       }
     case dr_explicit_realign_optimized:
       {
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unaligned software "
-                   "pipelined.");
+          dump_printf (TDF_TREE,
+                       "vect_model_load_cost: unaligned software "
+                       "pipelined.");
 
         /* Unaligned software pipeline has a load of an address, an initial
            load, and possibly a mask operation to "prime" the loop.  However,
@@ -1128,8 +1140,8 @@ vect_get_load_cost (struct data_reference *dr, int
 				   + vect_get_stmt_cost (vec_perm));
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump,
-		   "vect_model_load_cost: explicit realign optimized");
+          dump_printf (TDF_TREE,
+                       "vect_model_load_cost: explicit realign optimized");
 
         break;
       }
@@ -1180,8 +1192,8 @@ vect_init_vector_1 (gimple stmt, gimple new_stmt,
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "created new init_stmt: ");
-      print_gimple_stmt (vect_dump, new_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "created new init_stmt: ");
+      dump_gimple_stmt (TDF_SLIM, new_stmt, 0);
     }
 }
 
@@ -1265,8 +1277,8 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_get_vec_def_for_operand: ");
-      print_generic_expr (vect_dump, op, TDF_SLIM);
+      dump_printf (TDF_TREE, "vect_get_vec_def_for_operand: ");
+      dump_generic_expr (TDF_SLIM, op);
     }
 
   is_simple_use = vect_is_simple_use (op, stmt, loop_vinfo, NULL,
@@ -1276,13 +1288,13 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
     {
       if (def)
         {
-          fprintf (vect_dump, "def =  ");
-          print_generic_expr (vect_dump, def, TDF_SLIM);
+          dump_printf (TDF_TREE, "def =  ");
+          dump_generic_expr (TDF_SLIM, def);
         }
       if (def_stmt)
         {
-          fprintf (vect_dump, "  def_stmt =  ");
-	  print_gimple_stmt (vect_dump, def_stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "  def_stmt =  ");
+	  dump_gimple_stmt (TDF_SLIM, def_stmt, 0);
         }
     }
 
@@ -1300,7 +1312,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 
         /* Create 'vect_cst_ = {cst,cst,...,cst}'  */
         if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Create vector_cst. nunits = %d", nunits);
+          dump_printf (TDF_TREE, "Create vector_cst. nunits = %d", nunits);
 
         return vect_init_vector (stmt, op, vector_type, NULL);
       }
@@ -1316,7 +1328,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 
         /* Create 'vec_inv = {inv,inv,..,inv}'  */
         if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Create vector_inv.");
+          dump_printf (TDF_TREE, "Create vector_inv.");
 
         return vect_init_vector (stmt, def, vector_type, NULL);
       }
@@ -1553,8 +1565,8 @@ vect_finish_stmt_generation (gimple stmt, gimple v
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "add new stmt: ");
-      print_gimple_stmt (vect_dump, vec_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "add new stmt: ");
+      dump_gimple_stmt (TDF_SLIM, vec_stmt, 0);
     }
 
   gimple_set_location (vec_stmt, gimple_location (stmt));
@@ -1655,7 +1667,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
 	  && !types_compatible_p (rhs_type, TREE_TYPE (op)))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "argument types differ.");
+	    dump_printf (TDF_TREE, "argument types differ.");
 	  return false;
 	}
       if (!rhs_type)
@@ -1665,7 +1677,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
 				 &def_stmt, &def, &dt[i], &opvectype))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    dump_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
 
@@ -1675,7 +1687,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
 	       && opvectype != vectype_in)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "argument vector types differ.");
+	    dump_printf (TDF_TREE, "argument vector types differ.");
 	  return false;
 	}
     }
@@ -1689,8 +1701,8 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, rhs_type, TDF_SLIM);
+          dump_printf (TDF_TREE, "no vectype for scalar type ");
+          dump_generic_expr (TDF_SLIM, rhs_type);
         }
 
       return false;
@@ -1716,7 +1728,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
   if (fndecl == NULL_TREE)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "function is not vectorizable.");
+	dump_printf (TDF_TREE, "function is not vectorizable.");
 
       return false;
     }
@@ -1738,7 +1750,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_call ===");
+        dump_printf (TDF_TREE, "=== vectorizable_call ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
@@ -1746,7 +1758,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform call.");
+    dump_printf (TDF_TREE, "transform call.");
 
   /* Handle def.  */
   scalar_dest = gimple_call_lhs (stmt);
@@ -2261,8 +2273,8 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 	      != GET_MODE_PRECISION (TYPE_MODE (rhs_type)))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump,
-		 "type conversion to/from bit-precision unsupported.");
+	dump_printf (TDF_TREE,
+                     "type conversion to/from bit-precision unsupported.");
       return false;
     }
 
@@ -2271,7 +2283,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 			     &def_stmt, &def, &dt[0], &vectype_in))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "use not simple.");
+	dump_printf (TDF_TREE, "use not simple.");
       return false;
     }
   if (op_type == binary_op)
@@ -2292,7 +2304,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
       if (!ok)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    dump_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
     }
@@ -2307,8 +2319,8 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
     {
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "no vectype for scalar type ");
-	  print_generic_expr (vect_dump, rhs_type, TDF_SLIM);
+	  dump_printf (TDF_TREE, "no vectype for scalar type ");
+	  dump_generic_expr (TDF_SLIM, rhs_type);
 	}
 
       return false;
@@ -2349,7 +2361,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
       /* FALLTHRU */
     unsupported:
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "conversion not supported by target.");
+	dump_printf (TDF_TREE, "conversion not supported by target.");
       return false;
 
     case WIDEN:
@@ -2449,7 +2461,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
   if (!vec_stmt)		/* transformation not required.  */
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "=== vectorizable_conversion ===");
+	dump_printf (TDF_TREE, "=== vectorizable_conversion ===");
       if (code == FIX_TRUNC_EXPR || code == FLOAT_EXPR)
         {
 	  STMT_VINFO_TYPE (stmt_info) = type_conversion_vec_info_type;
@@ -2471,7 +2483,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 
   /** Transform.  **/
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform conversion. ncopies = %d.", ncopies);
+    dump_printf (TDF_TREE, "transform conversion. ncopies = %d.", ncopies);
 
   if (op_type == binary_op)
     {
@@ -2823,7 +2835,7 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
 			     &def_stmt, &def, &dt[0], &vectype_in))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        dump_printf (TDF_TREE, "use not simple.");
       return false;
     }
 
@@ -2851,8 +2863,8 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
 	   && TYPE_UNSIGNED (TREE_TYPE (op))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "type conversion to/from bit-precision "
-		 "unsupported.");
+        dump_printf (TDF_TREE, "type conversion to/from bit-precision "
+                     "unsupported.");
       return false;
     }
 
@@ -2860,14 +2872,14 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
     {
       STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_assignment ===");
+        dump_printf (TDF_TREE, "=== vectorizable_assignment ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
 
   /** Transform.  **/
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform assignment.");
+    dump_printf (TDF_TREE, "transform assignment.");
 
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3014,7 +3026,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
       != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (scalar_dest))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bit-precision shifts not supported.");
+        dump_printf (TDF_TREE, "bit-precision shifts not supported.");
       return false;
     }
 
@@ -3023,7 +3035,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
                              &def_stmt, &def, &dt[0], &vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        dump_printf (TDF_TREE, "use not simple.");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -3036,8 +3048,8 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, TREE_TYPE (op0), TDF_SLIM);
+          dump_printf (TDF_TREE, "no vectype for scalar type ");
+          dump_generic_expr (TDF_SLIM, TREE_TYPE (op0));
         }
 
       return false;
@@ -3053,7 +3065,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 			     &def, &dt[1], &op1_vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        dump_printf (TDF_TREE, "use not simple.");
       return false;
     }
 
@@ -3097,7 +3109,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   else
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "operand mode requires invariant argument.");
+	dump_printf (TDF_TREE, "operand mode requires invariant argument.");
       return false;
     }
 
@@ -3106,15 +3118,15 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     {
       optab = optab_for_tree_code (code, vectype, optab_vector);
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "vector/vector shift/rotate found.");
+        dump_printf (TDF_TREE, "vector/vector shift/rotate found.");
       if (!op1_vectype)
 	op1_vectype = get_same_sized_vectype (TREE_TYPE (op1), vectype_out);
       if (op1_vectype == NULL_TREE
 	  || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "unusable type for last operand in"
-				" vector/vector shift/rotate.");
+	    dump_printf (TDF_TREE, "unusable type for last operand in"
+                         " vector/vector shift/rotate.");
 	  return false;
 	}
     }
@@ -3127,7 +3139,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
           && optab_handler (optab, TYPE_MODE (vectype)) != CODE_FOR_nothing)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "vector/scalar shift/rotate found.");
+            dump_printf (TDF_TREE, "vector/scalar shift/rotate found.");
         }
       else
         {
@@ -3139,7 +3151,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 	      scalar_shift_arg = false;
 
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "vector/vector shift/rotate found.");
+                dump_printf (TDF_TREE, "vector/vector shift/rotate found.");
 
               /* Unlike the other binary operators, shifts/rotates have
                  the rhs being int, instead of the same type as the lhs,
@@ -3155,8 +3167,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 			 != TYPE_MODE (TREE_TYPE (op1)))
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
-		      fprintf (vect_dump, "unusable type for last operand in"
-					  " vector/vector shift/rotate.");
+		      dump_printf (TDF_TREE,
+                                   "unusable type for last operand in"
+                                   " vector/vector shift/rotate.");
 			return false;
 		    }
 		  if (vec_stmt && !slp_node)
@@ -3174,7 +3187,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (!optab)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "no optab.");
+        dump_printf (TDF_TREE, "no optab.");
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
@@ -3182,14 +3195,14 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (icode == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "op not supported by target.");
+        dump_printf (TDF_TREE, "op not supported by target.");
       /* Check only during analysis.  */
       if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
           || (vf < vect_min_worthwhile_factor (code)
               && !vec_stmt))
         return false;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "proceeding using word mode.");
+        dump_printf (TDF_TREE, "proceeding using word mode.");
     }
 
   /* Worthwhile without SIMD support?  Check only during analysis.  */
@@ -3198,7 +3211,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
       && !vec_stmt)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not worthwhile without SIMD support.");
+        dump_printf (TDF_TREE, "not worthwhile without SIMD support.");
       return false;
     }
 
@@ -3206,7 +3219,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     {
       STMT_VINFO_TYPE (stmt_info) = shift_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_shift ===");
+        dump_printf (TDF_TREE, "=== vectorizable_shift ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
@@ -3214,7 +3227,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform binary/unary operation.");
+    dump_printf (TDF_TREE, "transform binary/unary operation.");
 
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3250,7 +3263,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
               if (!VECTOR_MODE_P (optab_op2_mode))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "operand 1 using scalar mode.");
+                    dump_printf (TDF_TREE, "operand 1 using scalar mode.");
                   vec_oprnd1 = op1;
                   VEC_quick_push (tree, vec_oprnds1, vec_oprnd1);
                   if (slp_node)
@@ -3373,8 +3386,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (op_type != unary_op && op_type != binary_op && op_type != ternary_op)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "num. args = %d (not unary/binary/ternary op).",
-		 op_type);
+	dump_printf (TDF_TREE,
+                     "num. args = %d (not unary/binary/ternary op).",
+                     op_type);
       return false;
     }
 
@@ -3391,7 +3405,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       && code != BIT_AND_EXPR)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bit-precision arithmetic not supported.");
+        dump_printf (TDF_TREE, "bit-precision arithmetic not supported.");
       return false;
     }
 
@@ -3400,7 +3414,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
 			     &def_stmt, &def, &dt[0], &vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        dump_printf (TDF_TREE, "use not simple.");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -3413,8 +3427,8 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, TREE_TYPE (op0), TDF_SLIM);
+          dump_printf (TDF_TREE, "no vectype for scalar type ");
+          dump_generic_expr (TDF_SLIM, TREE_TYPE (op0));
         }
 
       return false;
@@ -3432,7 +3446,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
 			       &def, &dt[1]))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    dump_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
     }
@@ -3443,7 +3457,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
 			       &def, &dt[2]))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    dump_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
     }
@@ -3474,7 +3488,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (!optab)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "no optab.");
+	dump_printf (TDF_TREE, "no optab.");
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
@@ -3482,14 +3496,14 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (icode == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "op not supported by target.");
+	dump_printf (TDF_TREE, "op not supported by target.");
       /* Check only during analysis.  */
       if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
 	  || (vf < vect_min_worthwhile_factor (code)
               && !vec_stmt))
         return false;
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "proceeding using word mode.");
+	dump_printf (TDF_TREE, "proceeding using word mode.");
     }
 
   /* Worthwhile without SIMD support?  Check only during analysis.  */
@@ -3498,7 +3512,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       && !vec_stmt)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "not worthwhile without SIMD support.");
+	dump_printf (TDF_TREE, "not worthwhile without SIMD support.");
       return false;
     }
 
@@ -3506,7 +3520,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
     {
       STMT_VINFO_TYPE (stmt_info) = op_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_operation ===");
+        dump_printf (TDF_TREE, "=== vectorizable_operation ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
@@ -3514,7 +3528,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform binary/unary operation.");
+    dump_printf (TDF_TREE, "transform binary/unary operation.");
 
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3717,7 +3731,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
   if (loop && nested_in_vect_loop_p (loop, stmt) && ncopies > 1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
+        dump_printf (TDF_TREE, "multiple types in nested loop.");
       return false;
     }
 
@@ -3750,7 +3764,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 			   &def, &dt))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        dump_printf (TDF_TREE, "use not simple.");
       return false;
     }
 
@@ -3770,7 +3784,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 			    size_zero_node) < 0)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "negative step for store.");
+        dump_printf (TDF_TREE, "negative step for store.");
       return false;
     }
 
@@ -3800,7 +3814,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 				       &def_stmt, &def, &dt))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "use not simple.");
+                    dump_printf (TDF_TREE, "use not simple.");
                   return false;
                 }
               next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
@@ -3860,7 +3874,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform store. ncopies = %d",ncopies);
+    dump_printf (TDF_TREE, "transform store. ncopies = %d",ncopies);
 
   dr_chain = VEC_alloc (tree, heap, group_size);
   oprnds = VEC_alloc (tree, heap, group_size);
@@ -4247,7 +4261,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
   if (nested_in_vect_loop && ncopies > 1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
+        dump_printf (TDF_TREE, "multiple types in nested loop.");
       return false;
     }
 
@@ -4286,7 +4300,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Aligned load, but unsupported type.");
+	dump_printf (TDF_TREE, "Aligned load, but unsupported type.");
       return false;
     }
 
@@ -4321,7 +4335,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 				 &gather_off_vectype))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "gather index use not simple.");
+	    dump_printf (TDF_TREE, "gather index use not simple.");
 	  return false;
 	}
     }
@@ -4340,7 +4354,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
       if (negative && ncopies > 1)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple types with negative step.");
+	    dump_printf (TDF_TREE, "multiple types with negative step.");
 	  return false;
 	}
 
@@ -4352,13 +4366,15 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 	      && alignment_support_scheme != dr_unaligned_supported)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "negative step but alignment required.");
+		dump_printf (TDF_TREE,
+                             "negative step but alignment required.");
 	      return false;
 	    }
 	  if (!perm_mask_for_reverse (vectype))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "negative step and reversing not supported.");
+		dump_printf (TDF_TREE,
+                             "negative step and reversing not supported.");
 	      return false;
 	    }
 	}
@@ -4372,7 +4388,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform load. ncopies = %d", ncopies);
+    dump_printf (TDF_TREE, "transform load. ncopies = %d", ncopies);
 
   /** Transform.  **/
 
@@ -5179,7 +5195,7 @@ vectorizable_condition (gimple stmt, gimple_stmt_i
   if (STMT_VINFO_LIVE_P (stmt_info))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
+        dump_printf (TDF_TREE, "value used after loop.");
       return false;
     }
 
@@ -5379,14 +5395,14 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "==> examining statement: ");
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "==> examining statement: ");
+      dump_gimple_stmt (TDF_SLIM, stmt, 0);
     }
 
   if (gimple_has_volatile_ops (stmt))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: stmt has volatile operands");
+        dump_printf (TDF_TREE, "not vectorized: stmt has volatile operands");
 
       return false;
     }
@@ -5417,14 +5433,14 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
           stmt_info = vinfo_for_stmt (pattern_stmt);
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "==> examining pattern statement: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE, "==> examining pattern statement: ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
         }
       else
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "irrelevant.");
+            dump_printf (TDF_TREE, "irrelevant.");
 
           return true;
         }
@@ -5437,8 +5453,8 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
       /* Analyze PATTERN_STMT too.  */
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "==> examining pattern statement: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "==> examining pattern statement: ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       if (!vect_analyze_stmt (pattern_stmt, need_to_vectorize, node))
@@ -5459,8 +5475,9 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
 	      /* Analyze def stmt of STMT if it's a pattern stmt.  */
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "==> examining pattern def statement: ");
-		  print_gimple_stmt (vect_dump, pattern_def_stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "==> examining pattern def statement: ");
+		  dump_gimple_stmt (TDF_SLIM, pattern_def_stmt, 0);
 		}
 
 	      if (!vect_analyze_stmt (pattern_def_stmt,
@@ -5497,8 +5514,8 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
       scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "get vectype for scalar type:  ");
-          print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+          dump_printf (TDF_TREE, "get vectype for scalar type:  ");
+          dump_generic_expr (TDF_SLIM, scalar_type);
         }
 
       vectype = get_vectype_for_scalar_type (scalar_type);
@@ -5506,16 +5523,16 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-               fprintf (vect_dump, "not SLPed: unsupported data-type ");
-               print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+               dump_printf (TDF_TREE, "not SLPed: unsupported data-type ");
+               dump_generic_expr (TDF_SLIM, scalar_type);
             }
           return false;
         }
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "vectype:  ");
-          print_generic_expr (vect_dump, vectype, TDF_SLIM);
+          dump_printf (TDF_TREE, "vectype:  ");
+          dump_generic_expr (TDF_SLIM, vectype);
         }
 
       STMT_VINFO_VECTYPE (stmt_info) = vectype;
@@ -5558,9 +5575,9 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
         {
-          fprintf (vect_dump, "not vectorized: relevant stmt not ");
-          fprintf (vect_dump, "supported: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "not vectorized: relevant stmt not ");
+          dump_printf (TDF_TREE, "supported: ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       return false;
@@ -5579,9 +5596,9 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
         {
-          fprintf (vect_dump, "not vectorized: live stmt not ");
-          fprintf (vect_dump, "supported: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "not vectorized: live stmt not ");
+          dump_printf (TDF_TREE, "supported: ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
        return false;
@@ -5677,7 +5694,7 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter
       if (!STMT_VINFO_LIVE_P (stmt_info))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "stmt not supported.");
+	    dump_printf (TDF_TREE, "stmt not supported.");
 	  gcc_unreachable ();
 	}
     }
@@ -5701,7 +5718,8 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter
       gimple exit_phi;
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Record the vdef for outer-loop vectorization.");
+        dump_printf (TDF_TREE,
+                     "Record the vdef for outer-loop vectorization.");
 
       /* Find the relevant loop-exit phi-node, and reord the vec_stmt there
         (to be used when vectorizing outer-loop stmts that use the DEF of
@@ -5935,8 +5953,8 @@ get_vectype_for_scalar_type_and_size (tree scalar_
   vectype = build_vector_type (scalar_type, nunits);
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "get vectype with %d units of type ", nunits);
-      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+      dump_printf (TDF_TREE, "get vectype with %d units of type ", nunits);
+      dump_generic_expr (TDF_SLIM, scalar_type);
     }
 
   if (!vectype)
@@ -5944,15 +5962,15 @@ get_vectype_for_scalar_type_and_size (tree scalar_
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vectype: ");
-      print_generic_expr (vect_dump, vectype, TDF_SLIM);
+      dump_printf (TDF_TREE, "vectype: ");
+      dump_generic_expr (TDF_SLIM, vectype);
     }
 
   if (!VECTOR_MODE_P (TYPE_MODE (vectype))
       && !INTEGRAL_MODE_P (TYPE_MODE (vectype)))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "mode not supported by target.");
+        dump_printf (TDF_TREE, "mode not supported by target.");
       return NULL_TREE;
     }
 
@@ -6023,8 +6041,8 @@ vect_is_simple_use (tree operand, gimple stmt, loo
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_is_simple_use: operand ");
-      print_generic_expr (vect_dump, operand, TDF_SLIM);
+      dump_printf (TDF_TREE, "vect_is_simple_use: operand ");
+      dump_generic_expr (TDF_SLIM, operand);
     }
 
   if (CONSTANT_CLASS_P (operand))
@@ -6043,14 +6061,14 @@ vect_is_simple_use (tree operand, gimple stmt, loo
   if (TREE_CODE (operand) == PAREN_EXPR)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "non-associatable copy.");
+        dump_printf (TDF_TREE, "non-associatable copy.");
       operand = TREE_OPERAND (operand, 0);
     }
 
   if (TREE_CODE (operand) != SSA_NAME)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not ssa-name.");
+        dump_printf (TDF_TREE, "not ssa-name.");
       return false;
     }
 
@@ -6058,14 +6076,14 @@ vect_is_simple_use (tree operand, gimple stmt, loo
   if (*def_stmt == NULL)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "no def_stmt.");
+        dump_printf (TDF_TREE, "no def_stmt.");
       return false;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "def_stmt: ");
-      print_gimple_stmt (vect_dump, *def_stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "def_stmt: ");
+      dump_gimple_stmt (TDF_SLIM, *def_stmt, 0);
     }
 
   /* Empty stmt is expected only in case of a function argument.
@@ -6095,12 +6113,12 @@ vect_is_simple_use (tree operand, gimple stmt, loo
 	  && gimple_code (stmt) != GIMPLE_PHI))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Unsupported pattern.");
+        dump_printf (TDF_TREE, "Unsupported pattern.");
       return false;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "type of def: %d.",*dt);
+    dump_printf (TDF_TREE, "type of def: %d.",*dt);
 
   switch (gimple_code (*def_stmt))
     {
@@ -6119,7 +6137,7 @@ vect_is_simple_use (tree operand, gimple stmt, loo
       /* FALLTHRU */
     default:
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "unsupported defining stmt: ");
+        dump_printf (TDF_TREE, "unsupported defining stmt: ");
       return false;
     }
 
@@ -6260,7 +6278,7 @@ supportable_widening_operation (enum tree_code cod
       && targetm.vectorize.builtin_mul_widen_odd (vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Unordered widening operation detected.");
+        dump_printf (TDF_TREE, "Unordered widening operation detected.");
 
       *code1 = *code2 = CALL_EXPR;
       *decl1 = targetm.vectorize.builtin_mul_widen_even (vectype);
Index: combine.c
===================================================================
--- combine.c	(revision 188212)
+++ combine.c	(working copy)
@@ -13909,7 +13909,7 @@ unmentioned_reg_p (rtx equiv, rtx expr)
 }
 \f
 DEBUG_FUNCTION void
-dump_combine_stats (FILE *file)
+print_combine_stats (FILE *file)
 {
   fprintf
     (file,
@@ -13918,7 +13918,7 @@ DEBUG_FUNCTION void
 }
 
 void
-dump_combine_total_stats (FILE *file)
+print_combine_total_stats (FILE *file)
 {
   fprintf
     (file,
Index: system.h
===================================================================
--- system.h	(revision 188212)
+++ system.h	(working copy)
@@ -669,6 +669,7 @@ extern int vsnprintf(char *, size_t, const char *,
    except, maybe, something to the dump file.  */
 #ifdef BUFSIZ
 extern FILE *dump_file;
+extern FILE *alt_dump_file;
 #endif
 
 /* Redefine abort to report an internal error w/o coredump, and
Index: passes.c
===================================================================
--- passes.c	(revision 188212)
+++ passes.c	(working copy)
@@ -232,20 +232,16 @@ finish_optimization_passes (void)
   timevar_push (TV_DUMP);
   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
     {
-      dump_file = dump_begin (pass_profile.pass.static_pass_number, NULL);
+      dump_start (pass_profile.pass.static_pass_number, NULL);
       end_branch_prob ();
-      if (dump_file)
-	dump_end (pass_profile.pass.static_pass_number, dump_file);
+      dump_finish (pass_profile.pass.static_pass_number);
     }
 
   if (optimize > 0)
     {
-      dump_file = dump_begin (pass_combine.pass.static_pass_number, NULL);
-      if (dump_file)
-	{
-	  dump_combine_total_stats (dump_file);
-          dump_end (pass_combine.pass.static_pass_number, dump_file);
-	}
+      dump_start (pass_profile.pass.static_pass_number, NULL);
+      dump_combine_total_stats (TDF_DETAILS);
+      dump_finish (pass_combine.pass.static_pass_number);
     }
 
   /* Do whatever is necessary to finish printing the graphs.  */
@@ -1218,9 +1214,9 @@ register_pass (struct register_pass_info *pass_inf
       else
         tdi = TDI_rtl_all;
       /* Check if dump-all flag is specified.  */
-      if (get_dump_file_info (tdi)->state)
+      if (get_dump_file_info (tdi)->pstate)
         get_dump_file_info (added_pass_nodes->pass->static_pass_number)
-            ->state = get_dump_file_info (tdi)->state;
+            ->pstate = get_dump_file_info (tdi)->pstate;
       XDELETE (added_pass_nodes);
       added_pass_nodes = next_node;
     }
@@ -1909,7 +1905,7 @@ pass_init_dump_file (struct opt_pass *pass)
     {
       bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
       dump_file_name = get_dump_file_name (pass->static_pass_number);
-      dump_file = dump_begin (pass->static_pass_number, &dump_flags);
+      dump_start (pass->static_pass_number, &dump_flags);
       if (dump_file && current_function_decl)
         dump_function_header (dump_file, current_function_decl, dump_flags);
       return initializing_dump;
@@ -1931,11 +1927,7 @@ pass_fini_dump_file (struct opt_pass *pass)
       dump_file_name = NULL;
     }
 
-  if (dump_file)
-    {
-      dump_end (pass->static_pass_number, dump_file);
-      dump_file = NULL;
-    }
+  dump_finish (pass->static_pass_number);
 }
 
 /* After executing the pass, apply expected changes to the function
Index: tree-vect-slp.c
===================================================================
--- tree-vect-slp.c	(revision 188212)
+++ tree-vect-slp.c	(working copy)
@@ -238,8 +238,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	{
 	  if (vect_print_dump_info (REPORT_SLP))
 	    {
-	      fprintf (vect_dump, "Build SLP failed: can't find def for ");
-	      print_generic_expr (vect_dump, oprnd, TDF_SLIM);
+	      dump_printf (TDF_TREE,
+                           "Build SLP failed: can't find def for ");
+	      dump_generic_expr (TDF_SLIM, oprnd);
 	    }
 
 	  return false;
@@ -262,9 +263,10 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "Build SLP failed: some of the stmts"
-				" are in a pattern, and others are not ");
-		  print_generic_expr (vect_dump, oprnd, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "Build SLP failed: some of the stmts"
+                               " are in a pattern, and others are not ");
+		  dump_generic_expr (TDF_SLIM, oprnd);
 		}
 
 	      return false;
@@ -276,7 +278,7 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
           if (dt == vect_unknown_def_type)
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Unsupported pattern.");
+                dump_printf (TDF_TREE, "Unsupported pattern.");
               return false;
             }
 
@@ -292,7 +294,7 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 
               default:
                 if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported defining stmt: ");
+                  dump_printf (TDF_TREE, "unsupported defining stmt: ");
                 return false;
             }
         }
@@ -355,7 +357,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	      if (number_of_oprnds != 2)
 		{
 		  if (vect_print_dump_info (REPORT_SLP))
-		    fprintf (vect_dump, "Build SLP failed: different types ");
+		    dump_printf (TDF_TREE,
+                                 "Build SLP failed: different types ");
 
 		  return false;
                 }
@@ -382,8 +385,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
                     {
                       if (vect_print_dump_info (REPORT_SLP))
 	                {
-			  fprintf (vect_dump, "Swapping operands of ");
- 		          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+			  dump_printf (TDF_TREE, "Swapping operands of ");
+ 		          dump_gimple_stmt (TDF_SLIM, stmt, 0);
 			}
 
  		      swap_tree_operands (stmt, gimple_assign_rhs1_ptr (stmt),
@@ -392,7 +395,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
                   else
                     {
          	      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: different types ");
+			dump_printf (TDF_TREE,
+                                     "Build SLP failed: different types ");
 
 		      return false;
 		    }
@@ -427,8 +431,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	  /* FORNOW: Not supported.  */
 	  if (vect_print_dump_info (REPORT_SLP))
 	    {
-	      fprintf (vect_dump, "Build SLP failed: illegal type of def ");
-	      print_generic_expr (vect_dump, def, TDF_SLIM);
+	      dump_printf (TDF_TREE,
+                           "Build SLP failed: illegal type of def ");
+	      dump_generic_expr (TDF_SLIM, def);
 	    }
 
 	  return false;
@@ -494,8 +499,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
     {
       if (vect_print_dump_info (REPORT_SLP))
 	{
-	  fprintf (vect_dump, "Build SLP for ");
-	  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	  dump_printf (TDF_TREE, "Build SLP for ");
+	  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	}
 
       /* Fail to vectorize statements marked as unvectorizable.  */
@@ -503,9 +508,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
         {
           if (vect_print_dump_info (REPORT_SLP))
             {
-              fprintf (vect_dump,
-                       "Build SLP failed: unvectorizable statement ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "Build SLP failed: unvectorizable statement ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -517,9 +522,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	{
 	  if (vect_print_dump_info (REPORT_SLP))
 	    {
-	      fprintf (vect_dump,
-		       "Build SLP failed: not GIMPLE_ASSIGN nor GIMPLE_CALL ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf (TDF_TREE,
+                           "Build SLP failed: not GIMPLE_ASSIGN nor "
+                           "GIMPLE_CALL ");
+	      dump_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -533,9 +539,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
         {
           if (vect_print_dump_info (REPORT_SLP))
             {
-              fprintf (vect_dump,
-                       "Build SLP failed: condition is not comparison ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "Build SLP failed: condition is not comparison ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -548,8 +554,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
         {
           if (vect_print_dump_info (REPORT_SLP))
             {
-              fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
-              print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+              dump_printf (TDF_TREE,
+                           "Build SLP failed: unsupported data-type ");
+              dump_generic_expr (TDF_SLIM, scalar_type);
             }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -577,9 +584,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: unsupported call type ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "Build SLP failed: unsupported call type ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -616,7 +623,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		  if (!optab)
 		    {
 		      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: no optab.");
+			dump_printf (TDF_TREE,
+                                     "Build SLP failed: no optab.");
 	  	      vect_free_oprnd_info (&oprnds_info);
 		      return false;
 		    }
@@ -624,8 +632,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		  if (icode == CODE_FOR_nothing)
 		    {
 		      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: "
-				            "op not supported by target.");
+			dump_printf (TDF_TREE,
+                                     "Build SLP failed: "
+                                     "op not supported by target.");
 	  	      vect_free_oprnd_info (&oprnds_info);
 		      return false;
 		    }
@@ -658,9 +667,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: different operation in stmt ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "Build SLP failed: different operation "
+                               "in stmt ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -672,9 +682,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: different shift arguments in ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "Build SLP failed: different shift "
+                               "arguments in ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -692,9 +703,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		{
 		  if (vect_print_dump_info (REPORT_SLP))
 		    {
-		      fprintf (vect_dump,
-			       "Build SLP failed: different calls in ");
-		      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		      dump_printf (TDF_TREE,
+                                   "Build SLP failed: different calls in ");
+		      dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		    }
 
 		  vect_free_oprnd_info (&oprnds_info);
@@ -728,9 +739,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                 {
                   if (vect_print_dump_info (REPORT_SLP))
                     {
-                      fprintf (vect_dump, "Build SLP failed: grouped "
-                                          "loads have gaps ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf (TDF_TREE, "Build SLP failed: grouped "
+                                   "loads have gaps ");
+                      dump_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
 
 	  	  vect_free_oprnd_info (&oprnds_info);
@@ -744,10 +755,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                 {
                   if (vect_print_dump_info (REPORT_SLP))
                     {
-                      fprintf (vect_dump, "Build SLP failed: the number of "
-                                          "interleaved loads is greater than"
-                                          " the SLP group size ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf (TDF_TREE, "Build SLP failed: the number "
+                                   "of interleaved loads is greater than "
+                                   "the SLP group size ");
+                      dump_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
 
 	  	  vect_free_oprnd_info (&oprnds_info);
@@ -761,16 +772,17 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                      chains in the same node.  The only exception is complex
                      numbers.  */
                   if (prev_first_load != first_load
-                      && rhs_code != REALPART_EXPR 
+                      && rhs_code != REALPART_EXPR
                       && rhs_code != IMAGPART_EXPR)
-                    {    
+                    {
                       if (vect_print_dump_info (REPORT_SLP))
                         {
-                          fprintf (vect_dump, "Build SLP failed: different "
-                                           "interleaving chains in one node ");
-                          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                          dump_printf (TDF_TREE,
+                                       "Build SLP failed: different "
+                                       "interleaving chains in one node ");
+                          dump_gimple_stmt (TDF_SLIM, stmt, 0);
                         }
- 
+
 	  	      vect_free_oprnd_info (&oprnds_info);
                       return false;
                     }
@@ -786,9 +798,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                     {
                       if (vect_print_dump_info (REPORT_SLP))
                         {
-                          fprintf (vect_dump, "Build SLP failed: unsupported "
-                                              "unaligned load ");
-                          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                          dump_printf (TDF_TREE,
+                                       "Build SLP failed: unsupported "
+                                       "unaligned load ");
+                          dump_gimple_stmt (TDF_SLIM, stmt, 0);
                         }
 
 	  	      vect_free_oprnd_info (&oprnds_info);
@@ -822,8 +835,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	      /* Not grouped load.  */
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump, "Build SLP failed: not grouped load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE,
+                               "Build SLP failed: not grouped load ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      /* FORNOW: Not grouped loads are not supported.  */
@@ -839,9 +853,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump, "Build SLP failed: operation");
-		  fprintf (vect_dump, " unsupported ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf (TDF_TREE, "Build SLP failed: operation");
+		  dump_printf (TDF_TREE, " unsupported ");
+		  dump_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -858,9 +872,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                 {
                   if (vect_print_dump_info (REPORT_SLP))
                     {
-                      fprintf (vect_dump, "Build SLP failed: different"
-					  " operation");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf (TDF_TREE, "Build SLP failed: different"
+                                   " operation");
+                      dump_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
 
 		  vect_free_oprnd_info (&oprnds_info);
@@ -949,13 +963,13 @@ vect_print_slp_tree (slp_tree node)
   if (!node)
     return;
 
-  fprintf (vect_dump, "node ");
+  dump_printf (TDF_TREE, "node ");
   FOR_EACH_VEC_ELT (gimple, SLP_TREE_SCALAR_STMTS (node), i, stmt)
     {
-      fprintf (vect_dump, "\n\tstmt %d ", i);
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "\n\tstmt %d ", i);
+      dump_gimple_stmt (TDF_SLIM, stmt, 0);
     }
-  fprintf (vect_dump, "\n");
+  dump_printf (TDF_TREE, "\n");
 
   FOR_EACH_VEC_ELT (slp_void_p, SLP_TREE_CHILDREN (node), i, child)
     vect_print_slp_tree ((slp_tree) child);
@@ -1043,9 +1057,9 @@ vect_supported_slp_permutation_p (slp_instance ins
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "Build SLP failed: unsupported data "
-                                   "permutation ");
-              print_gimple_stmt (vect_dump, scalar_stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE, "Build SLP failed: unsupported data "
+                           "permutation ");
+              dump_gimple_stmt (TDF_SLIM, scalar_stmt, 0);
             }
 
           free (tmp_loads);
@@ -1130,9 +1144,9 @@ vect_supported_load_permutation_p (slp_instance sl
 
   if (vect_print_dump_info (REPORT_SLP))
     {
-      fprintf (vect_dump, "Load permutation ");
+      dump_printf (TDF_TREE, "Load permutation ");
       FOR_EACH_VEC_ELT (int, load_permutation, i, next)
-        fprintf (vect_dump, "%d ", next);
+        dump_printf (TDF_TREE, "%d ", next);
     }
 
   /* In case of reduction every load permutation is allowed, since the order
@@ -1337,9 +1351,9 @@ vect_supported_load_permutation_p (slp_instance sl
                     {
    		      if (vect_print_dump_info (REPORT_SLP))
 		        {
-  	                  fprintf (vect_dump, "unsupported unaligned load ");
-                          print_gimple_stmt (vect_dump, first_load, 0,
-					     TDF_SLIM);
+  	                  dump_printf (TDF_TREE,
+                                       "unsupported unaligned load ");
+                          dump_gimple_stmt (TDF_SLIM, first_load, 0);
                         }
   		      bad_permutation = true;
                       break;
@@ -1493,8 +1507,8 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
     {
       if (vect_print_dump_info (REPORT_SLP))
         {
-          fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
-          print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+          dump_printf (TDF_TREE, "Build SLP failed: unsupported data-type ");
+          dump_generic_expr (TDF_SLIM, scalar_type);
         }
 
       return false;
@@ -1511,8 +1525,9 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
   if (unrolling_factor != 1 && !loop_vinfo)
     {
       if (vect_print_dump_info (REPORT_SLP))
-        fprintf (vect_dump, "Build SLP failed: unrolling required in basic"
-                            " block SLP");
+        dump_printf (TDF_TREE,
+                     "Build SLP failed: unrolling required in basic"
+                     " block SLP");
 
       return false;
     }
@@ -1566,8 +1581,9 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
       if (unrolling_factor != 1 && !loop_vinfo)
         {
           if (vect_print_dump_info (REPORT_SLP))
-            fprintf (vect_dump, "Build SLP failed: unrolling required in basic"
-                               " block SLP");
+            dump_printf (TDF_TREE,
+                         "Build SLP failed: unrolling required in basic"
+                         " block SLP");
           return false;
         }
 
@@ -1589,9 +1605,10 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
             {
               if (vect_print_dump_info (REPORT_SLP))
                 {
-                  fprintf (vect_dump, "Build SLP failed: unsupported load "
-                                      "permutation ");
-                  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                  dump_printf (TDF_TREE,
+                               "Build SLP failed: unsupported load "
+                               "permutation ");
+                  dump_gimple_stmt (TDF_SLIM, stmt, 0);
                 }
 
               vect_free_slp_instance (new_instance);
@@ -1640,7 +1657,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec
   bool ok = false;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_analyze_slp ===");
+    dump_printf (TDF_TREE, "=== vect_analyze_slp ===");
 
   if (loop_vinfo)
     {
@@ -1659,7 +1676,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec
   if (bb_vinfo && !ok)
     {
       if (vect_print_dump_info (REPORT_SLP))
-        fprintf (vect_dump, "Failed to SLP the basic block.");
+        dump_printf (TDF_TREE, "Failed to SLP the basic block.");
 
       return false;
     }
@@ -1702,7 +1719,7 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   int decided_to_slp = 0;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_make_slp_decision ===");
+    dump_printf (TDF_TREE, "=== vect_make_slp_decision ===");
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     {
@@ -1720,8 +1737,9 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo) = unrolling_factor;
 
   if (decided_to_slp && vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "Decided to SLP %d instances. Unrolling factor %d",
-	     decided_to_slp, unrolling_factor);
+    dump_printf (TDF_TREE,
+                 "Decided to SLP %d instances. Unrolling factor %d",
+                 decided_to_slp, unrolling_factor);
 
   return (decided_to_slp > 0);
 }
@@ -1784,7 +1802,7 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
   slp_instance instance;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_detect_hybrid_slp ===");
+    dump_printf (TDF_TREE, "=== vect_detect_hybrid_slp ===");
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     vect_detect_hybrid_slp_stmts (SLP_INSTANCE_TREE (instance));
@@ -1963,12 +1981,13 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb
 
   if (vect_print_dump_info (REPORT_COST))
     {
-      fprintf (vect_dump, "Cost model analysis: \n");
-      fprintf (vect_dump, "  Vector inside of basic block cost: %d\n",
+      dump_printf (TDF_TREE, "Cost model analysis: \n");
+      dump_printf (TDF_TREE, "  Vector inside of basic block cost: %d\n",
                vec_inside_cost);
-      fprintf (vect_dump, "  Vector outside of basic block cost: %d\n",
+      dump_printf (TDF_TREE, "  Vector outside of basic block cost: %d\n",
                vec_outside_cost);
-      fprintf (vect_dump, "  Scalar cost of basic block: %d", scalar_cost);
+      dump_printf (TDF_TREE, "  Scalar cost of basic block: %d",
+                   scalar_cost);
     }
 
   /* Vectorization is profitable if its cost is less than the cost of scalar
@@ -1999,8 +2018,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_refs (NULL, bb_vinfo, &min_vf))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unhandled data-ref in basic "
-                            "block.\n");
+        dump_printf (TDF_TREE, "not vectorized: unhandled data-ref in basic "
+                     "block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2010,8 +2029,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!VEC_length (ddr_p, ddrs))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: not enough data-refs in basic "
-                            "block.\n");
+        dump_printf (TDF_TREE, "not vectorized: not enough data-refs in "
+                     "basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2023,8 +2042,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
        || min_vf > max_vf)
      {
        if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	 fprintf (vect_dump, "not vectorized: unhandled data dependence "
-		  "in basic block.\n");
+	 dump_printf (TDF_TREE, "not vectorized: unhandled data dependence "
+                      "in basic block.\n");
 
        destroy_bb_vec_info (bb_vinfo);
        return NULL;
@@ -2033,8 +2052,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_refs_alignment (NULL, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: bad data alignment in basic "
-                            "block.\n");
+        dump_printf (TDF_TREE, "not vectorized: bad data alignment in basic "
+                     "block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2043,8 +2062,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_ref_accesses (NULL, bb_vinfo))
     {
      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-       fprintf (vect_dump, "not vectorized: unhandled data access in basic "
-                           "block.\n");
+       dump_printf (TDF_TREE, "not vectorized: unhandled data access in "
+                    "basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2053,8 +2072,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
    if (!vect_verify_datarefs_alignment (NULL, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported alignment in basic "
-                            "block.\n");
+        dump_printf (TDF_TREE, "not vectorized: unsupported alignment in "
+                     "basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2065,8 +2084,9 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_slp (NULL, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: failed to find SLP opportunities "
-                            "in basic block.\n");
+        dump_printf (TDF_TREE,
+                     "not vectorized: failed to find SLP opportunities "
+                     "in basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2085,7 +2105,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_slp_analyze_operations (bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: bad operation in basic block.\n");
+        dump_printf (TDF_TREE,
+                     "not vectorized: bad operation in basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2096,15 +2117,15 @@ vect_slp_analyze_bb_1 (basic_block bb)
       && !vect_bb_vectorization_profitable_p (bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization is not "
-                            "profitable.\n");
+        dump_printf (TDF_TREE, "not vectorized: vectorization is not "
+                     "profitable.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "Basic block will be vectorized using SLP\n");
+    dump_printf (TDF_TREE, "Basic block will be vectorized using SLP\n");
 
   return bb_vinfo;
 }
@@ -2119,7 +2140,7 @@ vect_slp_analyze_bb (basic_block bb)
   unsigned int vector_sizes;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===vect_slp_analyze_bb===\n");
+    dump_printf (TDF_TREE, "===vect_slp_analyze_bb===\n");
 
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -2133,8 +2154,8 @@ vect_slp_analyze_bb (basic_block bb)
   if (insns > PARAM_VALUE (PARAM_SLP_MAX_INSNS_IN_BB))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: too many instructions in basic "
-                            "block.\n");
+        dump_printf (TDF_TREE, "not vectorized: too many instructions in "
+                     "basic block.\n");
 
       return NULL;
     }
@@ -2159,8 +2180,8 @@ vect_slp_analyze_bb (basic_block bb)
       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "***** Re-trying analysis with "
-                 "vector size %d\n", current_vector_size);
+        dump_printf (TDF_TREE, "***** Re-trying analysis with "
+                     "vector size %d\n", current_vector_size);
     }
 }
 
@@ -2180,7 +2201,7 @@ vect_update_slp_costs_according_to_vf (loop_vec_in
   slp_instance instance;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_update_slp_costs_according_to_vf ===");
+    dump_printf (TDF_TREE, "=== vect_update_slp_costs_according_to_vf ===");
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     /* We assume that costs are linear in ncopies.  */
@@ -2651,8 +2672,9 @@ vect_get_mask_element (gimple stmt, int first_mask
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "permutation requires at least two vectors ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE,
+                       "permutation requires at least two vectors ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       return false;
@@ -2668,9 +2690,9 @@ vect_get_mask_element (gimple stmt, int first_mask
              vectors.  */
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "permutation requires at "
-                                  "least three vectors ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf (TDF_TREE, "permutation requires at "
+                           "least three vectors ");
+              dump_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           return false;
@@ -2733,8 +2755,8 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tr
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vect permute for ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "no vect permute for ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
       return false;
     }
@@ -2812,10 +2834,11 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tr
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
 			{
-			  fprintf (vect_dump, "unsupported vect permute { ");
+			  dump_printf (TDF_TREE,
+                                       "unsupported vect permute { ");
 			  for (i = 0; i < nunits; ++i)
-			    fprintf (vect_dump, "%d ", mask[i]);
-			  fprintf (vect_dump, "}\n");
+			    dump_printf (TDF_TREE, "%d ", mask[i]);
+			  dump_printf (TDF_TREE, "}\n");
 			}
 		      return false;
 		    }
@@ -2913,8 +2936,8 @@ vect_schedule_slp_instance (slp_tree node, slp_ins
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "------>vectorizing SLP node starting from: ");
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      dump_printf (TDF_TREE, "------>vectorizing SLP node starting from: ");
+      dump_gimple_stmt (TDF_SLIM, stmt, 0);
     }
 
   /* Loads should be inserted before the first load.  */
@@ -3021,7 +3044,7 @@ vect_schedule_slp (loop_vec_info loop_vinfo, bb_ve
                                              instance, vf);
       if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)
 	  || vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	fprintf (vect_dump, "vectorizing stmts using SLP.");
+	dump_printf (TDF_TREE, "vectorizing stmts using SLP.");
     }
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
@@ -3065,7 +3088,7 @@ vect_slp_transform_bb (basic_block bb)
   gcc_assert (bb_vinfo);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "SLPing BB\n");
+    dump_printf (TDF_TREE, "SLPing BB\n");
 
   for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
     {
@@ -3074,8 +3097,8 @@ vect_slp_transform_bb (basic_block bb)
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "------>SLPing statement: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf (TDF_TREE, "------>SLPing statement: ");
+          dump_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       stmt_info = vinfo_for_stmt (stmt);
@@ -3096,8 +3119,7 @@ vect_slp_transform_bb (basic_block bb)
   update_ssa (TODO_update_ssa);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "BASIC BLOCK VECTORIZED\n");
+    dump_printf (TDF_TREE, "BASIC BLOCK VECTORIZED\n");
 
   destroy_bb_vec_info (bb_vinfo);
 }
-

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-07  6:16                           ` Sharad Singhai
@ 2012-06-07  8:08                             ` Xinliang David Li
  2012-06-08  6:59                               ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-06-07  8:08 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
> Sorry about the delay. I have finally incorporated all the suggestions
> and reorganized the dump infrastructure a bit. The attached patch
> updates vectorizer passes so that instead of accessing global
> dump_file directly, these passes call dump_printf (FLAG, format, ...).
> The dump_printf can choose between two streams, one regular pass dump
> file, and another optional command line provided file. Currently, it
> doesn't discriminate and all the dump information goes to both the
> streams.
>
> Thus, for example,
>
> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3

But the default form of dump option (-fdump-tree-vect) no longer
interferes with -ftree-vectorize-verbose=xxx output right? (this is
one of the main requirements). One dumped to the primary stream (named
dump file) and the other to the stderr -- the default diagnostic (alt)
stream.

David

>
> will output the verbose vectorizer information in both *.vect file and
> foo.v file. However, as I have converted only vectorizer passes so
> far, there is additional information in *.vect file which is not
> present in foo.v file. Once other passes are converted to use this
> scheme, then these two dump files should have identical output.
>
> Also note that in this patch -fdump-xxx=yyy format does not override
> any auto named dump files as in my earlier patches. Instead the dump
> information is output to both places when a command line dump file
> option is provided.
>
> To summarize:
> - instead of using dump_begin () / dump_end (), the passes should use
> dump_start ()/dump_finish (). These new variants do not return the
> dump_file. However, they still set the global dump_file/dump_flags for
> the benefit of other passes during the transition.
> - instead of directly printing to the dump_file, as in
> if (dump_file)
>  fprintf (dump_file, ...);
>
> The passes should do
>
> dump_printf (dump_flag, ...);
> This will output to dump file(s) only when dump_flag is enabled for a
> given pass.
>
> I have bootstrapped and tested it on x86_64. Does it look okay?
>
> Thanks,
> Sharad
>
>
> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>> <gdr@integrable-solutions.net> wrote:
>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>
>>>>> The downside is that the dump file format will look different from the
>>>>> stderr output which is less than ideal.
>>>>
>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>> as opposed to stdout or other files?  That does not sound right.
>>>>
>>>
>>> I was talking about the transformation information difference. In
>>> stderr (where diagnostics go to), we may have
>>>
>>> foo.c: in function 'foo':
>>> foo.c:5:6: note: loop was vectorized
>>>
>>> but in dump file the format for the information may be different,
>>> unless we want to duplicate the machinery in diagnostics.
>>
>> So?  What's the problem with that ("different" diagnostics)?
>>
>> Richard.
>>
>>> David
>>>
>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-07  8:08                             ` Xinliang David Li
@ 2012-06-08  6:59                               ` Sharad Singhai
  2012-06-13  6:28                                 ` Sharad Singhai
  2012-06-13 11:49                                 ` Richard Guenther
  0 siblings, 2 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-06-08  6:59 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

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

Okay, I have updated the attached patch so that the output from
-ftree-vectorizer-verbose is considered diagnostic information and is
always
sent to stderr. Other functionality remains unchanged. Here is some
more context about this patch.

This patch improves the dump infrastructure and public interfaces so
that the existing private pass-specific dump stream is separated from
the diagnostic dump stream (typically stderr).  The optimization
passes can output information on the two streams independently.

The newly defined interfaces are:

Individual passes do not need to access the dump file directly. Thus Instead
of doing

   if (dump_file && (flags & dump_flags))
      fprintf (dump_file, ...);

they can do

     dump_printf (flags, ...);

If the current pass has FLAGS enabled then the information gets
printed into the dump file otherwise not.

Similar to the dump_printf (), another function is defined, called

	diag_printf (dump_flags, ...)

This prints information only onto the diagnostic stream, typically
standard error. It is useful for separating pass-specific dump
information from
the diagnostic information.

Currently, as a proof of concept, I have converted vectorizer passes
to use the new dump format. For this, I have considered
information printed in vect_dump file as diagnostic. Thus 'fprintf'
calls are changed to 'diag_printf'. Some other information printed to
dump_file is sent to the regular dump file via 'dump_printf ()'. It
helps to separate the two streams because they might serve different
purposes and might have different formatting requirements.

For example, using the trunk compiler, the following invocation

g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2

prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
However, the verbose diagnostic output is silently
ignored. This is not desirable as the two types of dump should not interfere.

After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
as before, but the verbose vectorizer diagnostic is additionally
printed on stderr. Thus both types of dump information are output.

An additional feature of this patch is that individual passes can
print dump information into command-line named files instead of auto
numbered filename. For example,

g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
     -ftree-vectorizer-verbose=2
     -fdump-tree-pre=foo.pre

This prints the tree vectorizer dump into 'foo.vect', PRE dump into
'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.

Please take another look.

Thanks,
Sharad


On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>> Sorry about the delay. I have finally incorporated all the suggestions
>> and reorganized the dump infrastructure a bit. The attached patch
>> updates vectorizer passes so that instead of accessing global
>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>> The dump_printf can choose between two streams, one regular pass dump
>> file, and another optional command line provided file. Currently, it
>> doesn't discriminate and all the dump information goes to both the
>> streams.
>>
>> Thus, for example,
>>
>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>
> But the default form of dump option (-fdump-tree-vect) no longer
> interferes with -ftree-vectorize-verbose=xxx output right? (this is
> one of the main requirements). One dumped to the primary stream (named
> dump file) and the other to the stderr -- the default diagnostic (alt)
> stream.
>
> David
>
>>
>> will output the verbose vectorizer information in both *.vect file and
>> foo.v file. However, as I have converted only vectorizer passes so
>> far, there is additional information in *.vect file which is not
>> present in foo.v file. Once other passes are converted to use this
>> scheme, then these two dump files should have identical output.
>>
>> Also note that in this patch -fdump-xxx=yyy format does not override
>> any auto named dump files as in my earlier patches. Instead the dump
>> information is output to both places when a command line dump file
>> option is provided.
>>
>> To summarize:
>> - instead of using dump_begin () / dump_end (), the passes should use
>> dump_start ()/dump_finish (). These new variants do not return the
>> dump_file. However, they still set the global dump_file/dump_flags for
>> the benefit of other passes during the transition.
>> - instead of directly printing to the dump_file, as in
>> if (dump_file)
>>  fprintf (dump_file, ...);
>>
>> The passes should do
>>
>> dump_printf (dump_flag, ...);
>> This will output to dump file(s) only when dump_flag is enabled for a
>> given pass.
>>
>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>
>> Thanks,
>> Sharad
>>
>>
>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>> <gdr@integrable-solutions.net> wrote:
>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>
>>>>>> The downside is that the dump file format will look different from the
>>>>>> stderr output which is less than ideal.
>>>>>
>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>
>>>>
>>>> I was talking about the transformation information difference. In
>>>> stderr (where diagnostics go to), we may have
>>>>
>>>> foo.c: in function 'foo':
>>>> foo.c:5:6: note: loop was vectorized
>>>>
>>>> but in dump file the format for the information may be different,
>>>> unless we want to duplicate the machinery in diagnostics.
>>>
>>> So?  What's the problem with that ("different" diagnostics)?
>>>
>>> Richard.
>>>
>>>> David
>>>>
>>>>> -- Gaby

[-- Attachment #2: dump_vectorizer_verbose.2.diff --]
[-- Type: application/octet-stream, Size: 243934 bytes --]

2012-06-07  Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for the new option.
	* tree-dump.c (get_dump_file_name): Use command line filename if
	available.
	(dump_open_alternate_stream): New function.
	(dump_gimple_stmt): Ditto.
	(diag_gimple_stmt): Ditto.
	(dump_generic_expr): Ditto.
	(diag_generic_expr): Ditto.
	(dump_set_alternate_stream): Ditto.
	(dump_printf): Ditto.
	(diag_printf): Ditto.
	(dump_start): Ditto.
	(dump_finish): Ditto.
	(dump_begin): Use pstate and allow for standard streams.
	(dump_enabled_p): Handle both private and diagnostic streams.
	(dump_initialized_p): Ditto.
	(dump_enable_all): Ditto.
	(dump_end): Do not close standard streams.
	(dump_switch_p_1): Handle command-line dump filenames.
	(enable_rtl_dump_file): Update call.
	(dump_combine_total_stats): New function.
	(dump_combine_stats): Ditto.
	* tree-dump.h: New function declarations.
	* tree-pass.h: New function declarations.
	(struct dump_file_info): Add fields for alternate stream. Rename
	state to pstate. Update all uses.
	* toplev.c: Define diagnostic stream.
	* tree-vect-loop-manip.c: Use diag_printf instead of directly
	printing to vect_dump file. Similary use dump_printf instead of
	dump_file, 
	* tree-vectorizer.c: Ditto.
	* tree-vect-loop.c: Ditto.
	* tree-vectorizer.c: Ditto.
	* tree-vect-data-refs.c: Ditto.
	* tree-vect-patterns.c: Ditto.
	* tree-vect-stmts.c: Ditto.
	* tree-vect-slp.c: Ditto.
	* testsuite/g++.dg/other/dump-vectorizer-1.C: New test.
	* gimple-pretty-print.c: Rename dump_gimple_stmt to print_gimple_stmt_1.
	All callers updated.
	* gimple-pretty-print.h: Ditto.
	* profile.c: Rename end_branch_prob to end_branch_prob_1. All callers
	upddated.
	* rtl.h: Rename dump_combine_stats and dump_combine_total_stats.
	* combine.c: Ditto.
	* system.h: Add declaration of ALT_DUMP_FILE.
	* passes.c (finish_optimization_passes): Use dump_start and dump_finish.
	(pass_init_dump_file): Ditto.
	(pass_fini_dump_file): Ditto.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 188325)
+++ doc/invoke.texi	(working copy)
@@ -5318,6 +5318,7 @@ Here are some examples showing uses of these optio
 
 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass}=@var{filename}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
@@ -5715,15 +5716,18 @@ counters for each function compiled.
 
 @item -fdump-tree-@var{switch}
 @itemx -fdump-tree-@var{switch}-@var{options}
+@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
-@samp{-@var{options}} form is used, @var{options} is a list of
-@samp{-} separated options which control the details of the dump.  Not
-all options are applicable to all dumps; those that are not
-meaningful are ignored.  The following options are available
+created in the same directory as the output file. In case of
+@option{=@var{filename}} option, the dump is output on the given file
+instead of the auto named dump files.  If the @samp{-@var{options}}
+form is used, @var{options} is a list of @samp{-} separated options
+which control the details of the dump.  Not all options are applicable
+to all dumps; those that are not meaningful are ignored.  The
+following options are available
 
 @table @samp
 @item address
@@ -5761,6 +5765,21 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item =@var{filename}
+Instead of an auto named dump file, output into the given file
+name. The file names @file{stdout} and @file{stderr} are treated
+specially and are considered already open standard streams. For
+example:
+
+@smallexample
+gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
+     -ftree-vectorizer-verbose=3
+@end smallexample
+
+outputs vectorizer dump into @file{foo.dump}. The diagnostic
+information produced by the -ftree-vectorizer-verbose=3 flag is output
+on to standard error.
+
 @item all
 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
 and @option{lineno}.
@@ -5914,9 +5933,7 @@ Enable all the available tree dumps with the flags
 @item -ftree-vectorizer-verbose=@var{n}
 @opindex ftree-vectorizer-verbose
 This option controls the amount of debugging output the vectorizer prints.
-This information is written to standard error, unless
-@option{-fdump-tree-all} or @option{-fdump-tree-vect} is specified,
-in which case it is output to the usual dump listing file, @file{.vect}.
+This information is written to standard error.
 For @var{n}=0 no diagnostic information is reported.
 If @var{n}=1 the vectorizer reports each loop that got vectorized,
 and the total number of loops that got vectorized.
@@ -5939,6 +5956,13 @@ For @var{n}=9, all the information the vectorizer
 analysis and transformation is reported.  This is the same verbosity level
 that @option{-fdump-tree-vect-details} uses.
 
+Note that by using the format @option{-fdump-tree-vect=filename} or
+@option{-fdump-tree-vect-details=filename}, the dump information is
+output into the filename instead of the auto named dump
+files. However, the information output by
+@option{-ftree-vectorizer-verbose} option is always sent to standard
+error as it is considered diagnostic information.
+
 @item -frandom-seed=@var{string}
 @opindex frandom-seed
 This option provides a seed that GCC uses in place of
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 188325)
+++ tree-dump.c	(working copy)
@@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "gimple-pretty-print.h"
 #include "splay-tree.h"
 #include "filenames.h"
 #include "diagnostic-core.h"
+#include "rtl.h"
 #include "toplev.h"
 #include "tree-dump.h"
 #include "tree-pass.h"
@@ -770,23 +772,25 @@ dump_node (const_tree t, int flags, FILE *stream)
 \f
 
 /* Table of tree dump switches. This must be consistent with the
-   tree_dump_index enumeration in tree-pass.h.  */
+   TREE_DUMP_INDEX enumeration in tree-pass.h.  */
 static struct dump_file_info dump_files[TDI_end] =
 {
-  {NULL, NULL, NULL, 0, 0, 0},
-  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
-  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
-  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
-  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
-  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
-  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
-  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
-  {".ads", "ada-spec", NULL, 0, 0, 7},
+  {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0},
+  {".cgraph", "ipa-cgraph", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0},
+  {".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 1},
+  {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   2},
+  {".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   3},
+  {".gimple", "tree-gimple", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 4},
+  {".nested", "tree-nested", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 5},
+  {".vcg", "tree-vcg", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 6},
+  {".ads", "ada-spec", NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 7},
 #define FIRST_AUTO_NUMBERED_DUMP 8
 
-  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
-  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
-  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
+  {NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0},
+  {NULL, "rtl-all", NULL, NULL, NULL, NULL, NULL, TDF_RTL, 0, 0, 0},
+  {NULL, "ipa-all", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0},
 };
 
 /* Dynamically registered tree dump files and switches.  */
@@ -802,7 +806,7 @@ struct dump_option_value_info
 };
 
 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in tree-pass.h */
 static const struct dump_option_value_info dump_options[] =
 {
   {"address", TDF_ADDRESS},
@@ -861,7 +865,6 @@ dump_register (const char *suffix, const char *swt
   return count + TDI_end;
 }
 
-
 /* Return the dump_file_info for the given phase.  */
 
 struct dump_file_info *
@@ -875,7 +878,6 @@ get_dump_file_info (int phase)
     return extra_dump_files + (phase - TDI_end);
 }
 
-
 /* Return the name of the dump file for the given phase.
    If the dump is not enabled, returns NULL.  */
 
@@ -889,9 +891,13 @@ get_dump_file_name (int phase)
     return NULL;
 
   dfi = get_dump_file_info (phase);
-  if (dfi->state == 0)
+  if (dfi->pstate == 0)
     return NULL;
 
+  /* If available, use the command line dump filename. */
+  if (dfi->pfilename)
+    return xstrdup (dfi->pfilename);
+
   if (dfi->num < 0)
     dump_id[0] = '\0';
   else
@@ -911,6 +917,199 @@ get_dump_file_name (int phase)
   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }
 
+/* Open an alternate dump filename for PHASE (which could also be a
+   standard stream such as stdout/stderr). If the alternate dump file
+   cannot be opened, return NULL.  */
+
+static FILE *
+dump_open_alternate_stream (int phase)
+{
+  FILE *stream ;
+  struct dump_file_info *dfi;
+
+  dfi = get_dump_file_info (phase);
+  if (!dfi->dfilename)
+    return NULL;
+
+  if (dfi->dstream)
+    return dfi->dstream;
+
+  stream = strcmp("stderr", dfi->dfilename) == 0
+    ? stderr
+    : strcmp("stdout", dfi->dfilename) == 0
+    ?  stdout
+    : fopen (dfi->dfilename, dfi->dstate < 0 ? "w" : "a");
+
+  if (!stream)
+    error ("could not open dump file %qs: %m", dfi->dfilename);
+
+  return stream;
+}
+
+/* Dump gimple statement GS with SPC indentation spaces and FLAGS on
+   the pass-private dump stream.  */
+
+void
+dump_gimple_stmt (int flags, gimple gs, int spc)
+{
+  if (dump_file)
+    print_gimple_stmt (dump_file, gs, spc, flags);
+}
+
+/* Dump gimple statement GS with SPC indentation spaces and FLAGS on
+   the diagnostic stream.  */
+
+void
+diag_gimple_stmt (int flags, gimple gs, int spc)
+{
+  if (alt_dump_file)
+    print_gimple_stmt (alt_dump_file, gs, spc, flags);
+}
+
+/* Dump tree T using FLAGS on pass-specific private stream.  */
+
+void
+dump_generic_expr (int flags, tree t)
+{
+  if (dump_file)
+    print_generic_expr (dump_file, t, flags);
+}
+
+/* Dump tree T using FLAGS on diagnostic stream.  */
+
+void
+diag_generic_expr (int flags, tree t)
+{
+  if (alt_dump_file)
+    print_generic_expr (alt_dump_file, t, flags);
+}
+
+/* Open the FILENAME and set diagnostic dump stream for that phase.
+   Store user-supplied dump flags in *FLAG_PTR.  */
+
+void
+dump_set_alternate_stream (int phase, const char *filename, int *flag_ptr)
+{
+  struct dump_file_info *dfi;
+
+  dfi = get_dump_file_info (phase);
+  if (dfi->dfilename)
+    free (CONST_CAST (char *, dfi->dfilename));
+  dfi->dfilename = xstrdup (filename);
+  if (dfi->dstream && strcmp("stderr", dfi->dfilename) != 0
+      && strcmp("stdout", dfi->dfilename) != 0)
+    fclose (dfi->dstream);
+  dfi->dstream = dump_open_alternate_stream (phase);
+  dfi->dstate = 1;
+  alt_dump_file = dfi->dstream;
+  if (flag_ptr)
+    *flag_ptr = dfi->flags;
+}
+
+/* Output a formatted message using FORMAT on pass-specific private
+   dump stream if FLAGS are enabled for the stream.  */
+
+void
+dump_printf (int flags, const char *format, ...)
+{
+  if (dump_file && (flags & dump_flags))
+    {
+      va_list ap;
+      va_start (ap, format);
+      vfprintf (dump_file, format, ap);
+      va_end (ap);
+    }
+}
+
+/* Output a formatted message using FORMAT on diagnostic stream
+   if FLAGS are enabled on diagnostic stream.  */
+
+void
+diag_printf (int flags, const char *format, ...)
+{
+  if (alt_dump_file && (flags & dump_flags))
+    {
+      va_list ap;
+      va_start (ap, format);
+      vfprintf (alt_dump_file, format, ap);
+      va_end (ap);
+    }
+}
+
+/* Start a dump for PHASE. Store user-supplied dump flags in *FLAG_PTR.
+   Return the number of streams opened.  Also set globals DUMP_FILE,
+   and ALT_DUMP_FILE to point to the opened streams.  */
+
+int
+dump_start (int phase, int *flag_ptr)
+{
+  int count = 0;
+  char *name;
+  struct dump_file_info *dfi;
+  FILE *stream;
+  if (phase == TDI_none || !dump_enabled_p (phase))
+    return 0;
+
+  dfi = get_dump_file_info (phase);
+  name = get_dump_file_name (phase);
+  if (name)
+    {
+      stream = strcmp("stderr", name) == 0
+          ? stderr
+          : strcmp("stdout", name) == 0
+          ?  stdout
+          : fopen (name, dfi->pstate < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        {
+          dfi->pstate = 1;
+          count++;
+        }
+      free (name);
+      dfi->pstream = stream;
+      dump_file = dfi->pstream;
+    }
+
+  stream = dump_open_alternate_stream (phase);
+  if (stream)
+    {
+      dfi->dstream = stream;
+      dfi->dstate = 1;
+      count++;
+      alt_dump_file = dfi->dstream;
+    }
+
+  if (flag_ptr)
+    *flag_ptr = dfi->flags;
+  return count;
+}
+
+/* Finish a tree dump for PHASE and close associated dump streams.  Also
+   reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS.  */
+
+void
+dump_finish (int phase)
+{
+  struct dump_file_info *dfi;
+
+  if (phase < 0)
+    return;
+  dfi = get_dump_file_info (phase);
+  if (dfi->pstream)
+    fclose (dfi->pstream);
+
+  if (dfi->dstream && strcmp("stderr", dfi->dfilename) != 0
+      && strcmp("stdout", dfi->dfilename) != 0)
+    fclose (dfi->dstream);
+
+  dfi->dstream = NULL;
+  dfi->pstream = NULL;
+  dump_file = NULL;
+  alt_dump_file = NULL;
+  dump_flags = TDI_none;
+}
+
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
@@ -928,11 +1127,17 @@ dump_begin (int phase, int *flag_ptr)
 
   name = get_dump_file_name (phase);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
+
+  stream = strcmp("stderr", name) == 0
+    ? stderr
+    : strcmp("stdout", name) == 0
+    ?  stdout
+    : fopen (name, dfi->pstate < 0 ? "w" : "a");
+
   if (!stream)
     error ("could not open dump file %qs: %m", name);
   else
-    dfi->state = 1;
+    dfi->pstate = 1;
   free (name);
 
   if (flag_ptr)
@@ -941,8 +1146,9 @@ dump_begin (int phase, int *flag_ptr)
   return stream;
 }
 
-/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
-   TDI_tree_all, return nonzero if any dump is enabled.  */
+/* Returns nonzero if dump PHASE is enabled for at least one stream.
+   If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
+   any phase.  */
 
 int
 dump_enabled_p (int phase)
@@ -951,17 +1157,17 @@ dump_enabled_p (int phase)
     {
       size_t i;
       for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-	if (dump_files[i].state)
+	if (dump_files[i].pstate || dump_files[i].dstate)
 	  return 1;
       for (i = 0; i < extra_dump_files_in_use; i++)
-	if (extra_dump_files[i].state)
+	if (extra_dump_files[i].pstate || extra_dump_files[i].dstate)
 	  return 1;
       return 0;
     }
   else
     {
       struct dump_file_info *dfi = get_dump_file_info (phase);
-      return dfi->state;
+      return dfi->pstate || dfi->dstate;
     }
 }
 
@@ -971,7 +1177,7 @@ int
 dump_initialized_p (int phase)
 {
   struct dump_file_info *dfi = get_dump_file_info (phase);
-  return dfi->state > 0;
+  return dfi->pstate > 0 || dfi->dstate > 0;
 }
 
 /* Returns the switch name of PHASE.  */
@@ -989,33 +1195,53 @@ dump_flag_name (int phase)
 void
 dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
 {
-  fclose (stream);
+  if (stream != stderr && stream != stdout)
+    fclose (stream);
 }
 
-/* Enable all tree dumps.  Return number of enabled tree dumps.  */
+/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
+   enabled tree dumps.  */
 
 static int
-dump_enable_all (int flags)
+dump_enable_all (int flags, const char *filename)
 {
   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;
 
   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_dump_type))
-      {
-        dump_files[i].state = -1;
-        dump_files[i].flags |= flags;
-        n++;
-      }
+    {
+      if ((dump_files[i].flags & ir_dump_type))
+        {
+          const char *old_filename = dump_files[i].dfilename;
+          dump_files[i].pstate = -1;
+          dump_files[i].dstate = -1;
+          dump_files[i].flags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            dump_files[i].dfilename = xstrdup (filename);
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }
 
   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_dump_type))
-      {
-        extra_dump_files[i].state = -1;
-        extra_dump_files[i].flags |= flags;
-	n++;
-      }
+    {
+      if ((extra_dump_files[i].flags & ir_dump_type))
+        {
+          const char *old_filename = extra_dump_files[i].dfilename;
+          extra_dump_files[i].pstate = -1;
+          extra_dump_files[i].dstate = -1;
+          extra_dump_files[i].flags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            extra_dump_files[i].dfilename = xstrdup (filename);
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }
 
   return n;
 }
@@ -1037,7 +1263,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   if (!option_value)
     return 0;
 
-  if (*option_value && *option_value != '-')
+  if (*option_value && *option_value != '-' && *option_value != '=')
     return 0;
 
   ptr = option_value;
@@ -1047,11 +1273,17 @@ dump_switch_p_1 (const char *arg, struct dump_file
     {
       const struct dump_option_value_info *option_ptr;
       const char *end_ptr;
+      const char *eq_ptr;
       unsigned length;
 
       while (*ptr == '-')
 	ptr++;
       end_ptr = strchr (ptr, '-');
+      eq_ptr = strchr (ptr, '=');
+
+      if (eq_ptr)
+        end_ptr = eq_ptr;
+
       if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;
@@ -1059,23 +1291,35 @@ dump_switch_p_1 (const char *arg, struct dump_file
       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
-	  {
-	    flags |= option_ptr->value;
+          {
+            flags |= option_ptr->value;
 	    goto found;
-	  }
-      warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
-	       length, ptr, dfi->swtch);
+          }
+
+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  This
+             filename overrides other command line filenames.  */
+          if (dfi->pfilename)
+            free (CONST_CAST (char *, dfi->pfilename));
+          dfi->pfilename = xstrdup (ptr + 1);
+          break;
+        }
+      else
+        warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
+                 length, ptr, dfi->swtch);
     found:;
       ptr = end_ptr;
     }
 
-  dfi->state = -1;
+  dfi->pstate = -1;
+  dfi->dstate = -1;
   dfi->flags |= flags;
 
   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
      known dumps.  */
   if (dfi->suffix == NULL)
-    dump_enable_all (dfi->flags);
+    dump_enable_all (dfi->flags, dfi->dfilename);
 
   return 1;
 }
@@ -1124,5 +1368,31 @@ dump_function (int phase, tree fn)
 bool
 enable_rtl_dump_file (void)
 {
-  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
+  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
 }
+
+/* Dump combine statistics using FLAGS.  */
+
+void
+dump_combine_total_stats (int flags)
+{
+  if (flags & dump_flags)
+    {
+      if (dump_file)
+        print_combine_total_stats (dump_file);
+      if (alt_dump_file)
+        print_combine_total_stats (alt_dump_file);
+    }
+}
+
+DEBUG_FUNCTION void
+dump_combine_stats (int flags)
+{
+  if (flags & dump_flags)
+    {
+      if (dump_file)
+        print_combine_stats (dump_file);
+      if (alt_dump_file)
+        print_combine_stats (alt_dump_file);
+    }
+}
Index: tree-dump.h
===================================================================
--- tree-dump.h	(revision 188325)
+++ tree-dump.h	(working copy)
@@ -94,9 +94,17 @@ extern void dump_function_to_file (tree, FILE *, i
 extern void dump_enumerated_decls (FILE *, int);
 extern void debug_function (tree, int);
 extern int dump_flag (dump_info_p, int, const_tree);
+extern void dump_set_alternate_stream (int, const char *, int *);
+extern void dump_generic_expr (int, tree);
+extern void diag_generic_expr (int, tree);
+extern void dump_gimple_stmt (int, gimple, int);
+extern void diag_gimple_stmt (int, gimple, int);
+extern void dump_combine_total_stats (int);
+extern void dump_combine_stats (int);
 
 extern unsigned int dump_register (const char *, const char *, const char *,
 				   int);
+extern void dump_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
+extern void diag_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
 
-
 #endif /* ! GCC_TREE_DUMP_H */
Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 188325)
+++ tree-pass.h	(working copy)
@@ -85,7 +85,6 @@ enum tree_dump_index
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
 
-
 /* In tree-dump.c */
 
 extern char *get_dump_file_name (int);
@@ -93,12 +92,17 @@ extern int dump_enabled_p (int);
 extern int dump_initialized_p (int);
 extern FILE *dump_begin (int, int *);
 extern void dump_end (int, FILE *);
+
+extern int dump_start (int, int *);
+extern void dump_finish (int);
+
 extern void dump_node (const_tree, int, FILE *);
 extern int dump_switch_p (const char *);
 extern const char *dump_flag_name (int);
 
 /* Global variables used to communicate with passes.  */
 extern FILE *dump_file;
+extern FILE *alt_dump_file;
 extern int dump_flags;
 extern const char *dump_file_name;
 
@@ -222,8 +226,13 @@ struct dump_file_info
   const char *suffix;           /* suffix to give output file.  */
   const char *swtch;            /* command line switch */
   const char *glob;             /* command line glob  */
+  const char *pfilename;        /* filename for the pass-specific stream  */
+  const char *dfilename;        /* filename for the diagnostic stream  */
+  FILE *pstream;                /* private pass-specific dump stream  */
+  FILE *dstream;                /* diagnostic stream */
   int flags;                    /* user flags */
-  int state;                    /* state of play */
+  int pstate;                   /* state of pass-specific stream */
+  int dstate;                   /* state of the diagnostic stream */
   int num;                      /* dump file number */
 };
 
Index: toplev.c
===================================================================
--- toplev.c	(revision 188325)
+++ toplev.c	(working copy)
@@ -174,6 +174,7 @@ FILE *asm_out_file;
 FILE *aux_info_file;
 FILE *stack_usage_file = NULL;
 FILE *dump_file = NULL;
+FILE *alt_dump_file = NULL;
 const char *dump_file_name;
 
 /* The current working directory of a translation.  It's generally the
Index: tree-vect-loop-manip.c
===================================================================
--- tree-vect-loop-manip.c	(revision 188325)
+++ tree-vect-loop-manip.c	(working copy)
@@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
   gsi_remove (&loop_cond_gsi, true);
 
   loop_loc = find_loop_location (loop);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    {
-      if (loop_loc != UNKNOWN_LOC)
-        fprintf (dump_file, "\nloop at %s:%d: ",
+  if (loop_loc != UNKNOWN_LOC)
+    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
-    }
-
+  if (dump_flags & TDF_DETAILS)
+    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
   loop->nb_iterations = niters;
 }
 
@@ -1221,13 +1218,10 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
   if (!(new_loop = slpeel_tree_duplicate_loop_to_edge_cfg (loop, e)))
     {
       loop_loc = find_loop_location (loop);
-      if (dump_file && (dump_flags & TDF_DETAILS))
-        {
-          if (loop_loc != UNKNOWN_LOC)
-            fprintf (dump_file, "\n%s:%d: note: ",
+      if (loop_loc != UNKNOWN_LOC)
+        dump_printf (TDF_DETAILS, "\n%s:%d: note: ",
                      LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-          fprintf (dump_file, "tree_duplicate_loop_to_edge_cfg failed.\n");
-        }
+      dump_printf (TDF_DETAILS, "tree_duplicate_loop_to_edge_cfg failed.\n");
       return NULL;
     }
 
@@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
   /* Analyze phi functions of the loop header.  */
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_can_advance_ivs_p:");
+    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
 
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       phi = gsi_stmt (gsi);
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "Analyze phi: ");
+          diag_gimple_stmt (TDF_SLIM, phi, 0);
 	}
 
       /* Skip virtual phi's. The data dependences that are associated with
@@ -1668,7 +1662,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (!is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (phi))))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "virtual phi. skip.");
+	    diag_printf (TDF_TREE, "virtual phi. skip.");
 	  continue;
 	}
 
@@ -1677,7 +1671,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc phi. skip.");
+            diag_printf (TDF_TREE, "reduc phi. skip.");
           continue;
         }
 
@@ -1689,14 +1683,14 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (!access_fn)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "No Access function.");
+	    diag_printf (TDF_TREE, "No Access function.");
 	  return false;
 	}
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-	  fprintf (vect_dump, "Access function of PHI: ");
-	  print_generic_expr (vect_dump, access_fn, TDF_SLIM);
+	  diag_printf (TDF_TREE, "Access function of PHI: ");
+	  diag_generic_expr (TDF_SLIM, access_fn);
         }
 
       evolution_part = evolution_part_in_loop_num (access_fn, loop->num);
@@ -1704,7 +1698,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       if (evolution_part == NULL_TREE)
         {
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "No evolution.");
+	    diag_printf (TDF_TREE, "No evolution.");
 	  return false;
         }
 
@@ -1790,15 +1784,15 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
       phi1 = gsi_stmt (gsi1);
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "vect_update_ivs_after_vectorizer: phi: ");
-	  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "vect_update_ivs_after_vectorizer: phi: ");
+	  diag_gimple_stmt (TDF_SLIM, phi, 0);
         }
 
       /* Skip virtual phi's.  */
       if (!is_gimple_reg (SSA_NAME_VAR (PHI_RESULT (phi))))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "virtual phi. skip.");
+	    diag_printf (TDF_TREE, "virtual phi. skip.");
 	  continue;
 	}
 
@@ -1807,7 +1801,7 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
       if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc phi. skip.");
+            diag_printf (TDF_TREE, "reduc phi. skip.");
           continue;
         }
 
@@ -1870,7 +1864,7 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
   gimple_seq cond_expr_stmt_list = NULL;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
+    diag_printf (TDF_TREE, "=== vect_do_peeling_for_loop_bound ===");
 
   initialize_original_copy_tables ();
 
@@ -1915,9 +1909,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
   if (check_profitability)
     max_iter = MAX (max_iter, (int) th);
   record_niter_bound (new_loop, shwi_to_double_int (max_iter), false, true);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "Setting upper bound of nb iterations for epilogue "
-	     "loop to %d\n", max_iter);
+  dump_printf (TDF_DETAILS,
+               "Setting upper bound of nb iterations for epilogue "
+               "loop to %d\n", max_iter);
 
   /* After peeling we have to reset scalar evolution analyzer.  */
   scev_reset ();
@@ -1980,7 +1974,7 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
       int npeel = LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo);
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "known peeling = %d.", npeel);
+        diag_printf (TDF_TREE, "known peeling = %d.", npeel);
 
       iters = build_int_cst (niters_type, npeel);
     }
@@ -2031,8 +2025,8 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "niters for prolog loop: ");
-      print_generic_expr (vect_dump, iters, TDF_SLIM);
+      diag_printf (TDF_TREE, "niters for prolog loop: ");
+      diag_generic_expr (TDF_SLIM, iters);
     }
 
   var = create_tmp_var (niters_type, "prolog_loop_niters");
@@ -2088,7 +2082,7 @@ vect_update_inits_of_drs (loop_vec_info loop_vinfo
   struct data_reference *dr;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_update_inits_of_dr ===");
+    diag_printf (TDF_TREE, "=== vect_update_inits_of_dr ===");
 
   FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr)
     vect_update_init_of_dr (dr, niters);
@@ -2115,7 +2109,7 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
   int max_iter;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_alignment ===");
+    diag_printf (TDF_TREE, "=== vect_do_peeling_for_alignment ===");
 
   initialize_original_copy_tables ();
 
@@ -2137,9 +2131,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
   if (check_profitability)
     max_iter = MAX (max_iter, (int) th);
   record_niter_bound (new_loop, shwi_to_double_int (max_iter), false, true);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "Setting upper bound of nb iterations for prologue "
-	     "loop to %d\n", max_iter);
+  dump_printf (TDF_DETAILS,
+               "Setting upper bound of nb iterations for prologue "
+               "loop to %d\n", max_iter);
 
   /* Update number of times loop executes.  */
   n_iters = LOOP_VINFO_NITERS (loop_vinfo);
@@ -2434,11 +2428,11 @@ vect_create_cond_for_alias_checks (loop_vec_info l
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
 	{
-	  fprintf (vect_dump,
-		   "create runtime check for data references ");
-	  print_generic_expr (vect_dump, DR_REF (dr_a), TDF_SLIM);
-	  fprintf (vect_dump, " and ");
-	  print_generic_expr (vect_dump, DR_REF (dr_b), TDF_SLIM);
+	  diag_printf (TDF_TREE,
+                       "create runtime check for data references ");
+	  diag_generic_expr (TDF_SLIM, DR_REF (dr_a));
+	  diag_printf (TDF_TREE, " and ");
+	  diag_generic_expr (TDF_SLIM, DR_REF (dr_b));
 	}
 
       seg_a_min = addr_base_a;
@@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
     }
 
   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "created %u versioning for alias checks.\n",
-             VEC_length (ddr_p, may_alias_ddrs));
+    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
+                 VEC_length (ddr_p, may_alias_ddrs));
 }
 
 
@@ -2566,4 +2560,3 @@ vect_loop_versioning (loop_vec_info loop_vinfo,
 			     GSI_SAME_STMT);
     }
 }
-
Index: testsuite/g++.dg/other/dump-vectorizer-1.C
===================================================================
--- testsuite/g++.dg/other/dump-vectorizer-1.C	(revision 0)
+++ testsuite/g++.dg/other/dump-vectorizer-1.C	(revision 0)
@@ -0,0 +1,33 @@
+// Test that the dump to a user-defined file works correctly.
+// { dg-do compile }
+// { dg-options "-O2 -ftree-vectorize -fdump-tree-vect=foo.dump" }
+
+#include <stdio.h>
+#include <stdlib.h>
+
+char a[17];
+char c[16];
+
+int
+bar (int times)
+{
+ for (int i = 0; i< 16; i++)
+   a[i] = 0;
+
+ char *b = a+1;
+ for (int i = 0; i< 16; i++)
+   c[i] = b[i];
+
+ return 255;
+}
+
+
+int main(int argc, char *argv[])
+{
+ int a = bar (atoi(argv[1]));
+ printf("%d\n", a);
+ return a;
+}
+
+// { dg-final { scan-file foo.dump "Symbols to be put in SSA form" } }
+// { dg-final { remove-build-file "foo.dump" } }
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 188325)
+++ gimple-pretty-print.c	(working copy)
@@ -70,7 +70,7 @@ maybe_init_pretty_print (FILE *file)
 }
 
 
-/* Emit a newline and SPC indentantion spaces to BUFFER.  */
+/* Emit a newline and SPC indentation spaces to BUFFER.  */
 
 static void
 newline_and_indent (pretty_printer *buffer, int spc)
@@ -90,20 +90,20 @@ debug_gimple_stmt (gimple gs)
 }
 
 
-/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  */
+/* Dump GIMPLE statement G to FILE using SPC indentation spaces and
+   FLAGS as in print_gimple_stmt_1.  */
 
 void
 print_gimple_stmt (FILE *file, gimple g, int spc, int flags)
 {
   maybe_init_pretty_print (file);
-  dump_gimple_stmt (&buffer, g, spc, flags);
+  print_gimple_stmt_1 (&buffer, g, spc, flags);
   pp_flush (&buffer);
 }
 
 
-/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  Print only the right-hand side
+/* Dump GIMPLE statement G to FILE using SPC indentation spaces and
+   FLAGS as in print_gimple_stmt_1.  Print only the right-hand side
    of the statement.  */
 
 void
@@ -111,12 +111,12 @@ print_gimple_expr (FILE *file, gimple g, int spc,
 {
   flags |= TDF_RHS_ONLY;
   maybe_init_pretty_print (file);
-  dump_gimple_stmt (&buffer, g, spc, flags);
+  print_gimple_stmt_1 (&buffer, g, spc, flags);
 }
 
 
-/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
-   spaces and FLAGS as in dump_gimple_stmt.  */
+/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
+   spaces and FLAGS as in print_gimple_stmt_1.  */
 
 static void
 dump_gimple_seq (pretty_printer *buffer, gimple_seq seq, int spc, int flags)
@@ -127,15 +127,15 @@ dump_gimple_seq (pretty_printer *buffer, gimple_se
     {
       gimple gs = gsi_stmt (i);
       INDENT (spc);
-      dump_gimple_stmt (buffer, gs, spc, flags);
+      print_gimple_stmt_1 (buffer, gs, spc, flags);
       if (!gsi_one_before_end_p (i))
 	pp_newline (buffer);
     }
 }
 
 
-/* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  */
+/* Dump GIMPLE sequence SEQ to FILE using SPC indentation spaces and
+   FLAGS as in print_gimple_stmt_1.  */
 
 void
 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
@@ -244,7 +244,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc,
 
 
 /* Helper for dump_gimple_assign.  Print the unary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -328,7 +328,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs,
 
 
 /* Helper for dump_gimple_assign.  Print the binary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -382,7 +382,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs
 }
 
 /* Helper for dump_gimple_assign.  Print the ternary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -467,7 +467,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple g
 
 
 /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -518,7 +518,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple
 
 
 /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -618,7 +618,7 @@ pp_points_to_solution (pretty_printer *buffer, str
 }
 
 /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -751,7 +751,7 @@ dump_gimple_call (pretty_printer *buffer, gimple g
 
 
 /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -786,7 +786,7 @@ dump_gimple_switch (pretty_printer *buffer, gimple
 
 
 /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -1578,7 +1578,7 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs
 
 
 /* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   print_gimple_stmt_1.  */
 
 static void
 dump_gimple_phi (pretty_printer *buffer, gimple phi, int spc, int flags)
@@ -1810,7 +1810,7 @@ dump_gimple_omp_atomic_store (pretty_printer *buff
 
 
 /* Dump all the memory operands for statement GS.  BUFFER, SPC and
-   FLAGS are as in dump_gimple_stmt.  */
+   FLAGS are as in print_gimple_stmt_1.  */
 
 static void
 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -1845,7 +1845,7 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimpl
    TDF_* in tree-pass.h).  */
 
 void
-dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
+print_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
 {
   if (!gs)
     return;
@@ -2303,7 +2303,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic
       curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
 
       INDENT (curr_indent);
-      dump_gimple_stmt (buffer, stmt, curr_indent, flags);
+      print_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
       pp_newline (buffer);
       dump_histograms_for_stmt (cfun, buffer->buffer->stream, stmt);
     }
Index: gimple-pretty-print.h
===================================================================
--- gimple-pretty-print.h	(revision 188325)
+++ gimple-pretty-print.h	(working copy)
@@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
 extern void print_gimple_stmt (FILE *, gimple, int, int);
 extern void print_gimple_expr (FILE *, gimple, int, int);
-extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
+extern void print_gimple_stmt_1 (pretty_printer *, gimple, int, int);
 
 #endif /* ! GCC_GIMPLE_PRETTY_PRINT_H */
Index: tree-vectorizer.c
===================================================================
--- tree-vectorizer.c	(revision 188325)
+++ tree-vectorizer.c	(working copy)
@@ -96,7 +96,6 @@ VEC(vec_void_p,heap) *stmt_vec_info_vec;
 static void
 vect_set_dump_settings (bool slp)
 {
-  vect_dump = dump_file;
 
   /* Check if the verbosity level was defined by the user:  */
   if (user_vect_verbosity_level != MAX_VERBOSITY_LEVEL)
@@ -104,12 +103,15 @@ vect_set_dump_settings (bool slp)
       vect_verbosity_level = user_vect_verbosity_level;
       /* Ignore user defined verbosity if dump flags require higher level of
          verbosity.  */
-      if (dump_file)
+      if (dump_enabled_p (current_pass->static_pass_number))
         {
+          /* This is a diagnostic dump, always send it to standard error.  */
+          dump_set_alternate_stream (current_pass->static_pass_number,
+                                     "stderr", &dump_flags);
           if (((dump_flags & TDF_DETAILS)
-                && vect_verbosity_level >= REPORT_DETAILS)
-  	       || ((dump_flags & TDF_STATS)
-	            && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
+               && vect_verbosity_level >= REPORT_DETAILS)
+              || ((dump_flags & TDF_STATS)
+                  && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
             return;
         }
       else
@@ -117,21 +119,21 @@ vect_set_dump_settings (bool slp)
           /* If there is no dump file, print to stderr in case of loop
              vectorization.  */
           if (!slp)
-            vect_dump = stderr;
-
+            dump_set_alternate_stream (current_pass->static_pass_number,
+                                       "stderr", &dump_flags);
           return;
         }
     }
 
   /* User didn't specify verbosity level:  */
-  if (dump_file && (dump_flags & TDF_DETAILS))
+  if (dump_flags & TDF_DETAILS)
     vect_verbosity_level = REPORT_DETAILS;
-  else if (dump_file && (dump_flags & TDF_STATS))
+  else if (dump_flags & TDF_STATS)
     vect_verbosity_level = REPORT_UNVECTORIZED_LOCATIONS;
-  else
+  else if (user_vect_verbosity_level == MAX_VERBOSITY_LEVEL)
     vect_verbosity_level = REPORT_NONE;
 
-  gcc_assert (dump_file || vect_verbosity_level == REPORT_NONE);
+  gcc_assert (dump_flags || vect_verbosity_level == REPORT_NONE);
 }
 
 
@@ -145,15 +147,15 @@ vect_print_dump_info (enum vect_verbosity_levels v
   if (vl > vect_verbosity_level)
     return false;
 
-  if (!current_function_decl || !vect_dump)
+  if (!current_function_decl)
     return false;
 
   if (vect_location == UNKNOWN_LOC)
-    fprintf (vect_dump, "\n%s:%d: note: ",
-	     DECL_SOURCE_FILE (current_function_decl),
-	     DECL_SOURCE_LINE (current_function_decl));
+    diag_printf (TDF_TREE, "\n%s:%d: note: ",
+                 DECL_SOURCE_FILE (current_function_decl),
+                 DECL_SOURCE_LINE (current_function_decl));
   else
-    fprintf (vect_dump, "\n%d: ", LOC_LINE (vect_location));
+    diag_printf (TDF_TREE, "\n%d: ", LOC_LINE (vect_location));
 
   return true;
 }
@@ -194,10 +196,9 @@ vectorize_loops (void)
 	loop_vec_info loop_vinfo;
 
 	vect_location = find_loop_location (loop);
-        if (vect_location != UNKNOWN_LOC
-            && vect_verbosity_level > REPORT_NONE)
-	  fprintf (vect_dump, "\nAnalyzing loop at %s:%d\n",
-            LOC_FILE (vect_location), LOC_LINE (vect_location));
+        if (vect_location != UNKNOWN_LOC && vect_verbosity_level > REPORT_NONE)
+	  diag_printf (TDF_TREE, "\nAnalyzing loop at %s:%d\n",
+                       LOC_FILE (vect_location), LOC_LINE (vect_location));
 
 	loop_vinfo = vect_analyze_loop (loop);
 	loop->aux = loop_vinfo;
@@ -205,10 +206,9 @@ vectorize_loops (void)
 	if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
 	  continue;
 
-        if (vect_location != UNKNOWN_LOC
-            && vect_verbosity_level > REPORT_NONE)
-          fprintf (vect_dump, "\n\nVectorizing loop at %s:%d\n",
-            LOC_FILE (vect_location), LOC_LINE (vect_location));
+        if (vect_location != UNKNOWN_LOC && vect_verbosity_level > REPORT_NONE)
+          diag_printf (TDF_TREE, "\n\nVectorizing loop at %s:%d\n",
+                       LOC_FILE (vect_location), LOC_LINE (vect_location));
 
 	vect_transform_loop (loop_vinfo);
 	num_vectorized_loops++;
@@ -220,8 +220,8 @@ vectorize_loops (void)
   if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)
       || (num_vectorized_loops > 0
 	  && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)))
-    fprintf (vect_dump, "vectorized %u loops in function.\n",
-	     num_vectorized_loops);
+    diag_printf (TDF_TREE, "vectorized %u loops in function.\n",
+                 num_vectorized_loops);
 
   /*  ----------- Finalize. -----------  */
 
@@ -266,7 +266,7 @@ execute_vect_slp (void)
           vect_slp_transform_bb (bb);
 
           if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-            fprintf (vect_dump, "basic block vectorized using SLP\n");
+            diag_printf (TDF_TREE, "basic block vectorized using SLP\n");
         }
     }
 
@@ -339,12 +339,9 @@ increase_alignment (void)
         {
           DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
           DECL_USER_ALIGN (decl) = 1;
-          if (dump_file)
-            {
-              fprintf (dump_file, "Increasing alignment of decl: ");
-              print_generic_expr (dump_file, decl, TDF_SLIM);
-	      fprintf (dump_file, "\n");
-            }
+          diag_printf (TDF_TREE, "Increasing alignment of decl: ");
+          diag_generic_expr (TDF_SLIM, decl);
+          diag_printf (TDF_TREE, "\n");
         }
     }
   return 0;
Index: profile.c
===================================================================
--- profile.c	(revision 188325)
+++ profile.c	(working copy)
@@ -101,6 +101,7 @@ static int total_num_branches;
 
 /* Forward declarations.  */
 static void find_spanning_tree (struct edge_list *);
+static void end_branch_prob_1 (FILE *);
 
 /* Add edge instrumentation code to the entire insn chain.
 
@@ -1419,6 +1420,16 @@ init_branch_prob (void)
 void
 end_branch_prob (void)
 {
+  end_branch_prob_1 (dump_file);
+  end_branch_prob_1 (alt_dump_file);
+}
+
+/* Helper function for file-level cleanup for DUMP_FILE after
+   branch-prob processing is completed. */
+
+static void
+end_branch_prob_1 (FILE *dump_file)
+{
   if (dump_file)
     {
       fprintf (dump_file, "\n");
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 188325)
+++ tree-vect-loop.c	(working copy)
@@ -186,7 +186,7 @@ vect_determine_vectorization_factor (loop_vec_info
   bool analyze_pattern_stmt = false;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_determine_vectorization_factor ===");
+    diag_printf (TDF_TREE, "=== vect_determine_vectorization_factor ===");
 
   for (i = 0; i < nbbs; i++)
     {
@@ -198,8 +198,8 @@ vect_determine_vectorization_factor (loop_vec_info
 	  stmt_info = vinfo_for_stmt (phi);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "==> examining phi: ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "==> examining phi: ");
+	      diag_gimple_stmt (TDF_SLIM, phi, 0);
 	    }
 
 	  gcc_assert (stmt_info);
@@ -211,8 +211,8 @@ vect_determine_vectorization_factor (loop_vec_info
 
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "get vectype for scalar type:  ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  diag_printf (TDF_TREE, "get vectype for scalar type:  ");
+		  diag_generic_expr (TDF_SLIM, scalar_type);
 		}
 
 	      vectype = get_vectype_for_scalar_type (scalar_type);
@@ -220,9 +220,9 @@ vect_determine_vectorization_factor (loop_vec_info
 		{
 		  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		    {
-		      fprintf (vect_dump,
-		               "not vectorized: unsupported data-type ");
-		      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		      diag_printf (TDF_TREE,
+                                   "not vectorized: unsupported data-type ");
+		      diag_generic_expr (TDF_SLIM, scalar_type);
 		    }
 		  return false;
 		}
@@ -230,13 +230,13 @@ vect_determine_vectorization_factor (loop_vec_info
 
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "vectype: ");
-		  print_generic_expr (vect_dump, vectype, TDF_SLIM);
+		  diag_printf (TDF_TREE, "vectype: ");
+		  diag_generic_expr (TDF_SLIM, vectype);
 		}
 
 	      nunits = TYPE_VECTOR_SUBPARTS (vectype);
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "nunits = %d", nunits);
+		diag_printf (TDF_TREE, "nunits = %d", nunits);
 
 	      if (!vectorization_factor
 		  || (nunits > vectorization_factor))
@@ -257,8 +257,8 @@ vect_determine_vectorization_factor (loop_vec_info
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "==> examining statement: ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "==> examining statement: ");
+	      diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  gcc_assert (stmt_info);
@@ -276,14 +276,15 @@ vect_determine_vectorization_factor (loop_vec_info
                   stmt_info = vinfo_for_stmt (pattern_stmt);
                   if (vect_print_dump_info (REPORT_DETAILS))
                     {
-                      fprintf (vect_dump, "==> examining pattern statement: ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      diag_printf (TDF_TREE,
+                                   "==> examining pattern statement: ");
+                      diag_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
                 }
               else
 	        {
 	          if (vect_print_dump_info (REPORT_DETAILS))
-	            fprintf (vect_dump, "skip.");
+	            diag_printf (TDF_TREE, "skip.");
                   gsi_next (&si);
 	          continue;
                 }
@@ -324,10 +325,9 @@ vect_determine_vectorization_factor (loop_vec_info
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
 			{
-			  fprintf (vect_dump,
-				   "==> examining pattern def stmt: ");
-			  print_gimple_stmt (vect_dump, pattern_def_stmt, 0,
-					     TDF_SLIM);
+			  diag_printf (TDF_TREE,
+                                       "==> examining pattern def stmt: ");
+			  diag_gimple_stmt (TDF_SLIM, pattern_def_stmt, 0);
 			}
 
 		      stmt = pattern_def_stmt;
@@ -347,8 +347,8 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-	          fprintf (vect_dump, "not vectorized: irregular stmt.");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	          diag_printf (TDF_TREE, "not vectorized: irregular stmt.");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -357,8 +357,9 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 	        {
-	          fprintf (vect_dump, "not vectorized: vector stmt in loop:");
-	          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	          diag_printf (TDF_TREE,
+                               "not vectorized: vector stmt in loop:");
+	          diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	        }
 	      return false;
 	    }
@@ -380,17 +381,17 @@ vect_determine_vectorization_factor (loop_vec_info
 	      scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "get vectype for scalar type:  ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  diag_printf (TDF_TREE, "get vectype for scalar type:  ");
+		  diag_generic_expr (TDF_SLIM, scalar_type);
 		}
 	      vectype = get_vectype_for_scalar_type (scalar_type);
 	      if (!vectype)
 		{
 		  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		    {
-		      fprintf (vect_dump,
-			       "not vectorized: unsupported data-type ");
-		      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		      diag_printf (TDF_TREE,
+                                   "not vectorized: unsupported data-type ");
+		      diag_generic_expr (TDF_SLIM, scalar_type);
 		    }
 		  return false;
 		}
@@ -405,17 +406,17 @@ vect_determine_vectorization_factor (loop_vec_info
 						       &dummy);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "get vectype for scalar type:  ");
-	      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+	      diag_printf (TDF_TREE, "get vectype for scalar type:  ");
+	      diag_generic_expr (TDF_SLIM, scalar_type);
 	    }
 	  vf_vectype = get_vectype_for_scalar_type (scalar_type);
 	  if (!vf_vectype)
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: unsupported data-type ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "not vectorized: unsupported data-type ");
+		  diag_generic_expr (TDF_SLIM, scalar_type);
 		}
 	      return false;
 	    }
@@ -425,25 +426,25 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: different sized vector "
-			   "types in statement, ");
-		  print_generic_expr (vect_dump, vectype, TDF_SLIM);
-		  fprintf (vect_dump, " and ");
-		  print_generic_expr (vect_dump, vf_vectype, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "not vectorized: different sized vector "
+                               "types in statement, ");
+		  diag_generic_expr (TDF_SLIM, vectype);
+		  diag_printf (TDF_TREE, " and ");
+		  diag_generic_expr (TDF_SLIM, vf_vectype);
 		}
 	      return false;
 	    }
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "vectype: ");
-	      print_generic_expr (vect_dump, vf_vectype, TDF_SLIM);
+	      diag_printf (TDF_TREE, "vectype: ");
+	      diag_generic_expr (TDF_SLIM, vf_vectype);
 	    }
 
 	  nunits = TYPE_VECTOR_SUBPARTS (vf_vectype);
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "nunits = %d", nunits);
+	    diag_printf (TDF_TREE, "nunits = %d", nunits);
 
 	  if (!vectorization_factor
 	      || (nunits > vectorization_factor))
@@ -459,11 +460,12 @@ vect_determine_vectorization_factor (loop_vec_info
 
   /* TODO: Analyze cost. Decide if worth while to vectorize.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vectorization factor = %d", vectorization_factor);
+    diag_printf (TDF_TREE, "vectorization factor = %d",
+                 vectorization_factor);
   if (vectorization_factor <= 1)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported data-type");
+        diag_printf (TDF_TREE, "not vectorized: unsupported data-type");
       return false;
     }
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
@@ -500,10 +502,10 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tre
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "step: ");
-      print_generic_expr (vect_dump, step_expr, TDF_SLIM);
-      fprintf (vect_dump, ",  init: ");
-      print_generic_expr (vect_dump, init_expr, TDF_SLIM);
+      diag_printf (TDF_TREE, "step: ");
+      diag_generic_expr (TDF_SLIM, step_expr);
+      diag_printf (TDF_TREE, ",  init: ");
+      diag_generic_expr (TDF_SLIM, init_expr);
     }
 
   *init = init_expr;
@@ -512,7 +514,7 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tre
   if (TREE_CODE (step_expr) != INTEGER_CST)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "step unknown.");
+        diag_printf (TDF_TREE, "step unknown.");
       return false;
     }
 
@@ -536,7 +538,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
   bool double_reduc;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_scalar_cycles ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_scalar_cycles ===");
 
   /* First - identify all inductions.  Reduction detection assumes that all the
      inductions have been identified, therefore, this order must not be
@@ -550,8 +552,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
 
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "Analyze phi: ");
-	  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	  diag_printf (TDF_TREE, "Analyze phi: ");
+	  diag_gimple_stmt (TDF_SLIM, phi, 0);
 	}
 
       /* Skip virtual phi's.  The data dependences that are associated with
@@ -568,8 +570,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
 	  STRIP_NOPS (access_fn);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "Access function of PHI: ");
-	      print_generic_expr (vect_dump, access_fn, TDF_SLIM);
+	      diag_printf (TDF_TREE, "Access function of PHI: ");
+	      diag_generic_expr (TDF_SLIM, access_fn);
 	    }
 	  STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
 	    = evolution_part_in_loop_num (access_fn, loop->num);
@@ -585,7 +587,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
       gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) != NULL_TREE);
 
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Detected induction.");
+	diag_printf (TDF_TREE, "Detected induction.");
       STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_induction_def;
     }
 
@@ -601,8 +603,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "Analyze phi: ");
+          diag_gimple_stmt (TDF_SLIM, phi, 0);
         }
 
       gcc_assert (is_gimple_reg (SSA_NAME_VAR (def)));
@@ -616,7 +618,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
           if (double_reduc)
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Detected double reduction.");
+                diag_printf (TDF_TREE, "Detected double reduction.");
 
               STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_double_reduction_def;
               STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -627,7 +629,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
               if (nested_cycle)
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Detected vectorizable nested cycle.");
+                    diag_printf (TDF_TREE,
+                                 "Detected vectorizable nested cycle.");
 
                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_nested_cycle;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -636,7 +639,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
               else
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Detected reduction.");
+                    diag_printf (TDF_TREE, "Detected reduction.");
 
                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_reduction_def;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -651,7 +654,7 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
         }
       else
         if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Unknown def-use cycle pattern.");
+          diag_printf (TDF_TREE, "Unknown def-use cycle pattern.");
     }
 
   VEC_free (gimple, heap, worklist);
@@ -712,7 +715,7 @@ vect_get_loop_niters (struct loop *loop, tree *num
   tree niters;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== get_loop_niters ===");
+    diag_printf (TDF_TREE, "=== get_loop_niters ===");
 
   niters = number_of_exit_cond_executions (loop);
 
@@ -723,8 +726,8 @@ vect_get_loop_niters (struct loop *loop, tree *num
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "==> get_loop_niters:" );
-          print_generic_expr (vect_dump, *number_of_iterations, TDF_SLIM);
+          diag_printf (TDF_TREE, "==> get_loop_niters:" );
+          diag_generic_expr (TDF_SLIM, *number_of_iterations);
         }
     }
 
@@ -948,7 +951,7 @@ vect_analyze_loop_1 (struct loop *loop)
   loop_vec_info loop_vinfo;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===== analyze_loop_nest_1 =====");
+    diag_printf (TDF_TREE, "===== analyze_loop_nest_1 =====");
 
   /* Check the CFG characteristics of the loop (nesting, entry/exit, etc.  */
 
@@ -956,7 +959,7 @@ vect_analyze_loop_1 (struct loop *loop)
   if (!loop_vinfo)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bad inner-loop form.");
+        diag_printf (TDF_TREE, "bad inner-loop form.");
       return NULL;
     }
 
@@ -981,7 +984,7 @@ vect_analyze_loop_form (struct loop *loop)
   loop_vec_info inner_loop_vinfo = NULL;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_loop_form ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_loop_form ===");
 
   /* Different restrictions apply when we are considering an inner-most loop,
      vs. an outer (nested) loop.
@@ -1004,14 +1007,14 @@ vect_analyze_loop_form (struct loop *loop)
       if (loop->num_nodes != 2)
         {
           if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: control flow in loop.");
+            diag_printf (TDF_TREE, "not vectorized: control flow in loop.");
           return NULL;
         }
 
       if (empty_block_p (loop->header))
     {
           if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: empty loop.");
+            diag_printf (TDF_TREE, "not vectorized: empty loop.");
       return NULL;
     }
     }
@@ -1040,7 +1043,7 @@ vect_analyze_loop_form (struct loop *loop)
       if ((loop->inner)->inner || (loop->inner)->next)
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: multiple nested loops.");
+	    diag_printf (TDF_TREE, "not vectorized: multiple nested loops.");
 	  return NULL;
 	}
 
@@ -1049,7 +1052,7 @@ vect_analyze_loop_form (struct loop *loop)
       if (!inner_loop_vinfo)
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: Bad inner loop.");
+            diag_printf (TDF_TREE, "not vectorized: Bad inner loop.");
 	  return NULL;
 	}
 
@@ -1057,8 +1060,8 @@ vect_analyze_loop_form (struct loop *loop)
 					LOOP_VINFO_NITERS (inner_loop_vinfo)))
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump,
-		     "not vectorized: inner-loop count not invariant.");
+	    diag_printf (TDF_TREE,
+                         "not vectorized: inner-loop count not invariant.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}
@@ -1066,7 +1069,7 @@ vect_analyze_loop_form (struct loop *loop)
       if (loop->num_nodes != 5)
         {
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: control flow in loop.");
+	    diag_printf (TDF_TREE, "not vectorized: control flow in loop.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
         }
@@ -1081,13 +1084,14 @@ vect_analyze_loop_form (struct loop *loop)
 	  || single_exit (innerloop)->dest !=  EDGE_PRED (loop->latch, 0)->src)
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: unsupported outerloop form.");
+	    diag_printf (TDF_TREE,
+                         "not vectorized: unsupported outerloop form.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Considering outer-loop vectorization.");
+        diag_printf (TDF_TREE, "Considering outer-loop vectorization.");
     }
 
   if (!single_exit (loop)
@@ -1096,9 +1100,10 @@ vect_analyze_loop_form (struct loop *loop)
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
         {
           if (!single_exit (loop))
-            fprintf (vect_dump, "not vectorized: multiple exits.");
+            diag_printf (TDF_TREE, "not vectorized: multiple exits.");
           else if (EDGE_COUNT (loop->header->preds) != 2)
-            fprintf (vect_dump, "not vectorized: too many incoming edges.");
+            diag_printf (TDF_TREE,
+                         "not vectorized: too many incoming edges.");
         }
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
@@ -1113,7 +1118,7 @@ vect_analyze_loop_form (struct loop *loop)
         || !gimple_seq_empty_p (phi_nodes (loop->latch)))
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-        fprintf (vect_dump, "not vectorized: unexpected loop form.");
+        diag_printf (TDF_TREE, "not vectorized: unexpected loop form.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1127,12 +1132,13 @@ vect_analyze_loop_form (struct loop *loop)
 	{
 	  split_loop_exit_edge (e);
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "split exit edge.");
+	    diag_printf (TDF_TREE, "split exit edge.");
 	}
       else
 	{
 	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: abnormal loop exit edge.");
+	    diag_printf (TDF_TREE,
+                         "not vectorized: abnormal loop exit edge.");
 	  if (inner_loop_vinfo)
 	    destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
@@ -1143,7 +1149,8 @@ vect_analyze_loop_form (struct loop *loop)
   if (!loop_cond)
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	fprintf (vect_dump, "not vectorized: complicated exit condition.");
+	diag_printf (TDF_TREE,
+                     "not vectorized: complicated exit condition.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1152,8 +1159,9 @@ vect_analyze_loop_form (struct loop *loop)
   if (!number_of_iterations)
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	fprintf (vect_dump,
-		 "not vectorized: number of iterations cannot be computed.");
+	diag_printf (TDF_TREE,
+                     "not vectorized: number of iterations cannot be "
+                     "computed.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1162,7 +1170,7 @@ vect_analyze_loop_form (struct loop *loop)
   if (chrec_contains_undetermined (number_of_iterations))
     {
       if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-        fprintf (vect_dump, "Infinite number of iterations.");
+        diag_printf (TDF_TREE, "Infinite number of iterations.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1172,14 +1180,15 @@ vect_analyze_loop_form (struct loop *loop)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "Symbolic number of iterations is ");
-          print_generic_expr (vect_dump, number_of_iterations, TDF_DETAILS);
+          diag_printf (TDF_TREE, "Symbolic number of iterations is ");
+          if (dump_flags & TDF_DETAILS)
+            diag_generic_expr (TDF_DETAILS, number_of_iterations);
         }
     }
   else if (TREE_INT_CST_LOW (number_of_iterations) == 0)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: number of iterations = 0.");
+        diag_printf (TDF_TREE, "not vectorized: number of iterations = 0.");
       if (inner_loop_vinfo)
         destroy_loop_vec_info (inner_loop_vinfo, false);
       return NULL;
@@ -1237,7 +1246,7 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   HOST_WIDE_INT max_niter;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_loop_operations ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_loop_operations ===");
 
   gcc_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo));
   vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -1272,8 +1281,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
 
       LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Updating vectorization factor to %d ",
-	 		    vectorization_factor);
+	diag_printf (TDF_TREE, "Updating vectorization factor to %d ",
+                     vectorization_factor);
     }
 
   for (i = 0; i < nbbs; i++)
@@ -1288,8 +1297,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
           stmt_info = vinfo_for_stmt (phi);
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "examining phi: ");
-              print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+              diag_printf (TDF_TREE, "examining phi: ");
+              diag_gimple_stmt (TDF_SLIM, phi, 0);
             }
 
           /* Inner-loop loop-closed exit phi in outer-loop vectorization
@@ -1306,8 +1315,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
                      != vect_double_reduction_def)
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump,
-                             "Unsupported loop-closed phi in outer-loop.");
+                    diag_printf (TDF_TREE,
+                                 "Unsupported loop-closed phi in outer-loop.");
                   return false;
                 }
 
@@ -1347,7 +1356,7 @@ vect_analyze_loop_operations (loop_vec_info loop_v
             {
               /* FORNOW: not yet supported.  */
               if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-                fprintf (vect_dump, "not vectorized: value used after loop.");
+                diag_printf (TDF_TREE, "not vectorized: value used after loop.");
               return false;
             }
 
@@ -1356,7 +1365,8 @@ vect_analyze_loop_operations (loop_vec_info loop_v
             {
               /* A scalar-dependence cycle that we don't support.  */
               if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-                fprintf (vect_dump, "not vectorized: scalar dependence cycle.");
+                diag_printf (TDF_TREE,
+                             "not vectorized: scalar dependence cycle.");
               return false;
             }
 
@@ -1371,9 +1381,9 @@ vect_analyze_loop_operations (loop_vec_info loop_v
             {
               if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
                 {
-                  fprintf (vect_dump,
-                           "not vectorized: relevant phi not supported: ");
-                  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+                  diag_printf (TDF_TREE,
+                               "not vectorized: relevant phi not supported: ");
+                  diag_gimple_stmt (TDF_SLIM, phi, 0);
                 }
               return false;
             }
@@ -1395,19 +1405,19 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   if (!need_to_vectorize)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump,
-                 "All the computation can be taken out of the loop.");
+        diag_printf (TDF_TREE,
+                     "All the computation can be taken out of the loop.");
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump,
-                 "not vectorized: redundant loop. no profit to vectorize.");
+        diag_printf (TDF_TREE,
+                     "not vectorized: redundant loop. no profit to vectorize.");
       return false;
     }
 
   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
       && vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump,
-        "vectorization_factor = %d, niters = " HOST_WIDE_INT_PRINT_DEC,
-        vectorization_factor, LOOP_VINFO_INT_NITERS (loop_vinfo));
+    diag_printf (TDF_TREE,
+                 "vectorization_factor = %d, niters = " HOST_WIDE_INT_PRINT_DEC,
+                 vectorization_factor, LOOP_VINFO_INT_NITERS (loop_vinfo));
 
   if ((LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
        && (LOOP_VINFO_INT_NITERS (loop_vinfo) < vectorization_factor))
@@ -1415,10 +1425,10 @@ vect_analyze_loop_operations (loop_vec_info loop_v
 	  && (unsigned HOST_WIDE_INT) max_niter < vectorization_factor))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: iteration count too small.");
+        diag_printf (TDF_TREE, "not vectorized: iteration count too small.");
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump,"not vectorized: iteration count smaller than "
-                 "vectorization factor.");
+        diag_printf (TDF_TREE,"not vectorized: iteration count smaller than "
+                     "vectorization factor.");
       return false;
     }
 
@@ -1434,10 +1444,11 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   if (min_profitable_iters < 0)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization not profitable.");
+        diag_printf (TDF_TREE, "not vectorized: vectorization not profitable.");
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not vectorized: vector version will never be "
-                 "profitable.");
+        diag_printf (TDF_TREE,
+                     "not vectorized: vector version will never be "
+                     "profitable.");
       return false;
     }
 
@@ -1457,12 +1468,13 @@ vect_analyze_loop_operations (loop_vec_info loop_v
       && LOOP_VINFO_INT_NITERS (loop_vinfo) <= th)
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization not "
+        diag_printf (TDF_TREE, "not vectorized: vectorization not "
                  "profitable.");
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not vectorized: iteration count smaller than "
-                 "user specified loop bound parameter or minimum "
-                 "profitable iterations (whichever is more conservative).");
+        diag_printf (TDF_TREE,
+                     "not vectorized: iteration count smaller than "
+                     "user specified loop bound parameter or minimum "
+                     "profitable iterations (whichever is more conservative).");
       return false;
     }
 
@@ -1471,19 +1483,19 @@ vect_analyze_loop_operations (loop_vec_info loop_v
       || LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "epilog loop required.");
+        diag_printf (TDF_TREE, "epilog loop required.");
       if (!vect_can_advance_ivs_p (loop_vinfo))
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump,
-                     "not vectorized: can't create epilog loop 1.");
+            diag_printf (TDF_TREE,
+                         "not vectorized: can't create epilog loop 1.");
           return false;
         }
       if (!slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump,
-                     "not vectorized: can't create epilog loop 2.");
+            diag_printf (TDF_TREE,
+                         "not vectorized: can't create epilog loop 2.");
           return false;
         }
     }
@@ -1515,7 +1527,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data references.");
+	diag_printf (TDF_TREE, "bad data references.");
       return false;
     }
 
@@ -1532,7 +1544,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "unexpected pattern.");
+	diag_printf (TDF_TREE, "unexpected pattern.");
       return false;
     }
 
@@ -1546,7 +1558,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
       || max_vf < min_vf)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data dependence.");
+	diag_printf (TDF_TREE, "bad data dependence.");
       return false;
     }
 
@@ -1554,13 +1566,13 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "can't determine vectorization factor.");
+        diag_printf (TDF_TREE, "can't determine vectorization factor.");
       return false;
     }
   if (max_vf < LOOP_VINFO_VECT_FACTOR (loop_vinfo))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data dependence.");
+	diag_printf (TDF_TREE, "bad data dependence.");
       return false;
     }
 
@@ -1571,7 +1583,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data alignment.");
+	diag_printf (TDF_TREE, "bad data alignment.");
       return false;
     }
 
@@ -1582,7 +1594,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data access.");
+	diag_printf (TDF_TREE, "bad data access.");
       return false;
     }
 
@@ -1593,8 +1605,8 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "too long list of versioning for alias "
-			    "run-time tests.");
+	diag_printf (TDF_TREE, "too long list of versioning for alias "
+                     "run-time tests.");
       return false;
     }
 
@@ -1605,7 +1617,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bad data alignment.");
+        diag_printf (TDF_TREE, "bad data alignment.");
       return false;
     }
 
@@ -1629,7 +1641,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad operation or unsupported loop bound.");
+	diag_printf (TDF_TREE, "bad operation or unsupported loop bound.");
       return false;
     }
 
@@ -1652,14 +1664,14 @@ vect_analyze_loop (struct loop *loop)
   vector_sizes = targetm.vectorize.autovectorize_vector_sizes ();
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===== analyze_loop_nest =====");
+    diag_printf (TDF_TREE, "===== analyze_loop_nest =====");
 
   if (loop_outer (loop)
       && loop_vec_info_for_loop (loop_outer (loop))
       && LOOP_VINFO_VECTORIZABLE_P (loop_vec_info_for_loop (loop_outer (loop))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "outer-loop already vectorized.");
+	diag_printf (TDF_TREE, "outer-loop already vectorized.");
       return NULL;
     }
 
@@ -1670,7 +1682,7 @@ vect_analyze_loop (struct loop *loop)
       if (!loop_vinfo)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "bad loop form.");
+	    diag_printf (TDF_TREE, "bad loop form.");
 	  return NULL;
 	}
 
@@ -1691,7 +1703,7 @@ vect_analyze_loop (struct loop *loop)
       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "***** Re-trying analysis with "
+	diag_printf (TDF_TREE, "***** Re-trying analysis with "
 		 "vector size %d\n", current_vector_size);
     }
 }
@@ -1748,8 +1760,8 @@ reduction_code_for_scalar_code (enum tree_code cod
 static void
 report_vect_op (gimple stmt, const char *msg)
 {
-  fprintf (vect_dump, "%s", msg);
-  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+  diag_printf (TDF_TREE, "%s", msg);
+  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 }
 
 
@@ -1923,8 +1935,8 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
   	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "swapping oprnds: ");
-		  print_gimple_stmt (vect_dump, next_stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE, "swapping oprnds: ");
+		  diag_gimple_stmt (TDF_SLIM, next_stmt, 0);
 		}
 
 	      swap_tree_operands (next_stmt,
@@ -2021,7 +2033,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "intermediate value used outside loop.");
+            diag_printf (TDF_TREE, "intermediate value used outside loop.");
 
           return NULL;
         }
@@ -2032,7 +2044,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (nloop_uses > 1)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduction used in loop.");
+            diag_printf (TDF_TREE, "reduction used in loop.");
           return NULL;
         }
     }
@@ -2041,8 +2053,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
     {
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "reduction: not ssa_name: ");
-	  print_generic_expr (vect_dump, loop_arg, TDF_SLIM);
+	  diag_printf (TDF_TREE, "reduction: not ssa_name: ");
+	  diag_generic_expr (TDF_SLIM, loop_arg);
 	}
       return NULL;
     }
@@ -2051,14 +2063,14 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
   if (!def_stmt)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "reduction: no def_stmt.");
+	diag_printf (TDF_TREE, "reduction: no def_stmt.");
       return NULL;
     }
 
   if (!is_gimple_assign (def_stmt) && gimple_code (def_stmt) != GIMPLE_PHI)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        print_gimple_stmt (vect_dump, def_stmt, 0, TDF_SLIM);
+        diag_gimple_stmt (TDF_SLIM, def_stmt, 0);
       return NULL;
     }
 
@@ -2086,7 +2098,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (nloop_uses > 1)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "reduction used in loop.");
+	    diag_printf (TDF_TREE, "reduction used in loop.");
 	  return NULL;
 	}
     }
@@ -2101,7 +2113,7 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
           || TREE_CODE (op1) != SSA_NAME)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "unsupported phi node definition.");
+            diag_printf (TDF_TREE, "unsupported phi node definition.");
 
           return NULL;
         }
@@ -2197,22 +2209,23 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "reduction: multiple types: operation type: ");
-          print_generic_expr (vect_dump, type, TDF_SLIM);
-          fprintf (vect_dump, ", operands types: ");
-          print_generic_expr (vect_dump, TREE_TYPE (op1), TDF_SLIM);
-          fprintf (vect_dump, ",");
-          print_generic_expr (vect_dump, TREE_TYPE (op2), TDF_SLIM);
+          diag_printf (TDF_TREE,
+                       "reduction: multiple types: operation type: ");
+          diag_generic_expr (TDF_SLIM, type);
+          diag_printf (TDF_TREE, ", operands types: ");
+          diag_generic_expr (TDF_SLIM, TREE_TYPE (op1));
+          diag_printf (TDF_TREE, ",");
+          diag_generic_expr (TDF_SLIM, TREE_TYPE (op2));
           if (op3)
             {
-              fprintf (vect_dump, ",");
-              print_generic_expr (vect_dump, TREE_TYPE (op3), TDF_SLIM);
+              diag_printf (TDF_TREE, ",");
+              diag_generic_expr (TDF_SLIM, TREE_TYPE (op3));
             }
 
           if (op4)
             {
-              fprintf (vect_dump, ",");
-              print_generic_expr (vect_dump, TREE_TYPE (op4), TDF_SLIM);
+              diag_printf (TDF_TREE, ",");
+              diag_generic_expr (TDF_SLIM, TREE_TYPE (op4));
             }
         }
 
@@ -2460,9 +2473,9 @@ vect_get_known_peeling_cost (loop_vec_info loop_vi
     {
       *peel_iters_epilogue = vf/2;
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                            "epilogue peel iters set to vf/2 because "
-                            "loop iterations are unknown .");
+        diag_printf (TDF_TREE, "cost model: "
+                     "epilogue peel iters set to vf/2 because "
+                     "loop iterations are unknown .");
 
       /* If peeled iterations are known but number of scalar loop
          iterations are unknown, count a taken branch per peeled loop.  */
@@ -2519,7 +2532,7 @@ vect_estimate_min_profitable_iters (loop_vec_info
   if (!flag_vect_cost_model)
     {
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model disabled.");
+        diag_printf (TDF_TREE, "cost model disabled.");
       return 0;
     }
 
@@ -2530,8 +2543,8 @@ vect_estimate_min_profitable_iters (loop_vec_info
       vec_outside_cost +=
 	VEC_length (gimple, LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo));
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: Adding cost of checks for loop "
-                 "versioning to treat misalignment.\n");
+        diag_printf (TDF_TREE, "cost model: Adding cost of checks for loop "
+                     "versioning to treat misalignment.\n");
     }
 
   /* Requires loop versioning with alias checks.  */
@@ -2541,8 +2554,8 @@ vect_estimate_min_profitable_iters (loop_vec_info
       vec_outside_cost +=
         VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo));
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: Adding cost of checks for loop "
-                 "versioning aliasing.\n");
+        diag_printf (TDF_TREE, "cost model: Adding cost of checks for loop "
+                     "versioning aliasing.\n");
     }
 
   if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo)
@@ -2633,16 +2646,16 @@ vect_estimate_min_profitable_iters (loop_vec_info
     {
       peel_iters_prologue = vf/2;
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                 "prologue peel iters set to vf/2.");
+        diag_printf (TDF_TREE, "cost model: "
+                     "prologue peel iters set to vf/2.");
 
       /* If peeling for alignment is unknown, loop bound of main loop becomes
          unknown.  */
       peel_iters_epilogue = vf/2;
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                 "epilogue peel iters set to vf/2 because "
-                 "peeling for alignment is unknown .");
+        diag_printf (TDF_TREE, "cost model: "
+                     "epilogue peel iters set to vf/2 because "
+                     "peeling for alignment is unknown .");
 
       /* If peeled iterations are unknown, count a taken branch and a not taken
          branch per peeled loop. Even if scalar loop iterations are known,
@@ -2775,29 +2788,31 @@ vect_estimate_min_profitable_iters (loop_vec_info
   else
     {
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: the vector iteration cost = %d "
-		 "divided by the scalar iteration cost = %d "
-		 "is greater or equal to the vectorization factor = %d.",
-                 vec_inside_cost, scalar_single_iter_cost, vf);
+        diag_printf (TDF_TREE, "cost model: the vector iteration cost = %d "
+                     "divided by the scalar iteration cost = %d "
+                     "is greater or equal to the vectorization factor = %d.",
+                     vec_inside_cost, scalar_single_iter_cost, vf);
       return -1;
     }
 
   if (vect_print_dump_info (REPORT_COST))
     {
-      fprintf (vect_dump, "Cost model analysis: \n");
-      fprintf (vect_dump, "  Vector inside of loop cost: %d\n",
-	       vec_inside_cost);
-      fprintf (vect_dump, "  Vector outside of loop cost: %d\n",
-	       vec_outside_cost);
-      fprintf (vect_dump, "  Scalar iteration cost: %d\n",
-	       scalar_single_iter_cost);
-      fprintf (vect_dump, "  Scalar outside cost: %d\n", scalar_outside_cost);
-      fprintf (vect_dump, "  prologue iterations: %d\n",
-               peel_iters_prologue);
-      fprintf (vect_dump, "  epilogue iterations: %d\n",
-               peel_iters_epilogue);
-      fprintf (vect_dump, "  Calculated minimum iters for profitability: %d\n",
-	       min_profitable_iters);
+      diag_printf (TDF_TREE, "Cost model analysis: \n");
+      diag_printf (TDF_TREE, "  Vector inside of loop cost: %d\n",
+                   vec_inside_cost);
+      diag_printf (TDF_TREE, "  Vector outside of loop cost: %d\n",
+                   vec_outside_cost);
+      diag_printf (TDF_TREE, "  Scalar iteration cost: %d\n",
+                   scalar_single_iter_cost);
+      diag_printf (TDF_TREE, "  Scalar outside cost: %d\n",
+                   scalar_outside_cost);
+      diag_printf (TDF_TREE, "  prologue iterations: %d\n",
+                   peel_iters_prologue);
+      diag_printf (TDF_TREE, "  epilogue iterations: %d\n",
+                   peel_iters_epilogue);
+      diag_printf (TDF_TREE,
+                   "  Calculated minimum iters for profitability: %d\n",
+                   min_profitable_iters);
     }
 
   min_profitable_iters =
@@ -2809,8 +2824,8 @@ vect_estimate_min_profitable_iters (loop_vec_info
   min_profitable_iters--;
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "  Profitability threshold = %d\n",
-	     min_profitable_iters);
+    diag_printf (TDF_TREE, "  Profitability threshold = %d\n",
+                 min_profitable_iters);
 
   return min_profitable_iters;
 }
@@ -2870,8 +2885,8 @@ vect_model_reduction_cost (stmt_vec_info stmt_info
     {
       if (vect_print_dump_info (REPORT_COST))
         {
-          fprintf (vect_dump, "unsupported data-type ");
-          print_generic_expr (vect_dump, TREE_TYPE (reduction_op), TDF_SLIM);
+          diag_printf (TDF_TREE, "unsupported data-type ");
+          diag_generic_expr (TDF_SLIM, TREE_TYPE (reduction_op));
         }
       return false;
    }
@@ -2927,9 +2942,11 @@ vect_model_reduction_cost (stmt_vec_info stmt_info
   STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info) = outer_cost;
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_reduction_cost: inside_cost = %d, "
-             "outside_cost = %d .", STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
-             STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
+    diag_printf (TDF_TREE,
+                 "vect_model_reduction_cost: inside_cost = %d, "
+                 "outside_cost = %d .",
+                 STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
+                 STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
 
   return true;
 }
@@ -2950,9 +2967,10 @@ vect_model_induction_cost (stmt_vec_info stmt_info
     = 2 * vect_get_cost (scalar_to_vec);
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_induction_cost: inside_cost = %d, "
-             "outside_cost = %d .", STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
-             STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
+    diag_printf (TDF_TREE, "vect_model_induction_cost: inside_cost = %d, "
+                 "outside_cost = %d .",
+                 STMT_VINFO_INSIDE_OF_LOOP_COST (stmt_info),
+                 STMT_VINFO_OUTSIDE_OF_LOOP_COST (stmt_info));
 }
 
 
@@ -3082,8 +3100,8 @@ get_initial_def_for_induction (gimple iv_phi)
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "created new init_stmt: ");
-	      print_gimple_stmt (vect_dump, init_stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "created new init_stmt: ");
+	      diag_gimple_stmt (TDF_SLIM, init_stmt, 0);
 	    }
 	  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
 	}
@@ -3225,8 +3243,9 @@ get_initial_def_for_induction (gimple iv_phi)
 	  STMT_VINFO_VEC_STMT (stmt_vinfo) = new_stmt;
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "vector of inductions after inner-loop:");
-	      print_gimple_stmt (vect_dump, new_stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE,
+                           "vector of inductions after inner-loop:");
+	      diag_gimple_stmt (TDF_SLIM, new_stmt, 0);
 	    }
 	}
     }
@@ -3234,10 +3253,10 @@ get_initial_def_for_induction (gimple iv_phi)
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "transform induction: created def-use cycle: ");
-      print_gimple_stmt (vect_dump, induction_phi, 0, TDF_SLIM);
-      fprintf (vect_dump, "\n");
-      print_gimple_stmt (vect_dump, SSA_NAME_DEF_STMT (vec_def), 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "transform induction: created def-use cycle: ");
+      diag_gimple_stmt (TDF_SLIM, induction_phi, 0);
+      diag_printf (TDF_TREE, "\n");
+      diag_gimple_stmt (TDF_SLIM, SSA_NAME_DEF_STMT (vec_def), 0);
     }
 
   STMT_VINFO_VEC_STMT (phi_info) = induction_phi;
@@ -3640,12 +3659,11 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
 
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "transform reduction: created def-use"
-                                  " cycle: ");
-              print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
-              fprintf (vect_dump, "\n");
-              print_gimple_stmt (vect_dump, SSA_NAME_DEF_STMT (def), 0,
-                                 TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "transform reduction: created def-use cycle: ");
+              diag_gimple_stmt (TDF_SLIM, phi, 0);
+              diag_printf (TDF_TREE, "\n");
+              diag_gimple_stmt (TDF_SLIM, SSA_NAME_DEF_STMT (def), 0);
             }
 
           phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi));
@@ -3840,7 +3858,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
            v_out2 = reduc_expr <v_out1>  */
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Reduce using direct vector reduction.");
+        diag_printf (TDF_TREE, "Reduce using direct vector reduction.");
 
       vec_dest = vect_create_destination_var (scalar_dest, vectype);
       tmp = build1 (reduc_code, vectype, new_phi_result);
@@ -3890,7 +3908,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
                 }  */
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Reduce using vector shifts");
+            diag_printf (TDF_TREE, "Reduce using vector shifts");
 
           vec_dest = vect_create_destination_var (scalar_dest, vectype);
           new_temp = new_phi_result;
@@ -3930,7 +3948,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
                }  */
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Reduce using scalar code. ");
+            diag_printf (TDF_TREE, "Reduce using scalar code. ");
 
           vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1);
           FOR_EACH_VEC_ELT (gimple, new_phis, i, new_phi)
@@ -4020,7 +4038,7 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
       tree rhs;
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "extract scalar result");
+        diag_printf (TDF_TREE, "extract scalar result");
 
       if (BYTES_BIG_ENDIAN)
         bitpos = size_binop (MULT_EXPR,
@@ -4259,9 +4277,9 @@ vect_finalize_reduction:
                                loop_latch_edge (outer_loop), UNKNOWN_LOCATION);
                   if (vect_print_dump_info (REPORT_DETAILS))
                     {
-                      fprintf (vect_dump, "created double reduction phi "
-                                          "node: ");
-                      print_gimple_stmt (vect_dump, vect_phi, 0, TDF_SLIM);
+                      diag_printf (TDF_TREE, "created double reduction phi "
+                                   "node: ");
+                      diag_gimple_stmt (TDF_SLIM, vect_phi, 0);
                     }
 
                   vect_phi_res = PHI_RESULT (vect_phi);
@@ -4608,7 +4626,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!vectorizable_condition (stmt, gsi, NULL, ops[reduc_index], 0, NULL))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "unsupported condition in reduction");
+            diag_printf (TDF_TREE, "unsupported condition in reduction");
 
             return false;
         }
@@ -4622,7 +4640,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!optab)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no optab.");
+            diag_printf (TDF_TREE, "no optab.");
 
           return false;
         }
@@ -4630,7 +4648,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (optab_handler (optab, vec_mode) == CODE_FOR_nothing)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "op not supported by target.");
+            diag_printf (TDF_TREE, "op not supported by target.");
 
           if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
               || LOOP_VINFO_VECT_FACTOR (loop_vinfo)
@@ -4638,7 +4656,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
             return false;
 
           if (vect_print_dump_info (REPORT_DETAILS))
-  	    fprintf (vect_dump, "proceeding using word mode.");
+  	    diag_printf (TDF_TREE, "proceeding using word mode.");
         }
 
       /* Worthwhile without SIMD support?  */
@@ -4647,7 +4665,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
    	     < vect_min_worthwhile_factor (code))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "not worthwhile without SIMD support.");
+	    diag_printf (TDF_TREE, "not worthwhile without SIMD support.");
 
           return false;
         }
@@ -4727,7 +4745,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!reduc_optab)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no optab for reduction.");
+            diag_printf (TDF_TREE, "no optab for reduction.");
 
           epilog_reduc_code = ERROR_MARK;
         }
@@ -4736,7 +4754,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
           && optab_handler (reduc_optab, vec_mode) == CODE_FOR_nothing)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc op not supported by target.");
+            diag_printf (TDF_TREE, "reduc op not supported by target.");
 
           epilog_reduc_code = ERROR_MARK;
         }
@@ -4746,7 +4764,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (!nested_cycle || double_reduc)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no reduc code for scalar code.");
+            diag_printf (TDF_TREE, "no reduc code for scalar code.");
 
           return false;
         }
@@ -4755,7 +4773,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
   if (double_reduc && ncopies > 1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in double reduction");
+        diag_printf (TDF_TREE, "multiple types in double reduction");
 
       return false;
     }
@@ -4773,7 +4791,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       else
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "invalid types in dot-prod");
+            diag_printf (TDF_TREE, "invalid types in dot-prod");
 
           return false;
         }
@@ -4790,7 +4808,7 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform reduction.");
+    diag_printf (TDF_TREE, "transform reduction.");
 
   /* FORNOW: Multiple types are not supported for condition.  */
   if (code == COND_EXPR)
@@ -5076,7 +5094,7 @@ vectorizable_induction (gimple phi, gimple_stmt_it
       if (ncopies > 1)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple types in nested loop.");
+	    diag_printf (TDF_TREE, "multiple types in nested loop.");
 	  return false;
 	}
 
@@ -5099,8 +5117,9 @@ vectorizable_induction (gimple phi, gimple_stmt_it
 		&& !STMT_VINFO_LIVE_P (exit_phi_vinfo)))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "inner-loop induction only used outside "
-			 "of the outer vectorized loop.");
+		diag_printf (TDF_TREE,
+                             "inner-loop induction only used outside "
+                             "of the outer vectorized loop.");
 	      return false;
 	    }
 	}
@@ -5122,7 +5141,7 @@ vectorizable_induction (gimple phi, gimple_stmt_it
     {
       STMT_VINFO_TYPE (stmt_info) = induc_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_induction ===");
+        diag_printf (TDF_TREE, "=== vectorizable_induction ===");
       vect_model_induction_cost (stmt_info, ncopies);
       return true;
     }
@@ -5130,7 +5149,7 @@ vectorizable_induction (gimple phi, gimple_stmt_it
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform induction phi.");
+    diag_printf (TDF_TREE, "transform induction phi.");
 
   vec_def = get_initial_def_for_induction (phi);
   *vec_stmt = SSA_NAME_DEF_STMT (vec_def);
@@ -5195,7 +5214,7 @@ vectorizable_live_operation (gimple stmt,
 				  &dt))
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "use not simple.");
+            diag_printf (TDF_TREE, "use not simple.");
           return false;
         }
 
@@ -5233,7 +5252,7 @@ vect_loop_kill_debug_uses (struct loop *loop, gimp
 	      if (gimple_debug_bind_p (ustmt))
 		{
 		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "killing debug use");
+		    diag_printf (TDF_TREE, "killing debug use");
 
 		  gimple_debug_bind_reset_value (ustmt);
 		  update_stmt (ustmt);
@@ -5272,7 +5291,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   int th;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vec_transform_loop ===");
+    diag_printf (TDF_TREE, "=== vec_transform_loop ===");
 
   /* Use the more conservative vectorization threshold.  If the number
      of iterations is constant assume the cost check has been performed
@@ -5286,8 +5305,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
       && !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
       if (vect_print_dump_info (REPORT_COST))
-	fprintf (vect_dump,
-		 "Profitability threshold is %d loop iterations.", th);
+	diag_printf (TDF_TREE,
+                     "Profitability threshold is %d loop iterations.", th);
       check_profitability = true;
     }
 
@@ -5348,8 +5367,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	  phi = gsi_stmt (si);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "------>vectorizing phi: ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "------>vectorizing phi: ");
+	      diag_gimple_stmt (TDF_SLIM, phi, 0);
 	    }
 	  stmt_info = vinfo_for_stmt (phi);
 	  if (!stmt_info)
@@ -5365,12 +5384,12 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	  if ((TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info))
 	        != (unsigned HOST_WIDE_INT) vectorization_factor)
 	      && vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple-types.");
+	    diag_printf (TDF_TREE, "multiple-types.");
 
 	  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "transform phi.");
+		diag_printf (TDF_TREE, "transform phi.");
 	      vect_transform_stmt (phi, NULL, NULL, NULL, NULL);
 	    }
 	}
@@ -5387,8 +5406,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "------>vectorizing statement: ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "------>vectorizing statement: ");
+	      diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  stmt_info = vinfo_for_stmt (stmt);
@@ -5458,10 +5477,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
 			{
-			  fprintf (vect_dump, "==> vectorizing pattern def"
-					      " stmt: ");
-			  print_gimple_stmt (vect_dump, pattern_def_stmt, 0,
-					     TDF_SLIM);
+			  diag_printf (TDF_TREE,
+                                       "==> vectorizing pattern def stmt: ");
+			  diag_gimple_stmt (TDF_SLIM, pattern_def_stmt, 0);
 			}
 
 		      stmt = pattern_def_stmt;
@@ -5485,7 +5503,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
               && vect_print_dump_info (REPORT_DETAILS))
 	    /* For SLP VF is set according to unrolling factor, and not to
 	       vector size, hence for SLP this print is not valid.  */
-            fprintf (vect_dump, "multiple-types.");
+            diag_printf (TDF_TREE, "multiple-types.");
 
 	  /* SLP. Schedule all the SLP instances when the first SLP stmt is
 	     reached.  */
@@ -5496,7 +5514,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		  slp_scheduled = true;
 
 		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "=== scheduling SLP instances ===");
+		    diag_printf (TDF_TREE,
+                                 "=== scheduling SLP instances ===");
 
 		  vect_schedule_slp (loop_vinfo, NULL);
 		}
@@ -5515,10 +5534,11 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 
 	  /* -------- vectorize statement ------------ */
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "transform statement.");
+	    diag_printf (TDF_TREE, "transform statement.");
 
 	  grouped_store = false;
-	  is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL, NULL);
+	  is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL,
+                                          NULL);
           if (is_store)
             {
 	      if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
@@ -5558,7 +5578,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   update_ssa (TODO_update_ssa);
 
   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "LOOP VECTORIZED.");
+    diag_printf (TDF_TREE, "LOOP VECTORIZED.");
   if (loop->inner && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "OUTER LOOP VECTORIZED.");
+    diag_printf (TDF_TREE, "OUTER LOOP VECTORIZED.");
 }
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c	(revision 188325)
+++ tree-vect-data-refs.c	(working copy)
@@ -61,22 +61,23 @@ vect_lanes_optab_supported_p (const char *name, co
   if (array_mode == BLKmode)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "no array mode for %s[" HOST_WIDE_INT_PRINT_DEC "]",
-		 GET_MODE_NAME (mode), count);
+	diag_printf (TDF_TREE,
+                     "no array mode for %s[" HOST_WIDE_INT_PRINT_DEC "]",
+                     GET_MODE_NAME (mode), count);
       return false;
     }
 
   if (convert_optab_handler (optab, array_mode, mode) == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "cannot use %s<%s><%s>",
-		 name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+	diag_printf (TDF_TREE, "cannot use %s<%s><%s>",
+                     name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
       return false;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "can use %s<%s><%s>",
-	     name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+    diag_printf (TDF_TREE, "can use %s<%s><%s>",
+                 name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
 
   return true;
 }
@@ -438,10 +439,10 @@ vect_check_interleaving (struct data_reference *dr
 	  vect_update_interleaving_chain (drb, dra);
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "Detected interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      diag_printf (TDF_TREE, "Detected interleaving ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (dra));
+	      diag_printf (TDF_TREE, " and ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 	  return true;
 	}
@@ -460,10 +461,10 @@ vect_check_interleaving (struct data_reference *dr
 	  vect_update_interleaving_chain (dra, drb);
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "Detected interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      diag_printf (TDF_TREE, "Detected interleaving ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (dra));
+	      diag_printf (TDF_TREE, " and ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 	  return true;
 	}
@@ -521,16 +522,17 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
 
   if (vect_print_dump_info (REPORT_DR_DETAILS))
     {
-      fprintf (vect_dump, "mark for run-time aliasing test between ");
-      print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
-      fprintf (vect_dump, " and ");
-      print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+      diag_printf (TDF_TREE, "mark for run-time aliasing test between ");
+      diag_generic_expr (TDF_SLIM, DR_REF (DDR_A (ddr)));
+      diag_printf (TDF_TREE, " and ");
+      diag_generic_expr (TDF_SLIM, DR_REF (DDR_B (ddr)));
     }
 
   if (optimize_loop_nest_for_size_p (loop))
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not supported when optimizing for size.");
+	diag_printf (TDF_TREE,
+                     "versioning not supported when optimizing for size.");
       return false;
     }
 
@@ -538,7 +540,8 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
   if (loop->inner)
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not yet supported for outer-loops.");
+	diag_printf (TDF_TREE,
+                     "versioning not yet supported for outer-loops.");
       return false;
     }
 
@@ -548,8 +551,9 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
       || TREE_CODE (DR_STEP (DDR_B (ddr))) != INTEGER_CST)
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not yet supported for non-constant "
-		 "step");
+	diag_printf (TDF_TREE,
+                     "versioning not yet supported for non-constant "
+                     "step");
       return false;
     }
 
@@ -604,11 +608,11 @@ vect_analyze_data_ref_dependence (struct data_depe
         {
           if (vect_print_dump_info (REPORT_DR_DETAILS))
             {
-              fprintf (vect_dump, "versioning for alias required: "
+              diag_printf (TDF_TREE, "versioning for alias required: "
                                   "can't determine dependence between ");
-              print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-              fprintf (vect_dump, " and ");
-              print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+              diag_generic_expr (TDF_SLIM, DR_REF (dra));
+              diag_printf (TDF_TREE, " and ");
+              diag_generic_expr (TDF_SLIM, DR_REF (drb));
             }
 
           /* Add to list of ddrs that need to be tested at run-time.  */
@@ -627,10 +631,10 @@ vect_analyze_data_ref_dependence (struct data_depe
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "can't determine dependence between ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          diag_printf (TDF_TREE, "can't determine dependence between ");
+          diag_generic_expr (TDF_SLIM, DR_REF (dra));
+          diag_printf (TDF_TREE, " and ");
+          diag_generic_expr (TDF_SLIM, DR_REF (drb));
         }
 
       /* We do not vectorize basic blocks with write-write dependencies.  */
@@ -655,17 +659,17 @@ vect_analyze_data_ref_dependence (struct data_depe
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "determined dependence between ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          diag_printf (TDF_TREE, "determined dependence between ");
+          diag_generic_expr (TDF_SLIM, DR_REF (dra));
+          diag_printf (TDF_TREE, " and ");
+          diag_generic_expr (TDF_SLIM, DR_REF (drb));
         }
 
       /* Do not vectorize basic blcoks with write-write dependences.  */
       if (DR_IS_WRITE (dra) && DR_IS_WRITE (drb))
         return true;
 
-      /* Check if this dependence is allowed in basic block vectorization.  */ 
+      /* Check if this dependence is allowed in basic block vectorization.  */
       return vect_drs_dependent_in_basic_block (dra, drb);
     }
 
@@ -674,10 +678,11 @@ vect_analyze_data_ref_dependence (struct data_depe
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
         {
-          fprintf (vect_dump, "versioning for alias required: bad dist vector for ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          diag_printf (TDF_TREE,
+                       "versioning for alias required: bad dist vector for ");
+          diag_generic_expr (TDF_SLIM, DR_REF (dra));
+          diag_printf (TDF_TREE, " and ");
+          diag_generic_expr (TDF_SLIM, DR_REF (drb));
         }
       /* Add to list of ddrs that need to be tested at run-time.  */
       return !vect_mark_for_runtime_alias_test (ddr, loop_vinfo);
@@ -689,16 +694,16 @@ vect_analyze_data_ref_dependence (struct data_depe
       int dist = dist_v[loop_depth];
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "dependence distance  = %d.", dist);
+	diag_printf (TDF_TREE, "dependence distance  = %d.", dist);
 
       if (dist == 0)
 	{
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "dependence distance == 0 between ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      diag_printf (TDF_TREE, "dependence distance == 0 between ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (dra));
+	      diag_printf (TDF_TREE, " and ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 
           /* For interleaving, mark that there is a read-write dependency if
@@ -720,7 +725,7 @@ vect_analyze_data_ref_dependence (struct data_depe
 	     reversed (to make distance vector positive), and the actual
 	     distance is negative.  */
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "dependence distance negative.");
+	    diag_printf (TDF_TREE, "dependence distance negative.");
 	  continue;
 	}
 
@@ -731,8 +736,9 @@ vect_analyze_data_ref_dependence (struct data_depe
 	     vectorization factor.  */
 	  *max_vf = abs (dist);
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "adjusting maximal vectorization factor to %i",
-		     *max_vf);
+	    diag_printf (TDF_TREE,
+                         "adjusting maximal vectorization factor to %i",
+                         *max_vf);
 	}
 
       if (abs (dist) >= *max_vf)
@@ -740,17 +746,17 @@ vect_analyze_data_ref_dependence (struct data_depe
 	  /* Dependence distance does not create dependence, as far as
 	     vectorization is concerned, in this case.  */
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "dependence distance >= VF.");
+	    diag_printf (TDF_TREE, "dependence distance >= VF.");
 	  continue;
 	}
 
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 	{
-	  fprintf (vect_dump, "not vectorized, possible dependence "
-    		              "between data-refs ");
-	  print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	  fprintf (vect_dump, " and ");
-	  print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	  diag_printf (TDF_TREE, "not vectorized, possible dependence "
+                       "between data-refs ");
+	  diag_generic_expr (TDF_SLIM, DR_REF (dra));
+	  diag_printf (TDF_TREE, " and ");
+	  diag_generic_expr (TDF_SLIM, DR_REF (drb));
 	}
 
       return true;
@@ -774,7 +780,7 @@ vect_analyze_data_ref_dependences (loop_vec_info l
   struct data_dependence_relation *ddr;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_dependences ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_dependences ===");
 
   if (loop_vinfo)
     ddrs = LOOP_VINFO_DDRS (loop_vinfo);
@@ -816,7 +822,7 @@ vect_compute_data_ref_alignment (struct data_refer
   tree aligned_to, alignment;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_compute_data_ref_alignment:");
+    diag_printf (TDF_TREE, "vect_compute_data_ref_alignment:");
 
   if (loop_vinfo)
     loop = LOOP_VINFO_LOOP (loop_vinfo);
@@ -848,7 +854,7 @@ vect_compute_data_ref_alignment (struct data_refer
       if (dr_step % GET_MODE_SIZE (TYPE_MODE (vectype)) == 0)
         {
           if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "inner step divides the vector-size.");
+            diag_printf (TDF_TREE, "inner step divides the vector-size.");
 	  misalign = STMT_VINFO_DR_INIT (stmt_info);
 	  aligned_to = STMT_VINFO_DR_ALIGNED_TO (stmt_info);
 	  base_addr = STMT_VINFO_DR_BASE_ADDRESS (stmt_info);
@@ -856,7 +862,8 @@ vect_compute_data_ref_alignment (struct data_refer
       else
 	{
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "inner step doesn't divide the vector-size.");
+	    diag_printf (TDF_TREE,
+                         "inner step doesn't divide the vector-size.");
 	  misalign = NULL_TREE;
 	}
     }
@@ -869,8 +876,8 @@ vect_compute_data_ref_alignment (struct data_refer
     {
       if (vect_print_dump_info (REPORT_ALIGNMENT))
 	{
-	  fprintf (vect_dump, "Unknown alignment for access: ");
-	  print_generic_expr (vect_dump, base, TDF_SLIM);
+	  diag_printf (TDF_TREE, "Unknown alignment for access: ");
+	  diag_generic_expr (TDF_SLIM, base);
 	}
       return true;
     }
@@ -898,8 +905,8 @@ vect_compute_data_ref_alignment (struct data_refer
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "can't force alignment of ref: ");
-	      print_generic_expr (vect_dump, ref, TDF_SLIM);
+	      diag_printf (TDF_TREE, "can't force alignment of ref: ");
+	      diag_generic_expr (TDF_SLIM, ref);
 	    }
 	  return true;
 	}
@@ -909,8 +916,8 @@ vect_compute_data_ref_alignment (struct data_refer
 	 the analysis phase, before deciding to vectorize the loop.  */
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "force alignment of ");
-          print_generic_expr (vect_dump, ref, TDF_SLIM);
+          diag_printf (TDF_TREE, "force alignment of ");
+          diag_generic_expr (TDF_SLIM, ref);
         }
 
       DECL_ALIGN (base) = TYPE_ALIGN (vectype);
@@ -942,7 +949,7 @@ vect_compute_data_ref_alignment (struct data_refer
     {
       /* Negative or overflowed misalignment value.  */
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "unexpected misalign value");
+	diag_printf (TDF_TREE, "unexpected misalign value");
       return false;
     }
 
@@ -950,8 +957,9 @@ vect_compute_data_ref_alignment (struct data_refer
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
-      print_generic_expr (vect_dump, ref, TDF_SLIM);
+      diag_printf (TDF_TREE,
+                   "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
+      diag_generic_expr (TDF_SLIM, ref);
     }
 
   return true;
@@ -1048,7 +1056,7 @@ vect_update_misalignment_for_peel (struct data_ref
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "Setting misalignment to -1.");
+    diag_printf (TDF_TREE, "Setting misalignment to -1.");
   SET_DR_MISALIGNMENT (dr, -1);
 }
 
@@ -1094,19 +1102,19 @@ vect_verify_datarefs_alignment (loop_vec_info loop
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
               if (DR_IS_READ (dr))
-                fprintf (vect_dump,
-                         "not vectorized: unsupported unaligned load.");
+                diag_printf (TDF_TREE,
+                             "not vectorized: unsupported unaligned load.");
               else
-                fprintf (vect_dump,
-                         "not vectorized: unsupported unaligned store.");
+                diag_printf (TDF_TREE,
+                             "not vectorized: unsupported unaligned store.");
 
-              print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
+              diag_generic_expr (TDF_SLIM, DR_REF (dr));
             }
           return false;
         }
       if (supportable_dr_alignment != dr_aligned
           && vect_print_dump_info (REPORT_ALIGNMENT))
-        fprintf (vect_dump, "Vectorizing an unaligned access.");
+        diag_printf (TDF_TREE, "Vectorizing an unaligned access.");
     }
   return true;
 }
@@ -1151,13 +1159,16 @@ vector_alignment_reachable_p (struct data_referenc
 		int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
-	  fprintf (vect_dump, ". misalignment = %d. ", DR_MISALIGNMENT (dr));
+	  diag_printf (TDF_TREE,
+                       "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
+	  diag_printf (TDF_TREE,
+                       ". misalignment = %d. ", DR_MISALIGNMENT (dr));
 	}
       if (DR_MISALIGNMENT (dr) % elmsize)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "data size does not divide the misalignment.\n");
+	    diag_printf (TDF_TREE,
+                         "data size does not divide the misalignment.\n");
 	  return false;
 	}
     }
@@ -1171,7 +1182,8 @@ vector_alignment_reachable_p (struct data_referenc
 	is_packed = true;
 
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Unknown misalignment, is_packed = %d",is_packed);
+	diag_printf (TDF_TREE,
+                     "Unknown misalignment, is_packed = %d",is_packed);
       if (targetm.vectorize.vector_alignment_reachable (type, is_packed))
 	return true;
       else
@@ -1208,8 +1220,9 @@ vect_get_data_access_cost (struct data_reference *
     }
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_get_data_access_cost: inside_cost = %d, "
-             "outside_cost = %d.", *inside_cost, *outside_cost);
+    diag_printf (TDF_TREE,
+                 "vect_get_data_access_cost: inside_cost = %d, "
+                 "outside_cost = %d.", *inside_cost, *outside_cost);
 }
 
 
@@ -1480,7 +1493,7 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
   unsigned int nelements, mis, same_align_drs_max = 0;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_enhance_data_refs_alignment ===");
+    diag_printf (TDF_TREE, "=== vect_enhance_data_refs_alignment ===");
 
   /* While cost model enhancements are expected in the future, the high level
      view of the code at this time is as follows:
@@ -1534,7 +1547,7 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
       if (STMT_VINFO_STRIDE_LOAD_P (stmt_info))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "strided load prevents peeling");
+	    diag_printf (TDF_TREE, "strided load prevents peeling");
 	  do_peeling = false;
 	  break;
 	}
@@ -1649,8 +1662,8 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
           if (!aligned_access_p (dr))
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "vector alignment may not be reachable");
-
+                diag_printf (TDF_TREE,
+                             "vector alignment may not be reachable");
               break;
             }
         }
@@ -1786,7 +1799,7 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
 	    npeel /= GROUP_SIZE (stmt_info);
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Try peeling by %d", npeel);
+            diag_printf (TDF_TREE, "Try peeling by %d", npeel);
         }
 
       /* Ensure that all data refs can be vectorized after the peel.  */
@@ -1851,10 +1864,12 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
             LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo) = DR_MISALIGNMENT (dr0);
 	  SET_DR_MISALIGNMENT (dr0, 0);
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "Alignment of access forced using peeling.");
+            diag_printf (TDF_TREE,
+                         "Alignment of access forced using peeling.");
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Peeling for alignment will be applied.");
+            diag_printf (TDF_TREE,
+                         "Peeling for alignment will be applied.");
 
 	  stat = vect_verify_datarefs_alignment (loop_vinfo, NULL);
 	  gcc_assert (stat);
@@ -1960,11 +1975,13 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
           dr = STMT_VINFO_DATA_REF (stmt_info);
 	  SET_DR_MISALIGNMENT (dr, 0);
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "Alignment of access forced using versioning.");
+            diag_printf (TDF_TREE,
+                         "Alignment of access forced using versioning.");
         }
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Versioning for alignment will be applied.");
+        diag_printf (TDF_TREE,
+                     "Versioning for alignment will be applied.");
 
       /* Peeling and versioning can't be done together at this time.  */
       gcc_assert (! (do_peeling && do_versioning));
@@ -2029,7 +2046,7 @@ vect_find_same_alignment_drs (struct data_dependen
       int dist = dist_v[loop_depth];
 
       if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "dependence distance  = %d.", dist);
+	diag_printf (TDF_TREE, "dependence distance  = %d.", dist);
 
       /* Same loop iteration.  */
       if (dist == 0
@@ -2039,13 +2056,14 @@ vect_find_same_alignment_drs (struct data_dependen
 	  VEC_safe_push (dr_p, heap, STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_a), drb);
 	  VEC_safe_push (dr_p, heap, STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_b), dra);
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "accesses have the same alignment.");
+	    diag_printf (TDF_TREE, "accesses have the same alignment.");
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "dependence distance modulo vf == 0 between ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      diag_printf (TDF_TREE,
+                           "dependence distance modulo vf == 0 between ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (dra));
+	      diag_printf (TDF_TREE, " and ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (drb));
 	    }
 	}
     }
@@ -2062,7 +2080,7 @@ vect_analyze_data_refs_alignment (loop_vec_info lo
                                   bb_vec_info bb_vinfo)
 {
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_refs_alignment ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_data_refs_alignment ===");
 
   /* Mark groups of data references with same alignment using
      data dependence information.  */
@@ -2079,8 +2097,8 @@ vect_analyze_data_refs_alignment (loop_vec_info lo
   if (!vect_compute_data_refs_alignment (loop_vinfo, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	fprintf (vect_dump,
-		 "not vectorized: can't calculate alignment for data ref.");
+	diag_printf (TDF_TREE,
+                     "not vectorized: can't calculate alignment for data ref.");
       return false;
     }
 
@@ -2132,22 +2150,24 @@ vect_analyze_group_access (struct data_reference *
 	  GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
 	  if (vect_print_dump_info (REPORT_DR_DETAILS))
 	    {
-	      fprintf (vect_dump, "Detected single element interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
-	      fprintf (vect_dump, " step ");
-	      print_generic_expr (vect_dump, step, TDF_SLIM);
+	      diag_printf (TDF_TREE,
+                           "Detected single element interleaving ");
+	      diag_generic_expr (TDF_SLIM, DR_REF (dr));
+	      diag_printf (TDF_TREE, " step ");
+	      diag_generic_expr (TDF_SLIM, step);
 	    }
 
 	  if (loop_vinfo)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "Data access with gaps requires scalar "
-				    "epilogue loop");
+		diag_printf (TDF_TREE,
+                             "Data access with gaps requires scalar "
+                             "epilogue loop");
               if (loop->inner)
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Peeling for outer loop is not"
-                                        " supported");
+                    diag_printf (TDF_TREE, "Peeling for outer loop is not"
+                                 " supported");
                   return false;
                 }
 
@@ -2159,8 +2179,8 @@ vect_analyze_group_access (struct data_reference *
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
- 	  fprintf (vect_dump, "not consecutive access ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+ 	  diag_printf (TDF_TREE, "not consecutive access ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       if (bb_vinfo)
@@ -2169,7 +2189,7 @@ vect_analyze_group_access (struct data_reference *
           STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) = false;
           return true;
         }
-    
+
       return false;
     }
 
@@ -2197,7 +2217,8 @@ vect_analyze_group_access (struct data_reference *
               if (DR_IS_WRITE (data_ref))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Two store stmts share the same dr.");
+                    diag_printf (TDF_TREE,
+                                 "Two store stmts share the same dr.");
                   return false;
                 }
 
@@ -2207,8 +2228,8 @@ vect_analyze_group_access (struct data_reference *
                   || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump,
-                             "READ_WRITE dependence in interleaving.");
+                    diag_printf (TDF_TREE,
+                                 "READ_WRITE dependence in interleaving.");
                   return false;
                 }
 
@@ -2227,7 +2248,8 @@ vect_analyze_group_access (struct data_reference *
           if (tree_int_cst_compare (step, next_step))
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "not consecutive access in interleaving");
+                diag_printf (TDF_TREE,
+                             "not consecutive access in interleaving");
               return false;
             }
 
@@ -2243,7 +2265,7 @@ vect_analyze_group_access (struct data_reference *
 	      if (DR_IS_WRITE (data_ref))
 		{
 		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "interleaved store with gaps");
+		    diag_printf (TDF_TREE, "interleaved store with gaps");
 		  return false;
 		}
 
@@ -2272,8 +2294,9 @@ vect_analyze_group_access (struct data_reference *
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "interleaving size is greater than step for ");
-              print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "interleaving size is greater than step for ");
+              diag_generic_expr (TDF_SLIM, DR_REF (dr));
             }
           return false;
         }
@@ -2293,7 +2316,7 @@ vect_analyze_group_access (struct data_reference *
           else
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "interleaved store with gaps");
+                diag_printf (TDF_TREE, "interleaved store with gaps");
               return false;
             }
         }
@@ -2303,11 +2326,11 @@ vect_analyze_group_access (struct data_reference *
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "step is not a multiple of type size: step ");
-              print_generic_expr (vect_dump, step, TDF_SLIM);
-              fprintf (vect_dump, " size ");
-              print_generic_expr (vect_dump, TYPE_SIZE_UNIT (scalar_type),
-                                  TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "step is not a multiple of type size: step ");
+              diag_generic_expr (TDF_SLIM, step);
+              diag_printf (TDF_TREE, " size ");
+              diag_generic_expr (TDF_SLIM, TYPE_SIZE_UNIT (scalar_type));
             }
           return false;
         }
@@ -2317,7 +2340,8 @@ vect_analyze_group_access (struct data_reference *
 
       GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Detected interleaving of size %d", (int)groupsize);
+        diag_printf (TDF_TREE,
+                     "Detected interleaving of size %d", (int)groupsize);
 
       /* SLP: create an SLP data structure for every interleaving group of
 	 stores for further analysis in vect_analyse_slp.  */
@@ -2335,12 +2359,13 @@ vect_analyze_group_access (struct data_reference *
       if (groupsize - last_accessed_element > 0 && loop_vinfo)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "Data access with gaps requires scalar "
-				"epilogue loop");
+	    diag_printf (TDF_TREE, "Data access with gaps requires scalar "
+                         "epilogue loop");
           if (loop->inner)
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Peeling for outer loop is not supported");
+                diag_printf (TDF_TREE,
+                             "Peeling for outer loop is not supported");
               return false;
             }
 
@@ -2372,7 +2397,7 @@ vect_analyze_data_ref_access (struct data_referenc
   if (loop_vinfo && !step)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data-ref access in loop");
+	diag_printf (TDF_TREE, "bad data-ref access in loop");
       return false;
     }
 
@@ -2394,7 +2419,7 @@ vect_analyze_data_ref_access (struct data_referenc
       if (integer_zerop (step))
 	{
 	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "zero step in outer loop.");
+	    diag_printf (TDF_TREE, "zero step in outer loop.");
 	  if (DR_IS_READ (dr))
   	    return true;
 	  else
@@ -2419,7 +2444,7 @@ vect_analyze_data_ref_access (struct data_referenc
   if (loop && nested_in_vect_loop_p (loop, stmt))
     {
       if (vect_print_dump_info (REPORT_ALIGNMENT))
-	fprintf (vect_dump, "grouped access in outer loop.");
+	diag_printf (TDF_TREE, "grouped access in outer loop.");
       return false;
     }
 
@@ -2449,7 +2474,7 @@ vect_analyze_data_ref_accesses (loop_vec_info loop
   struct data_reference *dr;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_ref_accesses ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_data_ref_accesses ===");
 
   if (loop_vinfo)
     datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
@@ -2461,7 +2486,8 @@ vect_analyze_data_ref_accesses (loop_vec_info loop
         && !vect_analyze_data_ref_access (dr))
       {
 	if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	  fprintf (vect_dump, "not vectorized: complicated access pattern.");
+	  diag_printf (TDF_TREE,
+                       "not vectorized: complicated access pattern.");
 
         if (bb_vinfo)
           {
@@ -2490,7 +2516,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info
   unsigned i, j;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_prune_runtime_alias_test_list ===");
+    diag_printf (TDF_TREE, "=== vect_prune_runtime_alias_test_list ===");
 
   for (i = 0; i < VEC_length (ddr_p, ddrs); )
     {
@@ -2508,14 +2534,14 @@ vect_prune_runtime_alias_test_list (loop_vec_info
 	    {
 	      if (vect_print_dump_info (REPORT_DR_DETAILS))
 		{
-		  fprintf (vect_dump, "found equal ranges ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr_i)), TDF_SLIM);
-		  fprintf (vect_dump, ", ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr_i)), TDF_SLIM);
-		  fprintf (vect_dump, " and ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr_j)), TDF_SLIM);
-		  fprintf (vect_dump, ", ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr_j)), TDF_SLIM);
+		  diag_printf (TDF_TREE, "found equal ranges ");
+		  diag_generic_expr (TDF_SLIM, DR_REF (DDR_A (ddr_i)));
+		  diag_printf (TDF_TREE, ", ");
+		  diag_generic_expr (TDF_SLIM, DR_REF (DDR_B (ddr_i)));
+		  diag_printf (TDF_TREE, " and ");
+		  diag_generic_expr (TDF_SLIM, DR_REF (DDR_A (ddr_j)));
+		  diag_printf (TDF_TREE, ", ");
+		  diag_generic_expr (TDF_SLIM, DR_REF (DDR_B (ddr_j)));
 		}
 	      found = true;
 	      break;
@@ -2535,9 +2561,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info
     {
       if (vect_print_dump_info (REPORT_DR_DETAILS))
 	{
-	  fprintf (vect_dump,
-		   "disable versioning for alias - max number of generated "
-		   "checks exceeded.");
+	  diag_printf (TDF_TREE,
+                       "disable versioning for alias - max number of generated "
+                       "checks exceeded.");
 	}
 
       VEC_truncate (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), 0);
@@ -2821,7 +2847,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
   bool res, stop_bb_analysis = false;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_refs ===\n");
+    diag_printf (TDF_TREE, "=== vect_analyze_data_refs ===\n");
 
   if (loop_vinfo)
     {
@@ -2835,8 +2861,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (!res)
 	{
 	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: loop contains function calls"
-		     " or data references that cannot be analyzed");
+	    diag_printf (TDF_TREE,
+                         "not vectorized: loop contains function calls"
+                         " or data references that cannot be analyzed");
 	  return false;
 	}
 
@@ -2866,8 +2893,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 				    &BB_VINFO_DDRS (bb_vinfo), NULL, true))
 	{
 	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: basic block contains function"
-		     " calls or data references that cannot be analyzed");
+	    diag_printf (TDF_TREE,
+                         "not vectorized: basic block contains function"
+                         " calls or data references that cannot be analyzed");
 	  return false;
 	}
 
@@ -2888,7 +2916,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (!dr || !DR_REF (dr))
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: unhandled data-ref ");
+	    diag_printf (TDF_TREE, "not vectorized: unhandled data-ref ");
 
           return false;
         }
@@ -2935,9 +2963,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump, "not vectorized: data ref analysis "
-				      "failed ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE, "not vectorized: data ref analysis "
+                               "failed ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      if (bb_vinfo)
@@ -2954,8 +2982,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (TREE_CODE (DR_BASE_ADDRESS (dr)) == INTEGER_CST)
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump, "not vectorized: base addr of dr is a "
-                     "constant");
+            diag_printf (TDF_TREE, "not vectorized: base addr of dr is a "
+                         "constant");
 
           if (bb_vinfo)
             {
@@ -2973,8 +3001,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump, "not vectorized: volatile type ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE, "not vectorized: volatile type ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -2991,9 +3019,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump, "not vectorized: statement can throw an "
-                       "exception ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "not vectorized: statement can throw an "
+                           "exception ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -3013,9 +3042,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	{
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump, "not vectorized: statement is bitfield "
-                       "access ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE, "not vectorized: statement is bitfield "
+                           "access ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -3038,8 +3067,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	{
 	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 	    {
-	      fprintf (vect_dump, "not vectorized: dr in a call ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "not vectorized: dr in a call ");
+	      diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  if (bb_vinfo)
@@ -3080,8 +3109,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "analyze in outer-loop: ");
-	      print_generic_expr (vect_dump, inner_base, TDF_SLIM);
+	      diag_printf (TDF_TREE, "analyze in outer-loop: ");
+	      diag_generic_expr (TDF_SLIM, inner_base);
 	    }
 
 	  outer_base = get_inner_reference (inner_base, &pbitsize, &pbitpos,
@@ -3091,7 +3120,7 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	  if (pbitpos % BITS_PER_UNIT != 0)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "failed: bit offset alignment.\n");
+		diag_printf (TDF_TREE, "failed: bit offset alignment.\n");
 	      return false;
 	    }
 
@@ -3100,7 +3129,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
                           &base_iv, false))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "failed: evolution of base is not affine.\n");
+		diag_printf (TDF_TREE,
+                             "failed: evolution of base is not affine.\n");
 	      return false;
 	    }
 
@@ -3122,7 +3152,8 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
                                &offset_iv, false))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-	        fprintf (vect_dump, "evolution of offset is not affine.\n");
+	        diag_printf (TDF_TREE,
+                             "evolution of offset is not affine.\n");
 	      return false;
 	    }
 
@@ -3147,16 +3178,17 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "\touter base_address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_BASE_ADDRESS (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter offset from base address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_OFFSET (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter constant offset from base address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_INIT (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter step: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_STEP (stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter aligned to: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_ALIGNED_TO (stmt_info), TDF_SLIM);
+	      diag_printf (TDF_TREE, "\touter base_address: ");
+	      diag_generic_expr (TDF_SLIM, STMT_VINFO_DR_BASE_ADDRESS (stmt_info));
+	      diag_printf (TDF_TREE, "\n\touter offset from base address: ");
+	      diag_generic_expr (TDF_SLIM, STMT_VINFO_DR_OFFSET (stmt_info));
+	      diag_printf (TDF_TREE,
+                           "\n\touter constant offset from base address: ");
+	      diag_generic_expr (TDF_SLIM, STMT_VINFO_DR_INIT (stmt_info));
+	      diag_printf (TDF_TREE, "\n\touter step: ");
+	      diag_generic_expr (TDF_SLIM, STMT_VINFO_DR_STEP (stmt_info));
+	      diag_printf (TDF_TREE, "\n\touter aligned to: ");
+	      diag_generic_expr (TDF_SLIM, STMT_VINFO_DR_ALIGNED_TO (stmt_info));
 	    }
 	}
 
@@ -3164,9 +3196,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump,
-                       "not vectorized: more than one data ref in stmt: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "not vectorized: more than one data ref in stmt: ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           if (bb_vinfo)
@@ -3191,11 +3223,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
         {
           if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
             {
-              fprintf (vect_dump,
-                       "not vectorized: no vectype for stmt: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
-              fprintf (vect_dump, " scalar_type: ");
-              print_generic_expr (vect_dump, scalar_type, TDF_DETAILS);
+              diag_printf (TDF_TREE,
+                           "not vectorized: no vectype for stmt: ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
+              diag_printf (TDF_TREE, " scalar_type: ");
+              if (dump_flags & TDF_DETAILS)
+                diag_generic_expr (TDF_DETAILS, scalar_type);
             }
 
           if (bb_vinfo)
@@ -3239,9 +3272,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: not suitable for gather load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "not vectorized: not suitable for gather load ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3291,10 +3324,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: data dependence conflict"
-			   " prevents gather load");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "not vectorized: data dependence conflict"
+                               " prevents gather load");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3312,9 +3345,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: not suitable for strided load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "not vectorized: not suitable for strided "
+                               "load ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3507,8 +3541,8 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "created ");
-      print_generic_expr (vect_dump, vec_stmt, TDF_SLIM);
+      diag_printf (TDF_TREE, "created ");
+      diag_generic_expr (TDF_SLIM, vec_stmt);
     }
 
   return vec_stmt;
@@ -3630,17 +3664,17 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_t
   if (vect_print_dump_info (REPORT_DETAILS))
     {
       tree data_ref_base = base_name;
-      fprintf (vect_dump, "create %s-pointer variable to type: ",
+      diag_printf (TDF_TREE, "create %s-pointer variable to type: ",
 	       tree_code_name[(int) TREE_CODE (aggr_type)]);
-      print_generic_expr (vect_dump, aggr_type, TDF_SLIM);
+      diag_generic_expr (TDF_SLIM, aggr_type);
       if (TREE_CODE (data_ref_base) == VAR_DECL
           || TREE_CODE (data_ref_base) == ARRAY_REF)
-        fprintf (vect_dump, "  vectorizing an array ref: ");
+        diag_printf (TDF_TREE, "  vectorizing an array ref: ");
       else if (TREE_CODE (data_ref_base) == COMPONENT_REF)
-        fprintf (vect_dump, "  vectorizing a record based array ref: ");
+        diag_printf (TDF_TREE, "  vectorizing a record based array ref: ");
       else if (TREE_CODE (data_ref_base) == SSA_NAME)
-        fprintf (vect_dump, "  vectorizing a pointer ref: ");
-      print_generic_expr (vect_dump, base_name, TDF_SLIM);
+        diag_printf (TDF_TREE, "  vectorizing a pointer ref: ");
+      diag_generic_expr (TDF_SLIM, base_name);
     }
 
   /* (1) Create the new aggregate-pointer variable.  */
@@ -3962,8 +3996,8 @@ vect_grouped_store_supported (tree vectype, unsign
   if (exact_log2 (count) == -1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "the size of the group of accesses"
-		 " is not a power of 2");
+	diag_printf (TDF_TREE, "the size of the group of accesses"
+                     " is not a power of 2");
       return false;
     }
 
@@ -3987,7 +4021,7 @@ vect_grouped_store_supported (tree vectype, unsign
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "interleave op not supported by target.");
+    diag_printf (TDF_TREE, "interleave op not supported by target.");
   return false;
 }
 
@@ -4412,8 +4446,8 @@ vect_grouped_load_supported (tree vectype, unsigne
   if (exact_log2 (count) == -1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "the size of the group of accesses"
-		 " is not a power of 2");
+	diag_printf (TDF_TREE, "the size of the group of accesses"
+                     " is not a power of 2");
       return false;
     }
 
@@ -4435,7 +4469,7 @@ vect_grouped_load_supported (tree vectype, unsigne
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "extract even/odd not supported by target");
+    diag_printf (TDF_TREE, "extract even/odd not supported by target");
   return false;
 }
 
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c	(revision 188325)
+++ tree-vect-patterns.c	(working copy)
@@ -422,8 +422,8 @@ vect_recog_dot_prod_pattern (VEC (gimple, heap) **
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_recog_dot_prod_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "vect_recog_dot_prod_pattern: detected: ");
+      diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   /* We don't allow changing the order of the computation in the inner-loop
@@ -683,7 +683,7 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap)
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_widen_mult_pattern: detected: ");
+    diag_printf (TDF_TREE, "vect_recog_widen_mult_pattern: detected: ");
 
   /* Check target support  */
   vectype = get_vectype_for_scalar_type (half_type0);
@@ -705,7 +705,7 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap)
 					       oprnd1);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -919,8 +919,8 @@ vect_recog_widen_sum_pattern (VEC (gimple, heap) *
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_recog_widen_sum_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "vect_recog_widen_sum_pattern: detected: ");
+      diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   /* We don't allow changing the order of the computation in the inner-loop
@@ -1222,8 +1222,8 @@ vect_recog_over_widening_pattern (VEC (gimple, hea
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "created pattern stmt: ");
-          print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "created pattern stmt: ");
+          diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
         }
 
       type = gimple_expr_type (stmt);
@@ -1291,8 +1291,8 @@ vect_recog_over_widening_pattern (VEC (gimple, hea
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_recog_over_widening_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "vect_recog_over_widening_pattern: detected: ");
+      diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   return pattern_stmt;
@@ -1426,7 +1426,7 @@ vect_recog_widen_shift_pattern (VEC (gimple, heap)
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_widen_shift_pattern: detected: ");
+    diag_printf (TDF_TREE, "vect_recog_widen_shift_pattern: detected: ");
 
   /* Check target support.  */
   vectype = get_vectype_for_scalar_type (half_type0);
@@ -1450,7 +1450,7 @@ vect_recog_widen_shift_pattern (VEC (gimple, heap)
     gimple_build_assign_with_ops (WIDEN_LSHIFT_EXPR, var, oprnd0, oprnd1);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -1572,14 +1572,15 @@ vect_recog_vector_vector_shift_pattern (VEC (gimpl
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_vector_vector_shift_pattern: detected: ");
+    diag_printf (TDF_TREE,
+                 "vect_recog_vector_vector_shift_pattern: detected: ");
 
   /* Pattern supported.  Create a stmt to be used to replace the pattern.  */
   var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL);
   pattern_stmt = gimple_build_assign_with_ops (rhs_code, var, oprnd0, def);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -1682,7 +1683,7 @@ vect_recog_sdivmod_pow2_pattern (VEC (gimple, heap
 
   /* Pattern detected.  */
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_sdivmod_pow2_pattern: detected: ");
+    diag_printf (TDF_TREE, "vect_recog_sdivmod_pow2_pattern: detected: ");
 
   cond = build2 (LT_EXPR, boolean_type_node, oprnd0, build_int_cst (itype, 0));
   if (rhs_code == TRUNC_DIV_EXPR)
@@ -1779,7 +1780,7 @@ vect_recog_sdivmod_pow2_pattern (VEC (gimple, heap
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+    diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
 
   VEC_safe_push (gimple, heap, *stmts, last_stmt);
 
@@ -1943,7 +1944,7 @@ vect_recog_mixed_size_cond_pattern (VEC (gimple, h
   *type_out = vectype;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_mixed_size_cond_pattern: detected: ");
+    diag_printf (TDF_TREE, "vect_recog_mixed_size_cond_pattern: detected: ");
 
   return pattern_stmt;
 }
@@ -2335,7 +2336,7 @@ vect_recog_bool_pattern (VEC (gimple, heap) **stmt
       *type_in = vectype;
       VEC_safe_push (gimple, heap, *stmts, last_stmt);
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_bool_pattern: detected: ");
+	diag_printf (TDF_TREE, "vect_recog_bool_pattern: detected: ");
 
       return pattern_stmt;
     }
@@ -2380,7 +2381,7 @@ vect_recog_bool_pattern (VEC (gimple, heap) **stmt
       *type_in = vectype;
       VEC_safe_push (gimple, heap, *stmts, last_stmt);
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_bool_pattern: detected: ");
+	diag_printf (TDF_TREE, "vect_recog_bool_pattern: detected: ");
       return pattern_stmt;
     }
   else
@@ -2530,8 +2531,8 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
   /* Found a vectorizable pattern.  */
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "pattern recognized: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "pattern recognized: ");
+      diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
     }
 
   /* Mark the stmts that are involved in the pattern. */
@@ -2555,8 +2556,8 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
       pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "additional pattern stmt: ");
-          print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "additional pattern stmt: ");
+          diag_gimple_stmt (TDF_SLIM, pattern_stmt, 0);
         }
 
       vect_mark_pattern_stmts (stmt, pattern_stmt, NULL_TREE);
@@ -2654,7 +2655,7 @@ vect_pattern_recog (loop_vec_info loop_vinfo, bb_v
   gimple stmt;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_pattern_recog ===");
+    diag_printf (TDF_TREE, "=== vect_pattern_recog ===");
 
   if (loop_vinfo)
     {
Index: rtl.h
===================================================================
--- rtl.h	(revision 188325)
+++ rtl.h	(working copy)
@@ -2456,8 +2456,8 @@ extern bool validate_subreg (enum machine_mode, en
 /* In combine.c  */
 extern unsigned int extended_count (const_rtx, enum machine_mode, int);
 extern rtx remove_death (unsigned int, rtx);
-extern void dump_combine_stats (FILE *);
-extern void dump_combine_total_stats (FILE *);
+extern void print_combine_stats (FILE *);
+extern void print_combine_total_stats (FILE *);
 
 /* In cfgcleanup.c  */
 extern void delete_dead_jumptables (void);
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c	(revision 188325)
+++ tree-vect-stmts.c	(working copy)
@@ -129,7 +129,7 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
   gimple pattern_stmt;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "mark relevant %d, live %d.", relevant, live_p);
+    diag_printf (TDF_TREE, "mark relevant %d, live %d.", relevant, live_p);
 
   /* If this stmt is an original stmt in a pattern, we might need to mark its
      related pattern stmt instead of the original stmt.  However, such stmts
@@ -184,7 +184,7 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
           pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
 
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "last stmt in pattern. don't mark"
+            diag_printf (TDF_TREE, "last stmt in pattern. don't mark"
                                 " relevant/live.");
           stmt_info = vinfo_for_stmt (pattern_stmt);
           gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == stmt);
@@ -202,7 +202,7 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
       && STMT_VINFO_LIVE_P (stmt_info) == save_live_p)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "already marked relevant/live.");
+        diag_printf (TDF_TREE, "already marked relevant/live.");
       return;
     }
 
@@ -246,7 +246,7 @@ vect_stmt_relevant_p (gimple stmt, loop_vec_info l
     if (gimple_vdef (stmt))
       {
 	if (vect_print_dump_info (REPORT_DETAILS))
-	  fprintf (vect_dump, "vec_stmt_relevant_p: stmt has vdefs.");
+	  diag_printf (TDF_TREE, "vec_stmt_relevant_p: stmt has vdefs.");
 	*relevant = vect_used_in_scope;
       }
 
@@ -259,7 +259,8 @@ vect_stmt_relevant_p (gimple stmt, loop_vec_info l
 	  if (!flow_bb_inside_loop_p (loop, bb))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "vec_stmt_relevant_p: used out of loop.");
+		diag_printf (TDF_TREE,
+                             "vec_stmt_relevant_p: used out of loop.");
 
 	      if (is_gimple_debug (USE_STMT (use_p)))
 		continue;
@@ -371,7 +372,7 @@ process_use (gimple stmt, tree use, loop_vec_info
   if (!vect_is_simple_use (use, stmt, loop_vinfo, NULL, &def_stmt, &def, &dt))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported use in stmt.");
+        diag_printf (TDF_TREE, "not vectorized: unsupported use in stmt.");
       return false;
     }
 
@@ -382,7 +383,7 @@ process_use (gimple stmt, tree use, loop_vec_info
   if (!flow_bb_inside_loop_p (loop, def_bb))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "def_stmt is out of loop.");
+	diag_printf (TDF_TREE, "def_stmt is out of loop.");
       return true;
     }
 
@@ -400,7 +401,8 @@ process_use (gimple stmt, tree use, loop_vec_info
       && bb->loop_father == def_bb->loop_father)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "reduc-stmt defining reduc-phi in the same nest.");
+	diag_printf (TDF_TREE,
+                     "reduc-stmt defining reduc-phi in the same nest.");
       if (STMT_VINFO_IN_PATTERN_P (dstmt_vinfo))
 	dstmt_vinfo = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (dstmt_vinfo));
       gcc_assert (STMT_VINFO_RELEVANT (dstmt_vinfo) < vect_used_by_reduction);
@@ -419,7 +421,8 @@ process_use (gimple stmt, tree use, loop_vec_info
   if (flow_loop_nested_p (def_bb->loop_father, bb->loop_father))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "outer-loop def-stmt defining inner-loop stmt.");
+	diag_printf (TDF_TREE,
+                     "outer-loop def-stmt defining inner-loop stmt.");
 
       switch (relevant)
 	{
@@ -456,7 +459,8 @@ process_use (gimple stmt, tree use, loop_vec_info
   else if (flow_loop_nested_p (bb->loop_father, def_bb->loop_father))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "inner-loop def-stmt defining outer-loop stmt.");
+	diag_printf (TDF_TREE,
+                     "inner-loop def-stmt defining outer-loop stmt.");
 
       switch (relevant)
         {
@@ -519,7 +523,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
   enum vect_def_type def_type;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_mark_stmts_to_be_vectorized ===");
+    diag_printf (TDF_TREE, "=== vect_mark_stmts_to_be_vectorized ===");
 
   worklist = VEC_alloc (gimple, heap, 64);
 
@@ -532,8 +536,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
 	  phi = gsi_stmt (si);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "init: phi relevant? ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "init: phi relevant? ");
+	      diag_gimple_stmt (TDF_SLIM, phi, 0);
 	    }
 
 	  if (vect_stmt_relevant_p (phi, loop_vinfo, &relevant, &live_p))
@@ -544,8 +548,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
 	  stmt = gsi_stmt (si);
 	  if (vect_print_dump_info (REPORT_DETAILS))
 	    {
-	      fprintf (vect_dump, "init: stmt relevant? ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE, "init: stmt relevant? ");
+	      diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  if (vect_stmt_relevant_p (stmt, loop_vinfo, &relevant, &live_p))
@@ -562,8 +566,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
       stmt = VEC_pop (gimple, worklist);
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-          fprintf (vect_dump, "worklist: examine stmt: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "worklist: examine stmt: ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	}
 
       /* Examine the USEs of STMT. For each USE, mark the stmt that defines it
@@ -606,7 +610,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
 
 	        default:
 	          if (vect_print_dump_info (REPORT_DETAILS))
-	            fprintf (vect_dump, "unsupported use of reduction.");
+	            diag_printf (TDF_TREE, "unsupported use of reduction.");
 
   	          VEC_free (gimple, heap, worklist);
 	          return false;
@@ -621,7 +625,7 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
                 && tmp_relevant != vect_used_in_outer)
               {
                 if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported use of nested cycle.");
+                  diag_printf (TDF_TREE, "unsupported use of nested cycle.");
 
                 VEC_free (gimple, heap, worklist);
                 return false;
@@ -635,7 +639,8 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
                 && tmp_relevant != vect_used_by_reduction)
               {
                 if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported use of double reduction.");
+                  diag_printf (TDF_TREE,
+                               "unsupported use of double reduction.");
 
                 VEC_free (gimple, heap, worklist);
                 return false;
@@ -796,7 +801,7 @@ vect_model_simple_cost (stmt_vec_info stmt_info, i
     }
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_simple_cost: inside_cost = %d, "
+    diag_printf (TDF_TREE, "vect_model_simple_cost: inside_cost = %d, "
              "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs either in STMT_INFO or SLP_NODE (if exists).  */
@@ -837,8 +842,9 @@ vect_model_promotion_demotion_cost (stmt_vec_info
     }
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_promotion_demotion_cost: inside_cost = %d, "
-             "outside_cost = %d .", inside_cost, outside_cost);
+    diag_printf (TDF_TREE,
+                 "vect_model_promotion_demotion_cost: inside_cost = %d, "
+                 "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs in STMT_INFO.  */
   stmt_vinfo_set_inside_of_loop_cost (stmt_info, NULL, inside_cost);
@@ -919,16 +925,17 @@ vect_model_store_cost (stmt_vec_info stmt_info, in
         * vect_get_stmt_cost (vec_perm);
 
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "vect_model_store_cost: strided group_size = %d .",
-                 group_size);
+        diag_printf (TDF_TREE,
+                     "vect_model_store_cost: strided group_size = %d .",
+                     group_size);
     }
 
   /* Costs of the stores.  */
   vect_get_store_cost (first_dr, ncopies, &inside_cost);
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_store_cost: inside_cost = %d, "
-             "outside_cost = %d .", inside_cost, outside_cost);
+    diag_printf (TDF_TREE, "vect_model_store_cost: inside_cost = %d, "
+                 "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs either in STMT_INFO or SLP_NODE (if exists).  */
   stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
@@ -950,7 +957,7 @@ vect_get_store_cost (struct data_reference *dr, in
         *inside_cost += ncopies * vect_get_stmt_cost (vector_store);
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: aligned.");
+          diag_printf (TDF_TREE, "vect_model_store_cost: aligned.");
 
         break;
       }
@@ -967,8 +974,9 @@ vect_get_store_cost (struct data_reference *dr, in
                                  vectype, DR_MISALIGNMENT (dr));
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: unaligned supported by "
-                   "hardware.");
+          diag_printf (TDF_TREE,
+                       "vect_model_store_cost: unaligned supported by "
+                       "hardware.");
 
         break;
       }
@@ -1024,8 +1032,9 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
 	* vect_get_stmt_cost (vec_perm);
 
       if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "vect_model_load_cost: strided group_size = %d .",
-                 group_size);
+        diag_printf (TDF_TREE,
+                     "vect_model_load_cost: strided group_size = %d .",
+                     group_size);
     }
 
   /* The loads themselves.  */
@@ -1044,8 +1053,8 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
 			&inside_cost, &outside_cost);
 
   if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_load_cost: inside_cost = %d, "
-             "outside_cost = %d .", inside_cost, outside_cost);
+    diag_printf (TDF_TREE, "vect_model_load_cost: inside_cost = %d, "
+                 "outside_cost = %d .", inside_cost, outside_cost);
 
   /* Set the costs either in STMT_INFO or SLP_NODE (if exists).  */
   stmt_vinfo_set_inside_of_loop_cost (stmt_info, slp_node, inside_cost);
@@ -1068,7 +1077,7 @@ vect_get_load_cost (struct data_reference *dr, int
         *inside_cost += ncopies * vect_get_stmt_cost (vector_load); 
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: aligned.");
+          diag_printf (TDF_TREE, "vect_model_load_cost: aligned.");
 
         break;
       }
@@ -1083,8 +1092,9 @@ vect_get_load_cost (struct data_reference *dr, int
           * targetm.vectorize.builtin_vectorization_cost (unaligned_load,
                                            vectype, DR_MISALIGNMENT (dr));
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unaligned supported by "
-                   "hardware.");
+          diag_printf (TDF_TREE,
+                       "vect_model_load_cost: unaligned supported by "
+                       "hardware.");
 
         break;
       }
@@ -1100,15 +1110,17 @@ vect_get_load_cost (struct data_reference *dr, int
           *inside_cost += vect_get_stmt_cost (vector_stmt);
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: explicit realign");
+          diag_printf (TDF_TREE,
+                       "vect_model_load_cost: explicit realign");
 
         break;
       }
     case dr_explicit_realign_optimized:
       {
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unaligned software "
-                   "pipelined.");
+          diag_printf (TDF_TREE,
+                       "vect_model_load_cost: unaligned software "
+                       "pipelined.");
 
         /* Unaligned software pipeline has a load of an address, an initial
            load, and possibly a mask operation to "prime" the loop.  However,
@@ -1128,8 +1140,8 @@ vect_get_load_cost (struct data_reference *dr, int
 				   + vect_get_stmt_cost (vec_perm));
 
         if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump,
-		   "vect_model_load_cost: explicit realign optimized");
+          diag_printf (TDF_TREE,
+                       "vect_model_load_cost: explicit realign optimized");
 
         break;
       }
@@ -1180,8 +1192,8 @@ vect_init_vector_1 (gimple stmt, gimple new_stmt,
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "created new init_stmt: ");
-      print_gimple_stmt (vect_dump, new_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "created new init_stmt: ");
+      diag_gimple_stmt (TDF_SLIM, new_stmt, 0);
     }
 }
 
@@ -1265,8 +1277,8 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_get_vec_def_for_operand: ");
-      print_generic_expr (vect_dump, op, TDF_SLIM);
+      diag_printf (TDF_TREE, "vect_get_vec_def_for_operand: ");
+      diag_generic_expr (TDF_SLIM, op);
     }
 
   is_simple_use = vect_is_simple_use (op, stmt, loop_vinfo, NULL,
@@ -1276,13 +1288,13 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
     {
       if (def)
         {
-          fprintf (vect_dump, "def =  ");
-          print_generic_expr (vect_dump, def, TDF_SLIM);
+          diag_printf (TDF_TREE, "def =  ");
+          diag_generic_expr (TDF_SLIM, def);
         }
       if (def_stmt)
         {
-          fprintf (vect_dump, "  def_stmt =  ");
-	  print_gimple_stmt (vect_dump, def_stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "  def_stmt =  ");
+	  diag_gimple_stmt (TDF_SLIM, def_stmt, 0);
         }
     }
 
@@ -1300,7 +1312,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 
         /* Create 'vect_cst_ = {cst,cst,...,cst}'  */
         if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Create vector_cst. nunits = %d", nunits);
+          diag_printf (TDF_TREE, "Create vector_cst. nunits = %d", nunits);
 
         return vect_init_vector (stmt, op, vector_type, NULL);
       }
@@ -1316,7 +1328,7 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 
         /* Create 'vec_inv = {inv,inv,..,inv}'  */
         if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Create vector_inv.");
+          diag_printf (TDF_TREE, "Create vector_inv.");
 
         return vect_init_vector (stmt, def, vector_type, NULL);
       }
@@ -1553,8 +1565,8 @@ vect_finish_stmt_generation (gimple stmt, gimple v
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "add new stmt: ");
-      print_gimple_stmt (vect_dump, vec_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "add new stmt: ");
+      diag_gimple_stmt (TDF_SLIM, vec_stmt, 0);
     }
 
   gimple_set_location (vec_stmt, gimple_location (stmt));
@@ -1655,7 +1667,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
 	  && !types_compatible_p (rhs_type, TREE_TYPE (op)))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "argument types differ.");
+	    diag_printf (TDF_TREE, "argument types differ.");
 	  return false;
 	}
       if (!rhs_type)
@@ -1665,7 +1677,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
 				 &def_stmt, &def, &dt[i], &opvectype))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    diag_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
 
@@ -1675,7 +1687,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
 	       && opvectype != vectype_in)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "argument vector types differ.");
+	    diag_printf (TDF_TREE, "argument vector types differ.");
 	  return false;
 	}
     }
@@ -1689,8 +1701,8 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, rhs_type, TDF_SLIM);
+          diag_printf (TDF_TREE, "no vectype for scalar type ");
+          diag_generic_expr (TDF_SLIM, rhs_type);
         }
 
       return false;
@@ -1716,7 +1728,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
   if (fndecl == NULL_TREE)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "function is not vectorizable.");
+	diag_printf (TDF_TREE, "function is not vectorizable.");
 
       return false;
     }
@@ -1738,7 +1750,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_call ===");
+        diag_printf (TDF_TREE, "=== vectorizable_call ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
@@ -1746,7 +1758,7 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform call.");
+    diag_printf (TDF_TREE, "transform call.");
 
   /* Handle def.  */
   scalar_dest = gimple_call_lhs (stmt);
@@ -2261,8 +2273,8 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 	      != GET_MODE_PRECISION (TYPE_MODE (rhs_type)))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump,
-		 "type conversion to/from bit-precision unsupported.");
+	diag_printf (TDF_TREE,
+                     "type conversion to/from bit-precision unsupported.");
       return false;
     }
 
@@ -2271,7 +2283,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 			     &def_stmt, &def, &dt[0], &vectype_in))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "use not simple.");
+	diag_printf (TDF_TREE, "use not simple.");
       return false;
     }
   if (op_type == binary_op)
@@ -2292,7 +2304,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
       if (!ok)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    diag_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
     }
@@ -2307,8 +2319,8 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
     {
       if (vect_print_dump_info (REPORT_DETAILS))
 	{
-	  fprintf (vect_dump, "no vectype for scalar type ");
-	  print_generic_expr (vect_dump, rhs_type, TDF_SLIM);
+	  diag_printf (TDF_TREE, "no vectype for scalar type ");
+	  diag_generic_expr (TDF_SLIM, rhs_type);
 	}
 
       return false;
@@ -2349,7 +2361,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
       /* FALLTHRU */
     unsupported:
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "conversion not supported by target.");
+	diag_printf (TDF_TREE, "conversion not supported by target.");
       return false;
 
     case WIDEN:
@@ -2449,7 +2461,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
   if (!vec_stmt)		/* transformation not required.  */
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "=== vectorizable_conversion ===");
+	diag_printf (TDF_TREE, "=== vectorizable_conversion ===");
       if (code == FIX_TRUNC_EXPR || code == FLOAT_EXPR)
         {
 	  STMT_VINFO_TYPE (stmt_info) = type_conversion_vec_info_type;
@@ -2471,7 +2483,7 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 
   /** Transform.  **/
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform conversion. ncopies = %d.", ncopies);
+    diag_printf (TDF_TREE, "transform conversion. ncopies = %d.", ncopies);
 
   if (op_type == binary_op)
     {
@@ -2823,7 +2835,7 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
 			     &def_stmt, &def, &dt[0], &vectype_in))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        diag_printf (TDF_TREE, "use not simple.");
       return false;
     }
 
@@ -2851,8 +2863,8 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
 	   && TYPE_UNSIGNED (TREE_TYPE (op))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "type conversion to/from bit-precision "
-		 "unsupported.");
+        diag_printf (TDF_TREE, "type conversion to/from bit-precision "
+                     "unsupported.");
       return false;
     }
 
@@ -2860,14 +2872,14 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
     {
       STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_assignment ===");
+        diag_printf (TDF_TREE, "=== vectorizable_assignment ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
 
   /** Transform.  **/
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform assignment.");
+    diag_printf (TDF_TREE, "transform assignment.");
 
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3014,7 +3026,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
       != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (scalar_dest))))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bit-precision shifts not supported.");
+        diag_printf (TDF_TREE, "bit-precision shifts not supported.");
       return false;
     }
 
@@ -3023,7 +3035,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
                              &def_stmt, &def, &dt[0], &vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        diag_printf (TDF_TREE, "use not simple.");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -3036,8 +3048,8 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, TREE_TYPE (op0), TDF_SLIM);
+          diag_printf (TDF_TREE, "no vectype for scalar type ");
+          diag_generic_expr (TDF_SLIM, TREE_TYPE (op0));
         }
 
       return false;
@@ -3053,7 +3065,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 			     &def, &dt[1], &op1_vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        diag_printf (TDF_TREE, "use not simple.");
       return false;
     }
 
@@ -3097,7 +3109,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   else
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "operand mode requires invariant argument.");
+	diag_printf (TDF_TREE, "operand mode requires invariant argument.");
       return false;
     }
 
@@ -3106,15 +3118,15 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     {
       optab = optab_for_tree_code (code, vectype, optab_vector);
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "vector/vector shift/rotate found.");
+        diag_printf (TDF_TREE, "vector/vector shift/rotate found.");
       if (!op1_vectype)
 	op1_vectype = get_same_sized_vectype (TREE_TYPE (op1), vectype_out);
       if (op1_vectype == NULL_TREE
 	  || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "unusable type for last operand in"
-				" vector/vector shift/rotate.");
+	    diag_printf (TDF_TREE, "unusable type for last operand in"
+                         " vector/vector shift/rotate.");
 	  return false;
 	}
     }
@@ -3127,7 +3139,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
           && optab_handler (optab, TYPE_MODE (vectype)) != CODE_FOR_nothing)
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "vector/scalar shift/rotate found.");
+            diag_printf (TDF_TREE, "vector/scalar shift/rotate found.");
         }
       else
         {
@@ -3139,7 +3151,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 	      scalar_shift_arg = false;
 
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "vector/vector shift/rotate found.");
+                diag_printf (TDF_TREE, "vector/vector shift/rotate found.");
 
               /* Unlike the other binary operators, shifts/rotates have
                  the rhs being int, instead of the same type as the lhs,
@@ -3155,8 +3167,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 			 != TYPE_MODE (TREE_TYPE (op1)))
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
-		      fprintf (vect_dump, "unusable type for last operand in"
-					  " vector/vector shift/rotate.");
+		      diag_printf (TDF_TREE,
+                                   "unusable type for last operand in"
+                                   " vector/vector shift/rotate.");
 			return false;
 		    }
 		  if (vec_stmt && !slp_node)
@@ -3174,7 +3187,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (!optab)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "no optab.");
+        diag_printf (TDF_TREE, "no optab.");
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
@@ -3182,14 +3195,14 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (icode == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "op not supported by target.");
+        diag_printf (TDF_TREE, "op not supported by target.");
       /* Check only during analysis.  */
       if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
           || (vf < vect_min_worthwhile_factor (code)
               && !vec_stmt))
         return false;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "proceeding using word mode.");
+        diag_printf (TDF_TREE, "proceeding using word mode.");
     }
 
   /* Worthwhile without SIMD support?  Check only during analysis.  */
@@ -3198,7 +3211,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
       && !vec_stmt)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not worthwhile without SIMD support.");
+        diag_printf (TDF_TREE, "not worthwhile without SIMD support.");
       return false;
     }
 
@@ -3206,7 +3219,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     {
       STMT_VINFO_TYPE (stmt_info) = shift_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_shift ===");
+        diag_printf (TDF_TREE, "=== vectorizable_shift ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
@@ -3214,7 +3227,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform binary/unary operation.");
+    diag_printf (TDF_TREE, "transform binary/unary operation.");
 
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3250,7 +3263,7 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
               if (!VECTOR_MODE_P (optab_op2_mode))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "operand 1 using scalar mode.");
+                    diag_printf (TDF_TREE, "operand 1 using scalar mode.");
                   vec_oprnd1 = op1;
                   VEC_quick_push (tree, vec_oprnds1, vec_oprnd1);
                   if (slp_node)
@@ -3373,8 +3386,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (op_type != unary_op && op_type != binary_op && op_type != ternary_op)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "num. args = %d (not unary/binary/ternary op).",
-		 op_type);
+	diag_printf (TDF_TREE,
+                     "num. args = %d (not unary/binary/ternary op).",
+                     op_type);
       return false;
     }
 
@@ -3391,7 +3405,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       && code != BIT_AND_EXPR)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bit-precision arithmetic not supported.");
+        diag_printf (TDF_TREE, "bit-precision arithmetic not supported.");
       return false;
     }
 
@@ -3400,7 +3414,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
 			     &def_stmt, &def, &dt[0], &vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        diag_printf (TDF_TREE, "use not simple.");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -3413,8 +3427,8 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, TREE_TYPE (op0), TDF_SLIM);
+          diag_printf (TDF_TREE, "no vectype for scalar type ");
+          diag_generic_expr (TDF_SLIM, TREE_TYPE (op0));
         }
 
       return false;
@@ -3432,7 +3446,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
 			       &def, &dt[1]))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    diag_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
     }
@@ -3443,7 +3457,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
 			       &def, &dt[2]))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	    diag_printf (TDF_TREE, "use not simple.");
 	  return false;
 	}
     }
@@ -3474,7 +3488,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (!optab)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "no optab.");
+	diag_printf (TDF_TREE, "no optab.");
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
@@ -3482,14 +3496,14 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (icode == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "op not supported by target.");
+	diag_printf (TDF_TREE, "op not supported by target.");
       /* Check only during analysis.  */
       if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
 	  || (vf < vect_min_worthwhile_factor (code)
               && !vec_stmt))
         return false;
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "proceeding using word mode.");
+	diag_printf (TDF_TREE, "proceeding using word mode.");
     }
 
   /* Worthwhile without SIMD support?  Check only during analysis.  */
@@ -3498,7 +3512,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       && !vec_stmt)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "not worthwhile without SIMD support.");
+	diag_printf (TDF_TREE, "not worthwhile without SIMD support.");
       return false;
     }
 
@@ -3506,7 +3520,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
     {
       STMT_VINFO_TYPE (stmt_info) = op_vec_info_type;
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_operation ===");
+        diag_printf (TDF_TREE, "=== vectorizable_operation ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL);
       return true;
     }
@@ -3514,7 +3528,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   /** Transform.  **/
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform binary/unary operation.");
+    diag_printf (TDF_TREE, "transform binary/unary operation.");
 
   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3717,7 +3731,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
   if (loop && nested_in_vect_loop_p (loop, stmt) && ncopies > 1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
+        diag_printf (TDF_TREE, "multiple types in nested loop.");
       return false;
     }
 
@@ -3750,7 +3764,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 			   &def, &dt))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+        diag_printf (TDF_TREE, "use not simple.");
       return false;
     }
 
@@ -3770,7 +3784,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 			    size_zero_node) < 0)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "negative step for store.");
+        diag_printf (TDF_TREE, "negative step for store.");
       return false;
     }
 
@@ -3800,7 +3814,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 				       &def_stmt, &def, &dt))
                 {
                   if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "use not simple.");
+                    diag_printf (TDF_TREE, "use not simple.");
                   return false;
                 }
               next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
@@ -3860,7 +3874,7 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform store. ncopies = %d",ncopies);
+    diag_printf (TDF_TREE, "transform store. ncopies = %d",ncopies);
 
   dr_chain = VEC_alloc (tree, heap, group_size);
   oprnds = VEC_alloc (tree, heap, group_size);
@@ -4247,7 +4261,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
   if (nested_in_vect_loop && ncopies > 1)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
+        diag_printf (TDF_TREE, "multiple types in nested loop.");
       return false;
     }
 
@@ -4286,7 +4300,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Aligned load, but unsupported type.");
+	diag_printf (TDF_TREE, "Aligned load, but unsupported type.");
       return false;
     }
 
@@ -4321,7 +4335,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 				 &gather_off_vectype))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "gather index use not simple.");
+	    diag_printf (TDF_TREE, "gather index use not simple.");
 	  return false;
 	}
     }
@@ -4340,7 +4354,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
       if (negative && ncopies > 1)
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple types with negative step.");
+	    diag_printf (TDF_TREE, "multiple types with negative step.");
 	  return false;
 	}
 
@@ -4352,13 +4366,15 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 	      && alignment_support_scheme != dr_unaligned_supported)
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "negative step but alignment required.");
+		diag_printf (TDF_TREE,
+                             "negative step but alignment required.");
 	      return false;
 	    }
 	  if (!perm_mask_for_reverse (vectype))
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "negative step and reversing not supported.");
+		diag_printf (TDF_TREE,
+                             "negative step and reversing not supported.");
 	      return false;
 	    }
 	}
@@ -4372,7 +4388,7 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform load. ncopies = %d", ncopies);
+    diag_printf (TDF_TREE, "transform load. ncopies = %d", ncopies);
 
   /** Transform.  **/
 
@@ -5179,7 +5195,7 @@ vectorizable_condition (gimple stmt, gimple_stmt_i
   if (STMT_VINFO_LIVE_P (stmt_info))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
+        diag_printf (TDF_TREE, "value used after loop.");
       return false;
     }
 
@@ -5379,14 +5395,14 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "==> examining statement: ");
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "==> examining statement: ");
+      diag_gimple_stmt (TDF_SLIM, stmt, 0);
     }
 
   if (gimple_has_volatile_ops (stmt))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: stmt has volatile operands");
+        diag_printf (TDF_TREE, "not vectorized: stmt has volatile operands");
 
       return false;
     }
@@ -5417,14 +5433,14 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
           stmt_info = vinfo_for_stmt (pattern_stmt);
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "==> examining pattern statement: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE, "==> examining pattern statement: ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
         }
       else
         {
           if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "irrelevant.");
+            diag_printf (TDF_TREE, "irrelevant.");
 
           return true;
         }
@@ -5437,8 +5453,8 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
       /* Analyze PATTERN_STMT too.  */
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "==> examining pattern statement: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "==> examining pattern statement: ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       if (!vect_analyze_stmt (pattern_stmt, need_to_vectorize, node))
@@ -5459,8 +5475,9 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
 	      /* Analyze def stmt of STMT if it's a pattern stmt.  */
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "==> examining pattern def statement: ");
-		  print_gimple_stmt (vect_dump, pattern_def_stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "==> examining pattern def statement: ");
+		  diag_gimple_stmt (TDF_SLIM, pattern_def_stmt, 0);
 		}
 
 	      if (!vect_analyze_stmt (pattern_def_stmt,
@@ -5497,8 +5514,8 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
       scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "get vectype for scalar type:  ");
-          print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+          diag_printf (TDF_TREE, "get vectype for scalar type:  ");
+          diag_generic_expr (TDF_SLIM, scalar_type);
         }
 
       vectype = get_vectype_for_scalar_type (scalar_type);
@@ -5506,16 +5523,16 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-               fprintf (vect_dump, "not SLPed: unsupported data-type ");
-               print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+               diag_printf (TDF_TREE, "not SLPed: unsupported data-type ");
+               diag_generic_expr (TDF_SLIM, scalar_type);
             }
           return false;
         }
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "vectype:  ");
-          print_generic_expr (vect_dump, vectype, TDF_SLIM);
+          diag_printf (TDF_TREE, "vectype:  ");
+          diag_generic_expr (TDF_SLIM, vectype);
         }
 
       STMT_VINFO_VECTYPE (stmt_info) = vectype;
@@ -5558,9 +5575,9 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
         {
-          fprintf (vect_dump, "not vectorized: relevant stmt not ");
-          fprintf (vect_dump, "supported: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "not vectorized: relevant stmt not ");
+          diag_printf (TDF_TREE, "supported: ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       return false;
@@ -5579,9 +5596,9 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
         {
-          fprintf (vect_dump, "not vectorized: live stmt not ");
-          fprintf (vect_dump, "supported: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "not vectorized: live stmt not ");
+          diag_printf (TDF_TREE, "supported: ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
        return false;
@@ -5677,7 +5694,7 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter
       if (!STMT_VINFO_LIVE_P (stmt_info))
 	{
 	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "stmt not supported.");
+	    diag_printf (TDF_TREE, "stmt not supported.");
 	  gcc_unreachable ();
 	}
     }
@@ -5701,7 +5718,8 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter
       gimple exit_phi;
 
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Record the vdef for outer-loop vectorization.");
+        diag_printf (TDF_TREE,
+                     "Record the vdef for outer-loop vectorization.");
 
       /* Find the relevant loop-exit phi-node, and reord the vec_stmt there
         (to be used when vectorizing outer-loop stmts that use the DEF of
@@ -5935,8 +5953,8 @@ get_vectype_for_scalar_type_and_size (tree scalar_
   vectype = build_vector_type (scalar_type, nunits);
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "get vectype with %d units of type ", nunits);
-      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+      diag_printf (TDF_TREE, "get vectype with %d units of type ", nunits);
+      diag_generic_expr (TDF_SLIM, scalar_type);
     }
 
   if (!vectype)
@@ -5944,15 +5962,15 @@ get_vectype_for_scalar_type_and_size (tree scalar_
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vectype: ");
-      print_generic_expr (vect_dump, vectype, TDF_SLIM);
+      diag_printf (TDF_TREE, "vectype: ");
+      diag_generic_expr (TDF_SLIM, vectype);
     }
 
   if (!VECTOR_MODE_P (TYPE_MODE (vectype))
       && !INTEGRAL_MODE_P (TYPE_MODE (vectype)))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "mode not supported by target.");
+        diag_printf (TDF_TREE, "mode not supported by target.");
       return NULL_TREE;
     }
 
@@ -6023,8 +6041,8 @@ vect_is_simple_use (tree operand, gimple stmt, loo
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "vect_is_simple_use: operand ");
-      print_generic_expr (vect_dump, operand, TDF_SLIM);
+      diag_printf (TDF_TREE, "vect_is_simple_use: operand ");
+      diag_generic_expr (TDF_SLIM, operand);
     }
 
   if (CONSTANT_CLASS_P (operand))
@@ -6043,14 +6061,14 @@ vect_is_simple_use (tree operand, gimple stmt, loo
   if (TREE_CODE (operand) == PAREN_EXPR)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "non-associatable copy.");
+        diag_printf (TDF_TREE, "non-associatable copy.");
       operand = TREE_OPERAND (operand, 0);
     }
 
   if (TREE_CODE (operand) != SSA_NAME)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not ssa-name.");
+        diag_printf (TDF_TREE, "not ssa-name.");
       return false;
     }
 
@@ -6058,14 +6076,14 @@ vect_is_simple_use (tree operand, gimple stmt, loo
   if (*def_stmt == NULL)
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "no def_stmt.");
+        diag_printf (TDF_TREE, "no def_stmt.");
       return false;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "def_stmt: ");
-      print_gimple_stmt (vect_dump, *def_stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "def_stmt: ");
+      diag_gimple_stmt (TDF_SLIM, *def_stmt, 0);
     }
 
   /* Empty stmt is expected only in case of a function argument.
@@ -6095,12 +6113,12 @@ vect_is_simple_use (tree operand, gimple stmt, loo
 	  && gimple_code (stmt) != GIMPLE_PHI))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Unsupported pattern.");
+        diag_printf (TDF_TREE, "Unsupported pattern.");
       return false;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "type of def: %d.",*dt);
+    diag_printf (TDF_TREE, "type of def: %d.",*dt);
 
   switch (gimple_code (*def_stmt))
     {
@@ -6119,7 +6137,7 @@ vect_is_simple_use (tree operand, gimple stmt, loo
       /* FALLTHRU */
     default:
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "unsupported defining stmt: ");
+        diag_printf (TDF_TREE, "unsupported defining stmt: ");
       return false;
     }
 
@@ -6260,7 +6278,7 @@ supportable_widening_operation (enum tree_code cod
       && targetm.vectorize.builtin_mul_widen_odd (vectype))
     {
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Unordered widening operation detected.");
+        diag_printf (TDF_TREE, "Unordered widening operation detected.");
 
       *code1 = *code2 = CALL_EXPR;
       *decl1 = targetm.vectorize.builtin_mul_widen_even (vectype);
Index: combine.c
===================================================================
--- combine.c	(revision 188325)
+++ combine.c	(working copy)
@@ -13909,7 +13909,7 @@ unmentioned_reg_p (rtx equiv, rtx expr)
 }
 \f
 DEBUG_FUNCTION void
-dump_combine_stats (FILE *file)
+print_combine_stats (FILE *file)
 {
   fprintf
     (file,
@@ -13918,7 +13918,7 @@ DEBUG_FUNCTION void
 }
 
 void
-dump_combine_total_stats (FILE *file)
+print_combine_total_stats (FILE *file)
 {
   fprintf
     (file,
Index: system.h
===================================================================
--- system.h	(revision 188325)
+++ system.h	(working copy)
@@ -669,6 +669,7 @@ extern int vsnprintf(char *, size_t, const char *,
    except, maybe, something to the dump file.  */
 #ifdef BUFSIZ
 extern FILE *dump_file;
+extern FILE *alt_dump_file;
 #endif
 
 /* Redefine abort to report an internal error w/o coredump, and
Index: passes.c
===================================================================
--- passes.c	(revision 188325)
+++ passes.c	(working copy)
@@ -232,20 +232,16 @@ finish_optimization_passes (void)
   timevar_push (TV_DUMP);
   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
     {
-      dump_file = dump_begin (pass_profile.pass.static_pass_number, NULL);
+      dump_start (pass_profile.pass.static_pass_number, NULL);
       end_branch_prob ();
-      if (dump_file)
-	dump_end (pass_profile.pass.static_pass_number, dump_file);
+      dump_finish (pass_profile.pass.static_pass_number);
     }
 
   if (optimize > 0)
     {
-      dump_file = dump_begin (pass_combine.pass.static_pass_number, NULL);
-      if (dump_file)
-	{
-	  dump_combine_total_stats (dump_file);
-          dump_end (pass_combine.pass.static_pass_number, dump_file);
-	}
+      dump_start (pass_profile.pass.static_pass_number, NULL);
+      dump_combine_total_stats (TDF_DETAILS);
+      dump_finish (pass_combine.pass.static_pass_number);
     }
 
   /* Do whatever is necessary to finish printing the graphs.  */
@@ -1218,9 +1214,9 @@ register_pass (struct register_pass_info *pass_inf
       else
         tdi = TDI_rtl_all;
       /* Check if dump-all flag is specified.  */
-      if (get_dump_file_info (tdi)->state)
+      if (get_dump_file_info (tdi)->pstate)
         get_dump_file_info (added_pass_nodes->pass->static_pass_number)
-            ->state = get_dump_file_info (tdi)->state;
+            ->pstate = get_dump_file_info (tdi)->pstate;
       XDELETE (added_pass_nodes);
       added_pass_nodes = next_node;
     }
@@ -1909,7 +1905,7 @@ pass_init_dump_file (struct opt_pass *pass)
     {
       bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
       dump_file_name = get_dump_file_name (pass->static_pass_number);
-      dump_file = dump_begin (pass->static_pass_number, &dump_flags);
+      dump_start (pass->static_pass_number, &dump_flags);
       if (dump_file && current_function_decl)
         dump_function_header (dump_file, current_function_decl, dump_flags);
       return initializing_dump;
@@ -1931,11 +1927,7 @@ pass_fini_dump_file (struct opt_pass *pass)
       dump_file_name = NULL;
     }
 
-  if (dump_file)
-    {
-      dump_end (pass->static_pass_number, dump_file);
-      dump_file = NULL;
-    }
+  dump_finish (pass->static_pass_number);
 }
 
 /* After executing the pass, apply expected changes to the function
Index: tree-vect-slp.c
===================================================================
--- tree-vect-slp.c	(revision 188325)
+++ tree-vect-slp.c	(working copy)
@@ -238,8 +238,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	{
 	  if (vect_print_dump_info (REPORT_SLP))
 	    {
-	      fprintf (vect_dump, "Build SLP failed: can't find def for ");
-	      print_generic_expr (vect_dump, oprnd, TDF_SLIM);
+	      diag_printf (TDF_TREE,
+                           "Build SLP failed: can't find def for ");
+	      diag_generic_expr (TDF_SLIM, oprnd);
 	    }
 
 	  return false;
@@ -262,9 +263,10 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	    {
 	      if (vect_print_dump_info (REPORT_DETAILS))
 		{
-		  fprintf (vect_dump, "Build SLP failed: some of the stmts"
-				" are in a pattern, and others are not ");
-		  print_generic_expr (vect_dump, oprnd, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "Build SLP failed: some of the stmts"
+                               " are in a pattern, and others are not ");
+		  diag_generic_expr (TDF_SLIM, oprnd);
 		}
 
 	      return false;
@@ -276,7 +278,7 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
           if (dt == vect_unknown_def_type)
             {
               if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Unsupported pattern.");
+                diag_printf (TDF_TREE, "Unsupported pattern.");
               return false;
             }
 
@@ -292,7 +294,7 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 
               default:
                 if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported defining stmt: ");
+                  diag_printf (TDF_TREE, "unsupported defining stmt: ");
                 return false;
             }
         }
@@ -355,7 +357,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	      if (number_of_oprnds != 2)
 		{
 		  if (vect_print_dump_info (REPORT_SLP))
-		    fprintf (vect_dump, "Build SLP failed: different types ");
+		    diag_printf (TDF_TREE,
+                                 "Build SLP failed: different types ");
 
 		  return false;
                 }
@@ -382,8 +385,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
                     {
                       if (vect_print_dump_info (REPORT_SLP))
 	                {
-			  fprintf (vect_dump, "Swapping operands of ");
- 		          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+			  diag_printf (TDF_TREE, "Swapping operands of ");
+ 		          diag_gimple_stmt (TDF_SLIM, stmt, 0);
 			}
 
  		      swap_tree_operands (stmt, gimple_assign_rhs1_ptr (stmt),
@@ -392,7 +395,8 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
                   else
                     {
          	      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: different types ");
+			diag_printf (TDF_TREE,
+                                     "Build SLP failed: different types ");
 
 		      return false;
 		    }
@@ -427,8 +431,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	  /* FORNOW: Not supported.  */
 	  if (vect_print_dump_info (REPORT_SLP))
 	    {
-	      fprintf (vect_dump, "Build SLP failed: illegal type of def ");
-	      print_generic_expr (vect_dump, def, TDF_SLIM);
+	      diag_printf (TDF_TREE,
+                           "Build SLP failed: illegal type of def ");
+	      diag_generic_expr (TDF_SLIM, def);
 	    }
 
 	  return false;
@@ -494,8 +499,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
     {
       if (vect_print_dump_info (REPORT_SLP))
 	{
-	  fprintf (vect_dump, "Build SLP for ");
-	  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	  diag_printf (TDF_TREE, "Build SLP for ");
+	  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	}
 
       /* Fail to vectorize statements marked as unvectorizable.  */
@@ -503,9 +508,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
         {
           if (vect_print_dump_info (REPORT_SLP))
             {
-              fprintf (vect_dump,
-                       "Build SLP failed: unvectorizable statement ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "Build SLP failed: unvectorizable statement ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -517,9 +522,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	{
 	  if (vect_print_dump_info (REPORT_SLP))
 	    {
-	      fprintf (vect_dump,
-		       "Build SLP failed: not GIMPLE_ASSIGN nor GIMPLE_CALL ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      diag_printf (TDF_TREE,
+                           "Build SLP failed: not GIMPLE_ASSIGN nor "
+                           "GIMPLE_CALL ");
+	      diag_gimple_stmt (TDF_SLIM, stmt, 0);
 	    }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -533,9 +539,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
         {
           if (vect_print_dump_info (REPORT_SLP))
             {
-              fprintf (vect_dump,
-                       "Build SLP failed: condition is not comparison ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "Build SLP failed: condition is not comparison ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -548,8 +554,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
         {
           if (vect_print_dump_info (REPORT_SLP))
             {
-              fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
-              print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+              diag_printf (TDF_TREE,
+                           "Build SLP failed: unsupported data-type ");
+              diag_generic_expr (TDF_SLIM, scalar_type);
             }
 
 	  vect_free_oprnd_info (&oprnds_info);
@@ -577,9 +584,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: unsupported call type ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "Build SLP failed: unsupported call type ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -616,7 +623,8 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		  if (!optab)
 		    {
 		      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: no optab.");
+			diag_printf (TDF_TREE,
+                                     "Build SLP failed: no optab.");
 	  	      vect_free_oprnd_info (&oprnds_info);
 		      return false;
 		    }
@@ -624,8 +632,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		  if (icode == CODE_FOR_nothing)
 		    {
 		      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: "
-				            "op not supported by target.");
+			diag_printf (TDF_TREE,
+                                     "Build SLP failed: "
+                                     "op not supported by target.");
 	  	      vect_free_oprnd_info (&oprnds_info);
 		      return false;
 		    }
@@ -658,9 +667,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: different operation in stmt ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "Build SLP failed: different operation "
+                               "in stmt ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -672,9 +682,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: different shift arguments in ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "Build SLP failed: different shift "
+                               "arguments in ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -692,9 +703,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		{
 		  if (vect_print_dump_info (REPORT_SLP))
 		    {
-		      fprintf (vect_dump,
-			       "Build SLP failed: different calls in ");
-		      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		      diag_printf (TDF_TREE,
+                                   "Build SLP failed: different calls in ");
+		      diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		    }
 
 		  vect_free_oprnd_info (&oprnds_info);
@@ -728,9 +739,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                 {
                   if (vect_print_dump_info (REPORT_SLP))
                     {
-                      fprintf (vect_dump, "Build SLP failed: grouped "
-                                          "loads have gaps ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      diag_printf (TDF_TREE, "Build SLP failed: grouped "
+                                   "loads have gaps ");
+                      diag_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
 
 	  	  vect_free_oprnd_info (&oprnds_info);
@@ -744,10 +755,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                 {
                   if (vect_print_dump_info (REPORT_SLP))
                     {
-                      fprintf (vect_dump, "Build SLP failed: the number of "
-                                          "interleaved loads is greater than"
-                                          " the SLP group size ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      diag_printf (TDF_TREE, "Build SLP failed: the number "
+                                   "of interleaved loads is greater than "
+                                   "the SLP group size ");
+                      diag_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
 
 	  	  vect_free_oprnd_info (&oprnds_info);
@@ -761,16 +772,17 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                      chains in the same node.  The only exception is complex
                      numbers.  */
                   if (prev_first_load != first_load
-                      && rhs_code != REALPART_EXPR 
+                      && rhs_code != REALPART_EXPR
                       && rhs_code != IMAGPART_EXPR)
-                    {    
+                    {
                       if (vect_print_dump_info (REPORT_SLP))
                         {
-                          fprintf (vect_dump, "Build SLP failed: different "
-                                           "interleaving chains in one node ");
-                          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                          diag_printf (TDF_TREE,
+                                       "Build SLP failed: different "
+                                       "interleaving chains in one node ");
+                          diag_gimple_stmt (TDF_SLIM, stmt, 0);
                         }
- 
+
 	  	      vect_free_oprnd_info (&oprnds_info);
                       return false;
                     }
@@ -786,9 +798,10 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                     {
                       if (vect_print_dump_info (REPORT_SLP))
                         {
-                          fprintf (vect_dump, "Build SLP failed: unsupported "
-                                              "unaligned load ");
-                          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                          diag_printf (TDF_TREE,
+                                       "Build SLP failed: unsupported "
+                                       "unaligned load ");
+                          diag_gimple_stmt (TDF_SLIM, stmt, 0);
                         }
 
 	  	      vect_free_oprnd_info (&oprnds_info);
@@ -822,8 +835,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	      /* Not grouped load.  */
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump, "Build SLP failed: not grouped load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE,
+                               "Build SLP failed: not grouped load ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      /* FORNOW: Not grouped loads are not supported.  */
@@ -839,9 +853,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	    {
 	      if (vect_print_dump_info (REPORT_SLP))
 		{
-		  fprintf (vect_dump, "Build SLP failed: operation");
-		  fprintf (vect_dump, " unsupported ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  diag_printf (TDF_TREE, "Build SLP failed: operation");
+		  diag_printf (TDF_TREE, " unsupported ");
+		  diag_gimple_stmt (TDF_SLIM, stmt, 0);
 		}
 
 	      vect_free_oprnd_info (&oprnds_info);
@@ -858,9 +872,9 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                 {
                   if (vect_print_dump_info (REPORT_SLP))
                     {
-                      fprintf (vect_dump, "Build SLP failed: different"
-					  " operation");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      diag_printf (TDF_TREE, "Build SLP failed: different"
+                                   " operation");
+                      diag_gimple_stmt (TDF_SLIM, stmt, 0);
                     }
 
 		  vect_free_oprnd_info (&oprnds_info);
@@ -949,13 +963,13 @@ vect_print_slp_tree (slp_tree node)
   if (!node)
     return;
 
-  fprintf (vect_dump, "node ");
+  diag_printf (TDF_TREE, "node ");
   FOR_EACH_VEC_ELT (gimple, SLP_TREE_SCALAR_STMTS (node), i, stmt)
     {
-      fprintf (vect_dump, "\n\tstmt %d ", i);
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "\n\tstmt %d ", i);
+      diag_gimple_stmt (TDF_SLIM, stmt, 0);
     }
-  fprintf (vect_dump, "\n");
+  diag_printf (TDF_TREE, "\n");
 
   FOR_EACH_VEC_ELT (slp_void_p, SLP_TREE_CHILDREN (node), i, child)
     vect_print_slp_tree ((slp_tree) child);
@@ -1043,9 +1057,9 @@ vect_supported_slp_permutation_p (slp_instance ins
         {
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "Build SLP failed: unsupported data "
-                                   "permutation ");
-              print_gimple_stmt (vect_dump, scalar_stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE, "Build SLP failed: unsupported data "
+                           "permutation ");
+              diag_gimple_stmt (TDF_SLIM, scalar_stmt, 0);
             }
 
           free (tmp_loads);
@@ -1130,9 +1144,9 @@ vect_supported_load_permutation_p (slp_instance sl
 
   if (vect_print_dump_info (REPORT_SLP))
     {
-      fprintf (vect_dump, "Load permutation ");
+      diag_printf (TDF_TREE, "Load permutation ");
       FOR_EACH_VEC_ELT (int, load_permutation, i, next)
-        fprintf (vect_dump, "%d ", next);
+        diag_printf (TDF_TREE, "%d ", next);
     }
 
   /* In case of reduction every load permutation is allowed, since the order
@@ -1337,9 +1351,9 @@ vect_supported_load_permutation_p (slp_instance sl
                     {
    		      if (vect_print_dump_info (REPORT_SLP))
 		        {
-  	                  fprintf (vect_dump, "unsupported unaligned load ");
-                          print_gimple_stmt (vect_dump, first_load, 0,
-					     TDF_SLIM);
+  	                  diag_printf (TDF_TREE,
+                                       "unsupported unaligned load ");
+                          diag_gimple_stmt (TDF_SLIM, first_load, 0);
                         }
   		      bad_permutation = true;
                       break;
@@ -1493,8 +1507,8 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
     {
       if (vect_print_dump_info (REPORT_SLP))
         {
-          fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
-          print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+          diag_printf (TDF_TREE, "Build SLP failed: unsupported data-type ");
+          diag_generic_expr (TDF_SLIM, scalar_type);
         }
 
       return false;
@@ -1511,8 +1525,9 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
   if (unrolling_factor != 1 && !loop_vinfo)
     {
       if (vect_print_dump_info (REPORT_SLP))
-        fprintf (vect_dump, "Build SLP failed: unrolling required in basic"
-                            " block SLP");
+        diag_printf (TDF_TREE,
+                     "Build SLP failed: unrolling required in basic"
+                     " block SLP");
 
       return false;
     }
@@ -1566,8 +1581,9 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
       if (unrolling_factor != 1 && !loop_vinfo)
         {
           if (vect_print_dump_info (REPORT_SLP))
-            fprintf (vect_dump, "Build SLP failed: unrolling required in basic"
-                               " block SLP");
+            diag_printf (TDF_TREE,
+                         "Build SLP failed: unrolling required in basic"
+                         " block SLP");
           return false;
         }
 
@@ -1589,9 +1605,10 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
             {
               if (vect_print_dump_info (REPORT_SLP))
                 {
-                  fprintf (vect_dump, "Build SLP failed: unsupported load "
-                                      "permutation ");
-                  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                  diag_printf (TDF_TREE,
+                               "Build SLP failed: unsupported load "
+                               "permutation ");
+                  diag_gimple_stmt (TDF_SLIM, stmt, 0);
                 }
 
               vect_free_slp_instance (new_instance);
@@ -1640,7 +1657,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec
   bool ok = false;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_analyze_slp ===");
+    diag_printf (TDF_TREE, "=== vect_analyze_slp ===");
 
   if (loop_vinfo)
     {
@@ -1659,7 +1676,7 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec
   if (bb_vinfo && !ok)
     {
       if (vect_print_dump_info (REPORT_SLP))
-        fprintf (vect_dump, "Failed to SLP the basic block.");
+        diag_printf (TDF_TREE, "Failed to SLP the basic block.");
 
       return false;
     }
@@ -1702,7 +1719,7 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   int decided_to_slp = 0;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_make_slp_decision ===");
+    diag_printf (TDF_TREE, "=== vect_make_slp_decision ===");
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     {
@@ -1720,8 +1737,9 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo) = unrolling_factor;
 
   if (decided_to_slp && vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "Decided to SLP %d instances. Unrolling factor %d",
-	     decided_to_slp, unrolling_factor);
+    diag_printf (TDF_TREE,
+                 "Decided to SLP %d instances. Unrolling factor %d",
+                 decided_to_slp, unrolling_factor);
 
   return (decided_to_slp > 0);
 }
@@ -1784,7 +1802,7 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
   slp_instance instance;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_detect_hybrid_slp ===");
+    diag_printf (TDF_TREE, "=== vect_detect_hybrid_slp ===");
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     vect_detect_hybrid_slp_stmts (SLP_INSTANCE_TREE (instance));
@@ -1963,12 +1981,13 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb
 
   if (vect_print_dump_info (REPORT_COST))
     {
-      fprintf (vect_dump, "Cost model analysis: \n");
-      fprintf (vect_dump, "  Vector inside of basic block cost: %d\n",
+      diag_printf (TDF_TREE, "Cost model analysis: \n");
+      diag_printf (TDF_TREE, "  Vector inside of basic block cost: %d\n",
                vec_inside_cost);
-      fprintf (vect_dump, "  Vector outside of basic block cost: %d\n",
+      diag_printf (TDF_TREE, "  Vector outside of basic block cost: %d\n",
                vec_outside_cost);
-      fprintf (vect_dump, "  Scalar cost of basic block: %d", scalar_cost);
+      diag_printf (TDF_TREE, "  Scalar cost of basic block: %d",
+                   scalar_cost);
     }
 
   /* Vectorization is profitable if its cost is less than the cost of scalar
@@ -1999,8 +2018,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_refs (NULL, bb_vinfo, &min_vf))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unhandled data-ref in basic "
-                            "block.\n");
+        diag_printf (TDF_TREE, "not vectorized: unhandled data-ref in basic "
+                     "block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2010,8 +2029,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!VEC_length (ddr_p, ddrs))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: not enough data-refs in basic "
-                            "block.\n");
+        diag_printf (TDF_TREE, "not vectorized: not enough data-refs in "
+                     "basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2023,8 +2042,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
        || min_vf > max_vf)
      {
        if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	 fprintf (vect_dump, "not vectorized: unhandled data dependence "
-		  "in basic block.\n");
+	 diag_printf (TDF_TREE, "not vectorized: unhandled data dependence "
+                      "in basic block.\n");
 
        destroy_bb_vec_info (bb_vinfo);
        return NULL;
@@ -2033,8 +2052,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_refs_alignment (NULL, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: bad data alignment in basic "
-                            "block.\n");
+        diag_printf (TDF_TREE, "not vectorized: bad data alignment in basic "
+                     "block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2043,8 +2062,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_ref_accesses (NULL, bb_vinfo))
     {
      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-       fprintf (vect_dump, "not vectorized: unhandled data access in basic "
-                           "block.\n");
+       diag_printf (TDF_TREE, "not vectorized: unhandled data access in "
+                    "basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2053,8 +2072,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
    if (!vect_verify_datarefs_alignment (NULL, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported alignment in basic "
-                            "block.\n");
+        diag_printf (TDF_TREE, "not vectorized: unsupported alignment in "
+                     "basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2065,8 +2084,9 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_slp (NULL, bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: failed to find SLP opportunities "
-                            "in basic block.\n");
+        diag_printf (TDF_TREE,
+                     "not vectorized: failed to find SLP opportunities "
+                     "in basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2085,7 +2105,8 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_slp_analyze_operations (bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: bad operation in basic block.\n");
+        diag_printf (TDF_TREE,
+                     "not vectorized: bad operation in basic block.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2096,15 +2117,15 @@ vect_slp_analyze_bb_1 (basic_block bb)
       && !vect_bb_vectorization_profitable_p (bb_vinfo))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization is not "
-                            "profitable.\n");
+        diag_printf (TDF_TREE, "not vectorized: vectorization is not "
+                     "profitable.\n");
 
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
     }
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "Basic block will be vectorized using SLP\n");
+    diag_printf (TDF_TREE, "Basic block will be vectorized using SLP\n");
 
   return bb_vinfo;
 }
@@ -2119,7 +2140,7 @@ vect_slp_analyze_bb (basic_block bb)
   unsigned int vector_sizes;
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===vect_slp_analyze_bb===\n");
+    diag_printf (TDF_TREE, "===vect_slp_analyze_bb===\n");
 
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -2133,8 +2154,8 @@ vect_slp_analyze_bb (basic_block bb)
   if (insns > PARAM_VALUE (PARAM_SLP_MAX_INSNS_IN_BB))
     {
       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: too many instructions in basic "
-                            "block.\n");
+        diag_printf (TDF_TREE, "not vectorized: too many instructions in "
+                     "basic block.\n");
 
       return NULL;
     }
@@ -2159,8 +2180,8 @@ vect_slp_analyze_bb (basic_block bb)
       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
       if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "***** Re-trying analysis with "
-                 "vector size %d\n", current_vector_size);
+        diag_printf (TDF_TREE, "***** Re-trying analysis with "
+                     "vector size %d\n", current_vector_size);
     }
 }
 
@@ -2180,7 +2201,7 @@ vect_update_slp_costs_according_to_vf (loop_vec_in
   slp_instance instance;
 
   if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_update_slp_costs_according_to_vf ===");
+    diag_printf (TDF_TREE, "=== vect_update_slp_costs_according_to_vf ===");
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     /* We assume that costs are linear in ncopies.  */
@@ -2651,8 +2672,9 @@ vect_get_mask_element (gimple stmt, int first_mask
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "permutation requires at least two vectors ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE,
+                       "permutation requires at least two vectors ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       return false;
@@ -2668,9 +2690,9 @@ vect_get_mask_element (gimple stmt, int first_mask
              vectors.  */
           if (vect_print_dump_info (REPORT_DETAILS))
             {
-              fprintf (vect_dump, "permutation requires at "
-                                  "least three vectors ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              diag_printf (TDF_TREE, "permutation requires at "
+                           "least three vectors ");
+              diag_gimple_stmt (TDF_SLIM, stmt, 0);
             }
 
           return false;
@@ -2733,8 +2755,8 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tr
     {
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "no vect permute for ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "no vect permute for ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
       return false;
     }
@@ -2812,10 +2834,11 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tr
 		    {
 		      if (vect_print_dump_info (REPORT_DETAILS))
 			{
-			  fprintf (vect_dump, "unsupported vect permute { ");
+			  diag_printf (TDF_TREE,
+                                       "unsupported vect permute { ");
 			  for (i = 0; i < nunits; ++i)
-			    fprintf (vect_dump, "%d ", mask[i]);
-			  fprintf (vect_dump, "}\n");
+			    diag_printf (TDF_TREE, "%d ", mask[i]);
+			  diag_printf (TDF_TREE, "}\n");
 			}
 		      return false;
 		    }
@@ -2913,8 +2936,8 @@ vect_schedule_slp_instance (slp_tree node, slp_ins
 
   if (vect_print_dump_info (REPORT_DETAILS))
     {
-      fprintf (vect_dump, "------>vectorizing SLP node starting from: ");
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      diag_printf (TDF_TREE, "------>vectorizing SLP node starting from: ");
+      diag_gimple_stmt (TDF_SLIM, stmt, 0);
     }
 
   /* Loads should be inserted before the first load.  */
@@ -3021,7 +3044,7 @@ vect_schedule_slp (loop_vec_info loop_vinfo, bb_ve
                                              instance, vf);
       if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)
 	  || vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	fprintf (vect_dump, "vectorizing stmts using SLP.");
+	diag_printf (TDF_TREE, "vectorizing stmts using SLP.");
     }
 
   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
@@ -3065,7 +3088,7 @@ vect_slp_transform_bb (basic_block bb)
   gcc_assert (bb_vinfo);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "SLPing BB\n");
+    diag_printf (TDF_TREE, "SLPing BB\n");
 
   for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
     {
@@ -3074,8 +3097,8 @@ vect_slp_transform_bb (basic_block bb)
 
       if (vect_print_dump_info (REPORT_DETAILS))
         {
-          fprintf (vect_dump, "------>SLPing statement: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "------>SLPing statement: ");
+          diag_gimple_stmt (TDF_SLIM, stmt, 0);
         }
 
       stmt_info = vinfo_for_stmt (stmt);
@@ -3096,8 +3119,7 @@ vect_slp_transform_bb (basic_block bb)
   update_ssa (TODO_update_ssa);
 
   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "BASIC BLOCK VECTORIZED\n");
+    diag_printf (TDF_TREE, "BASIC BLOCK VECTORIZED\n");
 
   destroy_bb_vec_info (bb_vinfo);
 }
-

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-08  6:59                               ` Sharad Singhai
@ 2012-06-13  6:28                                 ` Sharad Singhai
  2012-06-13 11:49                                 ` Richard Guenther
  1 sibling, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-06-13  6:28 UTC (permalink / raw)
  To: Richard Guenther; +Cc: Gabriel Dos Reis, gcc-patches, Andrew Pinski

Ping.

Thanks,
Sharad

On Thu, Jun 7, 2012 at 10:16 PM, Sharad Singhai <singhai@google.com> wrote:
> Okay, I have updated the attached patch so that the output from
> -ftree-vectorizer-verbose is considered diagnostic information and is
> always
> sent to stderr. Other functionality remains unchanged. Here is some
> more context about this patch.
>
> This patch improves the dump infrastructure and public interfaces so
> that the existing private pass-specific dump stream is separated from
> the diagnostic dump stream (typically stderr).  The optimization
> passes can output information on the two streams independently.
>
> The newly defined interfaces are:
>
> Individual passes do not need to access the dump file directly. Thus Instead
> of doing
>
>   if (dump_file && (flags & dump_flags))
>      fprintf (dump_file, ...);
>
> they can do
>
>     dump_printf (flags, ...);
>
> If the current pass has FLAGS enabled then the information gets
> printed into the dump file otherwise not.
>
> Similar to the dump_printf (), another function is defined, called
>
>        diag_printf (dump_flags, ...)
>
> This prints information only onto the diagnostic stream, typically
> standard error. It is useful for separating pass-specific dump
> information from
> the diagnostic information.
>
> Currently, as a proof of concept, I have converted vectorizer passes
> to use the new dump format. For this, I have considered
> information printed in vect_dump file as diagnostic. Thus 'fprintf'
> calls are changed to 'diag_printf'. Some other information printed to
> dump_file is sent to the regular dump file via 'dump_printf ()'. It
> helps to separate the two streams because they might serve different
> purposes and might have different formatting requirements.
>
> For example, using the trunk compiler, the following invocation
>
> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>
> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
> However, the verbose diagnostic output is silently
> ignored. This is not desirable as the two types of dump should not interfere.
>
> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
> as before, but the verbose vectorizer diagnostic is additionally
> printed on stderr. Thus both types of dump information are output.
>
> An additional feature of this patch is that individual passes can
> print dump information into command-line named files instead of auto
> numbered filename. For example,
>
> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>     -ftree-vectorizer-verbose=2
>     -fdump-tree-pre=foo.pre
>
> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>
> Please take another look.
>
> Thanks,
> Sharad
>
>
> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>> Sorry about the delay. I have finally incorporated all the suggestions
>>> and reorganized the dump infrastructure a bit. The attached patch
>>> updates vectorizer passes so that instead of accessing global
>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>> The dump_printf can choose between two streams, one regular pass dump
>>> file, and another optional command line provided file. Currently, it
>>> doesn't discriminate and all the dump information goes to both the
>>> streams.
>>>
>>> Thus, for example,
>>>
>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>
>> But the default form of dump option (-fdump-tree-vect) no longer
>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>> one of the main requirements). One dumped to the primary stream (named
>> dump file) and the other to the stderr -- the default diagnostic (alt)
>> stream.
>>
>> David
>>
>>>
>>> will output the verbose vectorizer information in both *.vect file and
>>> foo.v file. However, as I have converted only vectorizer passes so
>>> far, there is additional information in *.vect file which is not
>>> present in foo.v file. Once other passes are converted to use this
>>> scheme, then these two dump files should have identical output.
>>>
>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>> any auto named dump files as in my earlier patches. Instead the dump
>>> information is output to both places when a command line dump file
>>> option is provided.
>>>
>>> To summarize:
>>> - instead of using dump_begin () / dump_end (), the passes should use
>>> dump_start ()/dump_finish (). These new variants do not return the
>>> dump_file. However, they still set the global dump_file/dump_flags for
>>> the benefit of other passes during the transition.
>>> - instead of directly printing to the dump_file, as in
>>> if (dump_file)
>>>  fprintf (dump_file, ...);
>>>
>>> The passes should do
>>>
>>> dump_printf (dump_flag, ...);
>>> This will output to dump file(s) only when dump_flag is enabled for a
>>> given pass.
>>>
>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>
>>> Thanks,
>>> Sharad
>>>
>>>
>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>> <richard.guenther@gmail.com> wrote:
>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>
>>>>>>> The downside is that the dump file format will look different from the
>>>>>>> stderr output which is less than ideal.
>>>>>>
>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>
>>>>>
>>>>> I was talking about the transformation information difference. In
>>>>> stderr (where diagnostics go to), we may have
>>>>>
>>>>> foo.c: in function 'foo':
>>>>> foo.c:5:6: note: loop was vectorized
>>>>>
>>>>> but in dump file the format for the information may be different,
>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>
>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>
>>>> Richard.
>>>>
>>>>> David
>>>>>
>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-08  6:59                               ` Sharad Singhai
  2012-06-13  6:28                                 ` Sharad Singhai
@ 2012-06-13 11:49                                 ` Richard Guenther
  2012-06-14  8:17                                   ` Sharad Singhai
  2012-06-15  8:13                                   ` Sharad Singhai
  1 sibling, 2 replies; 71+ messages in thread
From: Richard Guenther @ 2012-06-13 11:49 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
> Okay, I have updated the attached patch so that the output from
> -ftree-vectorizer-verbose is considered diagnostic information and is
> always
> sent to stderr. Other functionality remains unchanged. Here is some
> more context about this patch.
>
> This patch improves the dump infrastructure and public interfaces so
> that the existing private pass-specific dump stream is separated from
> the diagnostic dump stream (typically stderr).  The optimization
> passes can output information on the two streams independently.
>
> The newly defined interfaces are:
>
> Individual passes do not need to access the dump file directly. Thus Instead
> of doing
>
>   if (dump_file && (flags & dump_flags))
>      fprintf (dump_file, ...);
>
> they can do
>
>     dump_printf (flags, ...);
>
> If the current pass has FLAGS enabled then the information gets
> printed into the dump file otherwise not.
>
> Similar to the dump_printf (), another function is defined, called
>
>        diag_printf (dump_flags, ...)
>
> This prints information only onto the diagnostic stream, typically
> standard error. It is useful for separating pass-specific dump
> information from
> the diagnostic information.
>
> Currently, as a proof of concept, I have converted vectorizer passes
> to use the new dump format. For this, I have considered
> information printed in vect_dump file as diagnostic. Thus 'fprintf'
> calls are changed to 'diag_printf'. Some other information printed to
> dump_file is sent to the regular dump file via 'dump_printf ()'. It
> helps to separate the two streams because they might serve different
> purposes and might have different formatting requirements.
>
> For example, using the trunk compiler, the following invocation
>
> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>
> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
> However, the verbose diagnostic output is silently
> ignored. This is not desirable as the two types of dump should not interfere.
>
> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
> as before, but the verbose vectorizer diagnostic is additionally
> printed on stderr. Thus both types of dump information are output.
>
> An additional feature of this patch is that individual passes can
> print dump information into command-line named files instead of auto
> numbered filename. For example,

I'd wish you'd leave out this part for a followup.

>
> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>     -ftree-vectorizer-verbose=2
>     -fdump-tree-pre=foo.pre
>
> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>
> Please take another look.

--- tree-vect-loop-manip.c      (revision 188325)
+++ tree-vect-loop-manip.c      (working copy)
@@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
   gsi_remove (&loop_cond_gsi, true);

   loop_loc = find_loop_location (loop);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    {
-      if (loop_loc != UNKNOWN_LOC)
-        fprintf (dump_file, "\nloop at %s:%d: ",
+  if (loop_loc != UNKNOWN_LOC)
+    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
-    }
-
+  if (dump_flags & TDF_DETAILS)
+    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
   loop->nb_iterations = niters;

I'm confused by this.  Why is this not simply

  if (loop_loc != UNKNOWN_LOC)
    dump_printf (dump_flags, "\nloop at %s:%d: ",
                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);

for example.  I notice that you maybe mis-understood the message classification
I asked you to add (maybe I confused you by mentioning to eventually re-use
the TDF_* flags).  I think you basically provided this message classification
by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
But still in the above you keep a dump_flags test _and_ you pass in
(altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:

+void
+dump_gimple_stmt (int flags, gimple gs, int spc)
+{
+  if (dump_file)
+    print_gimple_stmt (dump_file, gs, spc, flags);
+}

+void
+diag_gimple_stmt (int flags, gimple gs, int spc)
+{
+  if (alt_dump_file)
+    print_gimple_stmt (alt_dump_file, gs, spc, flags);
+}

I'd say it should have been a single function:

void
dump_gimple_stmt (enum msg_classification, int additional_flags,
gimple gs, int spc)
{
  if (msg_classification & go-to-dumpfile
      && dump_file)
    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
  if (msg_classification & go-to-alt-dump-file
      && alt_dump_file && (alt_dump_flags & msg_classification))
    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
additional_flags);
}

where msg_classification would include things to suitably classify messages
for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.

In another place we have

@@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
   /* Analyze phi functions of the loop header.  */

   if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_can_advance_ivs_p:");
+    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");

so why's that diag_printf and why TDF_TREE?  I suppose you made all
dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
think it should have been

   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");

thus dump_printf only gets the msg-classification and the printf args
(dump-flags
are only meaningful when passed down to pretty-printers).  Thus

@@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
       phi = gsi_stmt (gsi);
       if (vect_print_dump_info (REPORT_DETAILS))
        {
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          diag_printf (TDF_TREE, "Analyze phi: ");
+          diag_gimple_stmt (TDF_SLIM, phi, 0);
        }

should be

  dump_printf (REPORT_DETAILS, "Analyze phi: ");
  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);

and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
the dump infrastructure provides and thus hidden.  Eventually we should
have a dump_kind (msg-classification) so we can replace it with

   if (dump_kind (REPORT_DETAILS))
     {
       dump_printf (REPORT_DETAILS, "Analyze phi: ");
       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
     }

to reduce the runtime overhead when not diagnosing/dumping.

@@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
     }

   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "created %u versioning for alias checks.\n",
-             VEC_length (ddr_p, may_alias_ddrs));
+    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
+                 VEC_length (ddr_p, may_alias_ddrs));
 }

so here we have a different msg-classification,
REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
-fopt-report=... we do not want to leave this implementation detail to
individual passes but gather them in a central place.

Thanks,
Richard.

> Thanks,
> Sharad
>
>
> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>> Sorry about the delay. I have finally incorporated all the suggestions
>>> and reorganized the dump infrastructure a bit. The attached patch
>>> updates vectorizer passes so that instead of accessing global
>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>> The dump_printf can choose between two streams, one regular pass dump
>>> file, and another optional command line provided file. Currently, it
>>> doesn't discriminate and all the dump information goes to both the
>>> streams.
>>>
>>> Thus, for example,
>>>
>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>
>> But the default form of dump option (-fdump-tree-vect) no longer
>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>> one of the main requirements). One dumped to the primary stream (named
>> dump file) and the other to the stderr -- the default diagnostic (alt)
>> stream.
>>
>> David
>>
>>>
>>> will output the verbose vectorizer information in both *.vect file and
>>> foo.v file. However, as I have converted only vectorizer passes so
>>> far, there is additional information in *.vect file which is not
>>> present in foo.v file. Once other passes are converted to use this
>>> scheme, then these two dump files should have identical output.
>>>
>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>> any auto named dump files as in my earlier patches. Instead the dump
>>> information is output to both places when a command line dump file
>>> option is provided.
>>>
>>> To summarize:
>>> - instead of using dump_begin () / dump_end (), the passes should use
>>> dump_start ()/dump_finish (). These new variants do not return the
>>> dump_file. However, they still set the global dump_file/dump_flags for
>>> the benefit of other passes during the transition.
>>> - instead of directly printing to the dump_file, as in
>>> if (dump_file)
>>>  fprintf (dump_file, ...);
>>>
>>> The passes should do
>>>
>>> dump_printf (dump_flag, ...);
>>> This will output to dump file(s) only when dump_flag is enabled for a
>>> given pass.
>>>
>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>
>>> Thanks,
>>> Sharad
>>>
>>>
>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>> <richard.guenther@gmail.com> wrote:
>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>
>>>>>>> The downside is that the dump file format will look different from the
>>>>>>> stderr output which is less than ideal.
>>>>>>
>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>
>>>>>
>>>>> I was talking about the transformation information difference. In
>>>>> stderr (where diagnostics go to), we may have
>>>>>
>>>>> foo.c: in function 'foo':
>>>>> foo.c:5:6: note: loop was vectorized
>>>>>
>>>>> but in dump file the format for the information may be different,
>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>
>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>
>>>> Richard.
>>>>
>>>>> David
>>>>>
>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-13 11:49                                 ` Richard Guenther
@ 2012-06-14  8:17                                   ` Sharad Singhai
  2012-06-14  9:13                                     ` Richard Guenther
  2012-06-15  8:13                                   ` Sharad Singhai
  1 sibling, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-06-14  8:17 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Thanks for your comments. Responses inline.

On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>> Okay, I have updated the attached patch so that the output from
>> -ftree-vectorizer-verbose is considered diagnostic information and is
>> always
>> sent to stderr. Other functionality remains unchanged. Here is some
>> more context about this patch.
>>
>> This patch improves the dump infrastructure and public interfaces so
>> that the existing private pass-specific dump stream is separated from
>> the diagnostic dump stream (typically stderr).  The optimization
>> passes can output information on the two streams independently.
>>
>> The newly defined interfaces are:
>>
>> Individual passes do not need to access the dump file directly. Thus Instead
>> of doing
>>
>>   if (dump_file && (flags & dump_flags))
>>      fprintf (dump_file, ...);
>>
>> they can do
>>
>>     dump_printf (flags, ...);
>>
>> If the current pass has FLAGS enabled then the information gets
>> printed into the dump file otherwise not.
>>
>> Similar to the dump_printf (), another function is defined, called
>>
>>        diag_printf (dump_flags, ...)
>>
>> This prints information only onto the diagnostic stream, typically
>> standard error. It is useful for separating pass-specific dump
>> information from
>> the diagnostic information.
>>
>> Currently, as a proof of concept, I have converted vectorizer passes
>> to use the new dump format. For this, I have considered
>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>> calls are changed to 'diag_printf'. Some other information printed to
>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>> helps to separate the two streams because they might serve different
>> purposes and might have different formatting requirements.
>>
>> For example, using the trunk compiler, the following invocation
>>
>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>
>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>> However, the verbose diagnostic output is silently
>> ignored. This is not desirable as the two types of dump should not interfere.
>>
>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>> as before, but the verbose vectorizer diagnostic is additionally
>> printed on stderr. Thus both types of dump information are output.
>>
>> An additional feature of this patch is that individual passes can
>> print dump information into command-line named files instead of auto
>> numbered filename. For example,
>
> I'd wish you'd leave out this part for a followup.

I thought you wanted all parts together. Anyway, I can remove this part.

>
>>
>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>     -ftree-vectorizer-verbose=2
>>     -fdump-tree-pre=foo.pre
>>
>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>
>> Please take another look.
>
> --- tree-vect-loop-manip.c      (revision 188325)
> +++ tree-vect-loop-manip.c      (working copy)
> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>   gsi_remove (&loop_cond_gsi, true);
>
>   loop_loc = find_loop_location (loop);
> -  if (dump_file && (dump_flags & TDF_DETAILS))
> -    {
> -      if (loop_loc != UNKNOWN_LOC)
> -        fprintf (dump_file, "\nloop at %s:%d: ",
> +  if (loop_loc != UNKNOWN_LOC)
> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
> -    }
> -
> +  if (dump_flags & TDF_DETAILS)
> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>   loop->nb_iterations = niters;
>
> I'm confused by this.  Why is this not simply
>
>  if (loop_loc != UNKNOWN_LOC)
>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>
> for example.  I notice that you maybe mis-understood the message classification
> I asked you to add (maybe I confused you by mentioning to eventually re-use
> the TDF_* flags).  I think you basically provided this message classification
> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
> But still in the above you keep a dump_flags test _and_ you pass in
> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>
> +void
> +dump_gimple_stmt (int flags, gimple gs, int spc)
> +{
> +  if (dump_file)
> +    print_gimple_stmt (dump_file, gs, spc, flags);
> +}
>
> +void
> +diag_gimple_stmt (int flags, gimple gs, int spc)
> +{
> +  if (alt_dump_file)
> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
> +}
>
> I'd say it should have been a single function:
>
> void
> dump_gimple_stmt (enum msg_classification, int additional_flags,
> gimple gs, int spc)
> {
>  if (msg_classification & go-to-dumpfile
>      && dump_file)
>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>  if (msg_classification & go-to-alt-dump-file
>      && alt_dump_file && (alt_dump_flags & msg_classification))
>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
> additional_flags);
> }

Okay.

> where msg_classification would include things to suitably classify messages
> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>
> In another place we have
>
> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>   /* Analyze phi functions of the loop header.  */
>
>   if (vect_print_dump_info (REPORT_DETAILS))
> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>
> so why's that diag_printf and why TDF_TREE?  I suppose you made all
> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
> think it should have been

Okay.

>
>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>
> thus dump_printf only gets the msg-classification and the printf args
> (dump-flags
> are only meaningful when passed down to pretty-printers).  Thus
>
> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>       phi = gsi_stmt (gsi);
>       if (vect_print_dump_info (REPORT_DETAILS))
>        {
> -          fprintf (vect_dump, "Analyze phi: ");
> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
> +          diag_printf (TDF_TREE, "Analyze phi: ");
> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>        }
>
> should be
>
>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>
> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
> the dump infrastructure provides and thus hidden.  Eventually we should
> have a dump_kind (msg-classification) so we can replace it with

I considered that, however, the vect_print_dump_info () uses
'vect_location' in a way that seems pass-specific. I didn't want to
make generic dump infrastructure aware of vectorizer-specific
reporting. Also, while more refactoring is possible, I don't know how
much people rely on the vectorizer pass dump output format. Anyway, I
will try to work around these limitations.

>
>   if (dump_kind (REPORT_DETAILS))
>     {
>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>     }
>
> to reduce the runtime overhead when not diagnosing/dumping.
>
> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>     }
>
>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
> -             VEC_length (ddr_p, may_alias_ddrs));
> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
> +                 VEC_length (ddr_p, may_alias_ddrs));
>  }
>
> so here we have a different msg-classification,
> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
> -fopt-report=... we do not want to leave this implementation detail to
> individual passes but gather them in a central place.

Okay. If I understand your comment right, you want all the different
REPORT_xxx handled in one place. Currently, vectorizer has about 10 of
such types in flag_types.h. All of these will become different
dump_kind flags under the new scheme and other passes will be free to
add more classification flags in future. Is that correct? If so, a
concern is that many of these flags could be very pass specific. For
example, since REPORT_VECTORIZED_LOCATION is not meaningful to other
passes, does it even deserve to be a msg classification?

Thanks,
Sharad

>
> Thanks,
> Richard.
>
>> Thanks,
>> Sharad
>>
>>
>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>> updates vectorizer passes so that instead of accessing global
>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>> The dump_printf can choose between two streams, one regular pass dump
>>>> file, and another optional command line provided file. Currently, it
>>>> doesn't discriminate and all the dump information goes to both the
>>>> streams.
>>>>
>>>> Thus, for example,
>>>>
>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>
>>> But the default form of dump option (-fdump-tree-vect) no longer
>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>> one of the main requirements). One dumped to the primary stream (named
>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>> stream.
>>>
>>> David
>>>
>>>>
>>>> will output the verbose vectorizer information in both *.vect file and
>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>> far, there is additional information in *.vect file which is not
>>>> present in foo.v file. Once other passes are converted to use this
>>>> scheme, then these two dump files should have identical output.
>>>>
>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>> information is output to both places when a command line dump file
>>>> option is provided.
>>>>
>>>> To summarize:
>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>> the benefit of other passes during the transition.
>>>> - instead of directly printing to the dump_file, as in
>>>> if (dump_file)
>>>>  fprintf (dump_file, ...);
>>>>
>>>> The passes should do
>>>>
>>>> dump_printf (dump_flag, ...);
>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>> given pass.
>>>>
>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>
>>>> Thanks,
>>>> Sharad
>>>>
>>>>
>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>> <richard.guenther@gmail.com> wrote:
>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>
>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>> stderr output which is less than ideal.
>>>>>>>
>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>
>>>>>>
>>>>>> I was talking about the transformation information difference. In
>>>>>> stderr (where diagnostics go to), we may have
>>>>>>
>>>>>> foo.c: in function 'foo':
>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>
>>>>>> but in dump file the format for the information may be different,
>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>
>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>
>>>>> Richard.
>>>>>
>>>>>> David
>>>>>>
>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-14  8:17                                   ` Sharad Singhai
@ 2012-06-14  9:13                                     ` Richard Guenther
  0 siblings, 0 replies; 71+ messages in thread
From: Richard Guenther @ 2012-06-14  9:13 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Thu, Jun 14, 2012 at 8:58 AM, Sharad Singhai <singhai@google.com> wrote:
> Thanks for your comments. Responses inline.
>
> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>>> Okay, I have updated the attached patch so that the output from
>>> -ftree-vectorizer-verbose is considered diagnostic information and is
>>> always
>>> sent to stderr. Other functionality remains unchanged. Here is some
>>> more context about this patch.
>>>
>>> This patch improves the dump infrastructure and public interfaces so
>>> that the existing private pass-specific dump stream is separated from
>>> the diagnostic dump stream (typically stderr).  The optimization
>>> passes can output information on the two streams independently.
>>>
>>> The newly defined interfaces are:
>>>
>>> Individual passes do not need to access the dump file directly. Thus Instead
>>> of doing
>>>
>>>   if (dump_file && (flags & dump_flags))
>>>      fprintf (dump_file, ...);
>>>
>>> they can do
>>>
>>>     dump_printf (flags, ...);
>>>
>>> If the current pass has FLAGS enabled then the information gets
>>> printed into the dump file otherwise not.
>>>
>>> Similar to the dump_printf (), another function is defined, called
>>>
>>>        diag_printf (dump_flags, ...)
>>>
>>> This prints information only onto the diagnostic stream, typically
>>> standard error. It is useful for separating pass-specific dump
>>> information from
>>> the diagnostic information.
>>>
>>> Currently, as a proof of concept, I have converted vectorizer passes
>>> to use the new dump format. For this, I have considered
>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>>> calls are changed to 'diag_printf'. Some other information printed to
>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>>> helps to separate the two streams because they might serve different
>>> purposes and might have different formatting requirements.
>>>
>>> For example, using the trunk compiler, the following invocation
>>>
>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>>
>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>>> However, the verbose diagnostic output is silently
>>> ignored. This is not desirable as the two types of dump should not interfere.
>>>
>>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>>> as before, but the verbose vectorizer diagnostic is additionally
>>> printed on stderr. Thus both types of dump information are output.
>>>
>>> An additional feature of this patch is that individual passes can
>>> print dump information into command-line named files instead of auto
>>> numbered filename. For example,
>>
>> I'd wish you'd leave out this part for a followup.
>
> I thought you wanted all parts together. Anyway, I can remove this part.
>
>>
>>>
>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>>     -ftree-vectorizer-verbose=2
>>>     -fdump-tree-pre=foo.pre
>>>
>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>>
>>> Please take another look.
>>
>> --- tree-vect-loop-manip.c      (revision 188325)
>> +++ tree-vect-loop-manip.c      (working copy)
>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>   gsi_remove (&loop_cond_gsi, true);
>>
>>   loop_loc = find_loop_location (loop);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    {
>> -      if (loop_loc != UNKNOWN_LOC)
>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>> +  if (loop_loc != UNKNOWN_LOC)
>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>> -    }
>> -
>> +  if (dump_flags & TDF_DETAILS)
>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>>   loop->nb_iterations = niters;
>>
>> I'm confused by this.  Why is this not simply
>>
>>  if (loop_loc != UNKNOWN_LOC)
>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>>
>> for example.  I notice that you maybe mis-understood the message classification
>> I asked you to add (maybe I confused you by mentioning to eventually re-use
>> the TDF_* flags).  I think you basically provided this message classification
>> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
>> But still in the above you keep a dump_flags test _and_ you pass in
>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>>
>> +void
>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>> +{
>> +  if (dump_file)
>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>> +}
>>
>> +void
>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>> +{
>> +  if (alt_dump_file)
>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>> +}
>>
>> I'd say it should have been a single function:
>>
>> void
>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>> gimple gs, int spc)
>> {
>>  if (msg_classification & go-to-dumpfile
>>      && dump_file)
>>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>>  if (msg_classification & go-to-alt-dump-file
>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>> additional_flags);
>> }
>
> Okay.
>
>> where msg_classification would include things to suitably classify messages
>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>>
>> In another place we have
>>
>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>   /* Analyze phi functions of the loop header.  */
>>
>>   if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>>
>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>> think it should have been
>
> Okay.
>
>>
>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>>
>> thus dump_printf only gets the msg-classification and the printf args
>> (dump-flags
>> are only meaningful when passed down to pretty-printers).  Thus
>>
>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>       phi = gsi_stmt (gsi);
>>       if (vect_print_dump_info (REPORT_DETAILS))
>>        {
>> -          fprintf (vect_dump, "Analyze phi: ");
>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>>        }
>>
>> should be
>>
>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>
>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>> the dump infrastructure provides and thus hidden.  Eventually we should
>> have a dump_kind (msg-classification) so we can replace it with
>
> I considered that, however, the vect_print_dump_info () uses
> 'vect_location' in a way that seems pass-specific. I didn't want to
> make generic dump infrastructure aware of vectorizer-specific
> reporting. Also, while more refactoring is possible, I don't know how
> much people rely on the vectorizer pass dump output format. Anyway, I
> will try to work around these limitations.

Ah, that's a good point - the dump_* routines should get a location argument
then (possibly mimcking what we do for tree builders, have the main
function be dump_*_loc (location_t, ...) and have a #define for dump_* which
passes UNKNOWN_LOCATION to dump_*_loc which can then refrain from
outputting any location prefix).

I suppose nobody relies on the vectorizer pass dump output format but
testcases in our testsuite.

>>
>>   if (dump_kind (REPORT_DETAILS))
>>     {
>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>     }
>>
>> to reduce the runtime overhead when not diagnosing/dumping.
>>
>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>     }
>>
>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>> -             VEC_length (ddr_p, may_alias_ddrs));
>> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
>> +                 VEC_length (ddr_p, may_alias_ddrs));
>>  }
>>
>> so here we have a different msg-classification,
>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>> -fopt-report=... we do not want to leave this implementation detail to
>> individual passes but gather them in a central place.
>
> Okay. If I understand your comment right, you want all the different
> REPORT_xxx handled in one place. Currently, vectorizer has about 10 of
> such types in flag_types.h. All of these will become different
> dump_kind flags under the new scheme and other passes will be free to
> add more classification flags in future. Is that correct? If so, a
> concern is that many of these flags could be very pass specific. For
> example, since REPORT_VECTORIZED_LOCATION is not meaningful to other
> passes, does it even deserve to be a msg classification?

Well, I suppose the generic name would be REPORT_OPTIMIZED_LOCATIONS
and REPORT_UNOPTIMIZED_LOCATIONS and if you dump information from
the vectorizer these naturally are about vectorized locations.  Thus,
-fopt-report=optimized,all for alll passes information on
optimizations or -fopt-report=optimized,vect for only vectorizer
information?  How do other compilers
allow to specify detail / transformation kind in this context?

Thus yes, try to use "common" report kinds, but I can envision that eventually
a few very specific ones will pop in.

Thanks,
Richard.

> Thanks,
> Sharad
>
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> Sharad
>>>
>>>
>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>>> updates vectorizer passes so that instead of accessing global
>>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>>> The dump_printf can choose between two streams, one regular pass dump
>>>>> file, and another optional command line provided file. Currently, it
>>>>> doesn't discriminate and all the dump information goes to both the
>>>>> streams.
>>>>>
>>>>> Thus, for example,
>>>>>
>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>>
>>>> But the default form of dump option (-fdump-tree-vect) no longer
>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>>> one of the main requirements). One dumped to the primary stream (named
>>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>>> stream.
>>>>
>>>> David
>>>>
>>>>>
>>>>> will output the verbose vectorizer information in both *.vect file and
>>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>>> far, there is additional information in *.vect file which is not
>>>>> present in foo.v file. Once other passes are converted to use this
>>>>> scheme, then these two dump files should have identical output.
>>>>>
>>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>>> information is output to both places when a command line dump file
>>>>> option is provided.
>>>>>
>>>>> To summarize:
>>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>>> the benefit of other passes during the transition.
>>>>> - instead of directly printing to the dump_file, as in
>>>>> if (dump_file)
>>>>>  fprintf (dump_file, ...);
>>>>>
>>>>> The passes should do
>>>>>
>>>>> dump_printf (dump_flag, ...);
>>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>>> given pass.
>>>>>
>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>>
>>>>> Thanks,
>>>>> Sharad
>>>>>
>>>>>
>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>>> <richard.guenther@gmail.com> wrote:
>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>
>>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>>> stderr output which is less than ideal.
>>>>>>>>
>>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>>
>>>>>>>
>>>>>>> I was talking about the transformation information difference. In
>>>>>>> stderr (where diagnostics go to), we may have
>>>>>>>
>>>>>>> foo.c: in function 'foo':
>>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>>
>>>>>>> but in dump file the format for the information may be different,
>>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>>
>>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>>
>>>>>> Richard.
>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-13 11:49                                 ` Richard Guenther
  2012-06-14  8:17                                   ` Sharad Singhai
@ 2012-06-15  8:13                                   ` Sharad Singhai
  2012-06-15  8:40                                     ` Richard Guenther
  1 sibling, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-06-15  8:13 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>> Okay, I have updated the attached patch so that the output from
>> -ftree-vectorizer-verbose is considered diagnostic information and is
>> always
>> sent to stderr. Other functionality remains unchanged. Here is some
>> more context about this patch.
>>
>> This patch improves the dump infrastructure and public interfaces so
>> that the existing private pass-specific dump stream is separated from
>> the diagnostic dump stream (typically stderr).  The optimization
>> passes can output information on the two streams independently.
>>
>> The newly defined interfaces are:
>>
>> Individual passes do not need to access the dump file directly. Thus Instead
>> of doing
>>
>>   if (dump_file && (flags & dump_flags))
>>      fprintf (dump_file, ...);
>>
>> they can do
>>
>>     dump_printf (flags, ...);
>>
>> If the current pass has FLAGS enabled then the information gets
>> printed into the dump file otherwise not.
>>
>> Similar to the dump_printf (), another function is defined, called
>>
>>        diag_printf (dump_flags, ...)
>>
>> This prints information only onto the diagnostic stream, typically
>> standard error. It is useful for separating pass-specific dump
>> information from
>> the diagnostic information.
>>
>> Currently, as a proof of concept, I have converted vectorizer passes
>> to use the new dump format. For this, I have considered
>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>> calls are changed to 'diag_printf'. Some other information printed to
>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>> helps to separate the two streams because they might serve different
>> purposes and might have different formatting requirements.
>>
>> For example, using the trunk compiler, the following invocation
>>
>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>
>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>> However, the verbose diagnostic output is silently
>> ignored. This is not desirable as the two types of dump should not interfere.
>>
>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>> as before, but the verbose vectorizer diagnostic is additionally
>> printed on stderr. Thus both types of dump information are output.
>>
>> An additional feature of this patch is that individual passes can
>> print dump information into command-line named files instead of auto
>> numbered filename. For example,
>
> I'd wish you'd leave out this part for a followup.
>
>>
>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>     -ftree-vectorizer-verbose=2
>>     -fdump-tree-pre=foo.pre
>>
>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>
>> Please take another look.
>
> --- tree-vect-loop-manip.c      (revision 188325)
> +++ tree-vect-loop-manip.c      (working copy)
> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>   gsi_remove (&loop_cond_gsi, true);
>
>   loop_loc = find_loop_location (loop);
> -  if (dump_file && (dump_flags & TDF_DETAILS))
> -    {
> -      if (loop_loc != UNKNOWN_LOC)
> -        fprintf (dump_file, "\nloop at %s:%d: ",
> +  if (loop_loc != UNKNOWN_LOC)
> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
> -    }
> -
> +  if (dump_flags & TDF_DETAILS)
> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>   loop->nb_iterations = niters;
>
> I'm confused by this.  Why is this not simply
>
>  if (loop_loc != UNKNOWN_LOC)
>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>
> for example.  I notice that you maybe mis-understood the message classification
> I asked you to add (maybe I confused you by mentioning to eventually re-use
> the TDF_* flags).  I think you basically provided this message classification
> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
> But still in the above you keep a dump_flags test _and_ you pass in
> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>
> +void
> +dump_gimple_stmt (int flags, gimple gs, int spc)
> +{
> +  if (dump_file)
> +    print_gimple_stmt (dump_file, gs, spc, flags);
> +}
>
> +void
> +diag_gimple_stmt (int flags, gimple gs, int spc)
> +{
> +  if (alt_dump_file)
> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
> +}
>
> I'd say it should have been a single function:
>
> void
> dump_gimple_stmt (enum msg_classification, int additional_flags,
> gimple gs, int spc)
> {
>  if (msg_classification & go-to-dumpfile
>      && dump_file)
>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>  if (msg_classification & go-to-alt-dump-file
>      && alt_dump_file && (alt_dump_flags & msg_classification))
>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
> additional_flags);
> }

Yes,  I can make the single function work for both regular (dump_file)
and diagnostic (stderr for now) dump streams. In fact, my original
patch did just that. However, it duplicated output on *both* the
streams. For example,

gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
-ftree-vectorizer-verbose=2 foo.c

Since both streams are enabled in this case, a call to dump_printf ()
would duplicate the information to both files, i.e., the dump and
diagnostic will be intermixed. Is that intended? My first thought was
to keep them separated via dump_*() and diag_* () methods.

Thanks,
Sharad

> where msg_classification would include things to suitably classify messages
> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>
> In another place we have
>
> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>   /* Analyze phi functions of the loop header.  */
>
>   if (vect_print_dump_info (REPORT_DETAILS))
> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>
> so why's that diag_printf and why TDF_TREE?  I suppose you made all
> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
> think it should have been
>
>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>
> thus dump_printf only gets the msg-classification and the printf args
> (dump-flags
> are only meaningful when passed down to pretty-printers).  Thus
>
> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>       phi = gsi_stmt (gsi);
>       if (vect_print_dump_info (REPORT_DETAILS))
>        {
> -          fprintf (vect_dump, "Analyze phi: ");
> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
> +          diag_printf (TDF_TREE, "Analyze phi: ");
> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>        }
>
> should be
>
>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>
> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
> the dump infrastructure provides and thus hidden.  Eventually we should
> have a dump_kind (msg-classification) so we can replace it with
>
>   if (dump_kind (REPORT_DETAILS))
>     {
>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>     }
>
> to reduce the runtime overhead when not diagnosing/dumping.
>
> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>     }
>
>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
> -             VEC_length (ddr_p, may_alias_ddrs));
> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
> +                 VEC_length (ddr_p, may_alias_ddrs));
>  }
>
> so here we have a different msg-classification,
> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
> -fopt-report=... we do not want to leave this implementation detail to
> individual passes but gather them in a central place.
>
> Thanks,
> Richard.
>
>> Thanks,
>> Sharad
>>
>>
>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>> updates vectorizer passes so that instead of accessing global
>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>> The dump_printf can choose between two streams, one regular pass dump
>>>> file, and another optional command line provided file. Currently, it
>>>> doesn't discriminate and all the dump information goes to both the
>>>> streams.
>>>>
>>>> Thus, for example,
>>>>
>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>
>>> But the default form of dump option (-fdump-tree-vect) no longer
>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>> one of the main requirements). One dumped to the primary stream (named
>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>> stream.
>>>
>>> David
>>>
>>>>
>>>> will output the verbose vectorizer information in both *.vect file and
>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>> far, there is additional information in *.vect file which is not
>>>> present in foo.v file. Once other passes are converted to use this
>>>> scheme, then these two dump files should have identical output.
>>>>
>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>> information is output to both places when a command line dump file
>>>> option is provided.
>>>>
>>>> To summarize:
>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>> the benefit of other passes during the transition.
>>>> - instead of directly printing to the dump_file, as in
>>>> if (dump_file)
>>>>  fprintf (dump_file, ...);
>>>>
>>>> The passes should do
>>>>
>>>> dump_printf (dump_flag, ...);
>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>> given pass.
>>>>
>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>
>>>> Thanks,
>>>> Sharad
>>>>
>>>>
>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>> <richard.guenther@gmail.com> wrote:
>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>
>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>> stderr output which is less than ideal.
>>>>>>>
>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>
>>>>>>
>>>>>> I was talking about the transformation information difference. In
>>>>>> stderr (where diagnostics go to), we may have
>>>>>>
>>>>>> foo.c: in function 'foo':
>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>
>>>>>> but in dump file the format for the information may be different,
>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>
>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>
>>>>> Richard.
>>>>>
>>>>>> David
>>>>>>
>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-15  8:13                                   ` Sharad Singhai
@ 2012-06-15  8:40                                     ` Richard Guenther
  2012-07-03 21:08                                       ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-06-15  8:40 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Fri, Jun 15, 2012 at 7:47 AM, Sharad Singhai <singhai@google.com> wrote:
> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>>> Okay, I have updated the attached patch so that the output from
>>> -ftree-vectorizer-verbose is considered diagnostic information and is
>>> always
>>> sent to stderr. Other functionality remains unchanged. Here is some
>>> more context about this patch.
>>>
>>> This patch improves the dump infrastructure and public interfaces so
>>> that the existing private pass-specific dump stream is separated from
>>> the diagnostic dump stream (typically stderr).  The optimization
>>> passes can output information on the two streams independently.
>>>
>>> The newly defined interfaces are:
>>>
>>> Individual passes do not need to access the dump file directly. Thus Instead
>>> of doing
>>>
>>>   if (dump_file && (flags & dump_flags))
>>>      fprintf (dump_file, ...);
>>>
>>> they can do
>>>
>>>     dump_printf (flags, ...);
>>>
>>> If the current pass has FLAGS enabled then the information gets
>>> printed into the dump file otherwise not.
>>>
>>> Similar to the dump_printf (), another function is defined, called
>>>
>>>        diag_printf (dump_flags, ...)
>>>
>>> This prints information only onto the diagnostic stream, typically
>>> standard error. It is useful for separating pass-specific dump
>>> information from
>>> the diagnostic information.
>>>
>>> Currently, as a proof of concept, I have converted vectorizer passes
>>> to use the new dump format. For this, I have considered
>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>>> calls are changed to 'diag_printf'. Some other information printed to
>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>>> helps to separate the two streams because they might serve different
>>> purposes and might have different formatting requirements.
>>>
>>> For example, using the trunk compiler, the following invocation
>>>
>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>>
>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>>> However, the verbose diagnostic output is silently
>>> ignored. This is not desirable as the two types of dump should not interfere.
>>>
>>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>>> as before, but the verbose vectorizer diagnostic is additionally
>>> printed on stderr. Thus both types of dump information are output.
>>>
>>> An additional feature of this patch is that individual passes can
>>> print dump information into command-line named files instead of auto
>>> numbered filename. For example,
>>
>> I'd wish you'd leave out this part for a followup.
>>
>>>
>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>>     -ftree-vectorizer-verbose=2
>>>     -fdump-tree-pre=foo.pre
>>>
>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>>
>>> Please take another look.
>>
>> --- tree-vect-loop-manip.c      (revision 188325)
>> +++ tree-vect-loop-manip.c      (working copy)
>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>   gsi_remove (&loop_cond_gsi, true);
>>
>>   loop_loc = find_loop_location (loop);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    {
>> -      if (loop_loc != UNKNOWN_LOC)
>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>> +  if (loop_loc != UNKNOWN_LOC)
>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>> -    }
>> -
>> +  if (dump_flags & TDF_DETAILS)
>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>>   loop->nb_iterations = niters;
>>
>> I'm confused by this.  Why is this not simply
>>
>>  if (loop_loc != UNKNOWN_LOC)
>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>>
>> for example.  I notice that you maybe mis-understood the message classification
>> I asked you to add (maybe I confused you by mentioning to eventually re-use
>> the TDF_* flags).  I think you basically provided this message classification
>> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
>> But still in the above you keep a dump_flags test _and_ you pass in
>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>>
>> +void
>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>> +{
>> +  if (dump_file)
>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>> +}
>>
>> +void
>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>> +{
>> +  if (alt_dump_file)
>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>> +}
>>
>> I'd say it should have been a single function:
>>
>> void
>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>> gimple gs, int spc)
>> {
>>  if (msg_classification & go-to-dumpfile
>>      && dump_file)
>>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>>  if (msg_classification & go-to-alt-dump-file
>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>> additional_flags);
>> }
>
> Yes,  I can make the single function work for both regular (dump_file)
> and diagnostic (stderr for now) dump streams. In fact, my original
> patch did just that. However, it duplicated output on *both* the
> streams. For example,
>
> gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
> -ftree-vectorizer-verbose=2 foo.c
>
> Since both streams are enabled in this case, a call to dump_printf ()
> would duplicate the information to both files, i.e., the dump and
> diagnostic will be intermixed. Is that intended? My first thought was
> to keep them separated via dump_*() and diag_* () methods.

No, I think that's intended.  The regular dump-files should contain
everything, the secondary stream (eventually enabled by -fopt-info)
should be a filtered regular dump-file.

Thanks,
Richard.

> Thanks,
> Sharad
>
>> where msg_classification would include things to suitably classify messages
>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>>
>> In another place we have
>>
>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>   /* Analyze phi functions of the loop header.  */
>>
>>   if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>>
>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>> think it should have been
>>
>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>>
>> thus dump_printf only gets the msg-classification and the printf args
>> (dump-flags
>> are only meaningful when passed down to pretty-printers).  Thus
>>
>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>       phi = gsi_stmt (gsi);
>>       if (vect_print_dump_info (REPORT_DETAILS))
>>        {
>> -          fprintf (vect_dump, "Analyze phi: ");
>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>>        }
>>
>> should be
>>
>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>
>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>> the dump infrastructure provides and thus hidden.  Eventually we should
>> have a dump_kind (msg-classification) so we can replace it with
>>
>>   if (dump_kind (REPORT_DETAILS))
>>     {
>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>     }
>>
>> to reduce the runtime overhead when not diagnosing/dumping.
>>
>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>     }
>>
>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>> -             VEC_length (ddr_p, may_alias_ddrs));
>> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
>> +                 VEC_length (ddr_p, may_alias_ddrs));
>>  }
>>
>> so here we have a different msg-classification,
>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>> -fopt-report=... we do not want to leave this implementation detail to
>> individual passes but gather them in a central place.
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> Sharad
>>>
>>>
>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>>> updates vectorizer passes so that instead of accessing global
>>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>>> The dump_printf can choose between two streams, one regular pass dump
>>>>> file, and another optional command line provided file. Currently, it
>>>>> doesn't discriminate and all the dump information goes to both the
>>>>> streams.
>>>>>
>>>>> Thus, for example,
>>>>>
>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>>
>>>> But the default form of dump option (-fdump-tree-vect) no longer
>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>>> one of the main requirements). One dumped to the primary stream (named
>>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>>> stream.
>>>>
>>>> David
>>>>
>>>>>
>>>>> will output the verbose vectorizer information in both *.vect file and
>>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>>> far, there is additional information in *.vect file which is not
>>>>> present in foo.v file. Once other passes are converted to use this
>>>>> scheme, then these two dump files should have identical output.
>>>>>
>>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>>> information is output to both places when a command line dump file
>>>>> option is provided.
>>>>>
>>>>> To summarize:
>>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>>> the benefit of other passes during the transition.
>>>>> - instead of directly printing to the dump_file, as in
>>>>> if (dump_file)
>>>>>  fprintf (dump_file, ...);
>>>>>
>>>>> The passes should do
>>>>>
>>>>> dump_printf (dump_flag, ...);
>>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>>> given pass.
>>>>>
>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>>
>>>>> Thanks,
>>>>> Sharad
>>>>>
>>>>>
>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>>> <richard.guenther@gmail.com> wrote:
>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>
>>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>>> stderr output which is less than ideal.
>>>>>>>>
>>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>>
>>>>>>>
>>>>>>> I was talking about the transformation information difference. In
>>>>>>> stderr (where diagnostics go to), we may have
>>>>>>>
>>>>>>> foo.c: in function 'foo':
>>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>>
>>>>>>> but in dump file the format for the information may be different,
>>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>>
>>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>>
>>>>>> Richard.
>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-06-15  8:40                                     ` Richard Guenther
@ 2012-07-03 21:08                                       ` Sharad Singhai
  2012-07-04 13:33                                         ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-07-03 21:08 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

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

Apologies for the spam. Attempting to resend the patch after shrinking it.

I have updated the attached patch to use a new dump message
classification system for the vectorizer. It currently uses four
classes, viz, MSG_OPTIMIZED_LOCATIONS, MSG_UNOPTIMIZED_LOCATION,
MSG_MISSING_OPTIMIZATION, and MSG_NOTE. I have gone through the
vectorizer passes and have converted each call to fprintf (dump_file,
....) to a message classification matching in spirit. Most often, it
is MSG_OPTIMIZED_LOCATIONS, but occasionally others as well.

For example, the following

if (vect_print_dump_info (REPORT_DETAILS))
  {
    fprintf (vect_dump, "niters for prolog loop: ");
    print_generic_expr (vect_dump, iters, TDF_SLIM);
  }

gets converted to

if (dump_kind (MSG_OPTIMIZED_LOCATIONS))
  {
     dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
                      "niters for prolog loop: ");
     dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
  }

The asymmetry between the first printf and the second is due to the
fact that 'vect_print_dump_info (xxx)' prints the location as a
"side-effect". To preserve the original intent somewhat, I have
converted the first call within a dump sequence to a dump_printf_loc
(xxx) which prints the location while the subsequence calls within the
same conditional get converted to the corresponding plain variants.

I considered removing the support for alternate dump file, but ended
up preserving it instead since it is needed for setting the alternate
dump file to stderr for the case when -fopt-info is given but no dump
file is available.

The following invocation
g++ ... -ftree-vectorize -fopt-info=4

dumps *all* available information to stderr. Currently, the opt-info
level is common to all passes, i.e., a pass can't specify if wants a
different level of diagnostic info. This can be added as an
enhancement with a suitable syntax for selecting passes.

I haven't fixed up the documentation/tests but wanted to get some
feedback about the current state of patch before doing that.

Thanks,
Sharad

On Fri, Jun 15, 2012 at 1:18 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Fri, Jun 15, 2012 at 7:47 AM, Sharad Singhai <singhai@google.com> wrote:
>> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>>>> Okay, I have updated the attached patch so that the output from
>>>> -ftree-vectorizer-verbose is considered diagnostic information and is
>>>> always
>>>> sent to stderr. Other functionality remains unchanged. Here is some
>>>> more context about this patch.
>>>>
>>>> This patch improves the dump infrastructure and public interfaces so
>>>> that the existing private pass-specific dump stream is separated from
>>>> the diagnostic dump stream (typically stderr).  The optimization
>>>> passes can output information on the two streams independently.
>>>>
>>>> The newly defined interfaces are:
>>>>
>>>> Individual passes do not need to access the dump file directly. Thus Instead
>>>> of doing
>>>>
>>>>   if (dump_file && (flags & dump_flags))
>>>>      fprintf (dump_file, ...);
>>>>
>>>> they can do
>>>>
>>>>     dump_printf (flags, ...);
>>>>
>>>> If the current pass has FLAGS enabled then the information gets
>>>> printed into the dump file otherwise not.
>>>>
>>>> Similar to the dump_printf (), another function is defined, called
>>>>
>>>>        diag_printf (dump_flags, ...)
>>>>
>>>> This prints information only onto the diagnostic stream, typically
>>>> standard error. It is useful for separating pass-specific dump
>>>> information from
>>>> the diagnostic information.
>>>>
>>>> Currently, as a proof of concept, I have converted vectorizer passes
>>>> to use the new dump format. For this, I have considered
>>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>>>> calls are changed to 'diag_printf'. Some other information printed to
>>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>>>> helps to separate the two streams because they might serve different
>>>> purposes and might have different formatting requirements.
>>>>
>>>> For example, using the trunk compiler, the following invocation
>>>>
>>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>>>
>>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>>>> However, the verbose diagnostic output is silently
>>>> ignored. This is not desirable as the two types of dump should not interfere.
>>>>
>>>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>>>> as before, but the verbose vectorizer diagnostic is additionally
>>>> printed on stderr. Thus both types of dump information are output.
>>>>
>>>> An additional feature of this patch is that individual passes can
>>>> print dump information into command-line named files instead of auto
>>>> numbered filename. For example,
>>>
>>> I'd wish you'd leave out this part for a followup.
>>>
>>>>
>>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>>>     -ftree-vectorizer-verbose=2
>>>>     -fdump-tree-pre=foo.pre
>>>>
>>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>>>
>>>> Please take another look.
>>>
>>> --- tree-vect-loop-manip.c      (revision 188325)
>>> +++ tree-vect-loop-manip.c      (working copy)
>>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>>   gsi_remove (&loop_cond_gsi, true);
>>>
>>>   loop_loc = find_loop_location (loop);
>>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>>> -    {
>>> -      if (loop_loc != UNKNOWN_LOC)
>>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>>> +  if (loop_loc != UNKNOWN_LOC)
>>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>>> -    }
>>> -
>>> +  if (dump_flags & TDF_DETAILS)
>>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>>>   loop->nb_iterations = niters;
>>>
>>> I'm confused by this.  Why is this not simply
>>>
>>>  if (loop_loc != UNKNOWN_LOC)
>>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>>>
>>> for example.  I notice that you maybe mis-understood the message classification
>>> I asked you to add (maybe I confused you by mentioning to eventually re-use
>>> the TDF_* flags).  I think you basically provided this message classification
>>> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
>>> But still in the above you keep a dump_flags test _and_ you pass in
>>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>>>
>>> +void
>>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>>> +{
>>> +  if (dump_file)
>>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>>> +}
>>>
>>> +void
>>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>>> +{
>>> +  if (alt_dump_file)
>>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>>> +}
>>>
>>> I'd say it should have been a single function:
>>>
>>> void
>>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>>> gimple gs, int spc)
>>> {
>>>  if (msg_classification & go-to-dumpfile
>>>      && dump_file)
>>>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>>>  if (msg_classification & go-to-alt-dump-file
>>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>>> additional_flags);
>>> }
>>
>> Yes,  I can make the single function work for both regular (dump_file)
>> and diagnostic (stderr for now) dump streams. In fact, my original
>> patch did just that. However, it duplicated output on *both* the
>> streams. For example,
>>
>> gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
>> -ftree-vectorizer-verbose=2 foo.c
>>
>> Since both streams are enabled in this case, a call to dump_printf ()
>> would duplicate the information to both files, i.e., the dump and
>> diagnostic will be intermixed. Is that intended? My first thought was
>> to keep them separated via dump_*() and diag_* () methods.
>
> No, I think that's intended.  The regular dump-files should contain
> everything, the secondary stream (eventually enabled by -fopt-info)
> should be a filtered regular dump-file.
>
> Thanks,
> Richard.
>
>> Thanks,
>> Sharad
>>
>>> where msg_classification would include things to suitably classify messages
>>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>>>
>>> In another place we have
>>>
>>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>>   /* Analyze phi functions of the loop header.  */
>>>
>>>   if (vect_print_dump_info (REPORT_DETAILS))
>>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>>>
>>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>>> think it should have been
>>>
>>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>>>
>>> thus dump_printf only gets the msg-classification and the printf args
>>> (dump-flags
>>> are only meaningful when passed down to pretty-printers).  Thus
>>>
>>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>>       phi = gsi_stmt (gsi);
>>>       if (vect_print_dump_info (REPORT_DETAILS))
>>>        {
>>> -          fprintf (vect_dump, "Analyze phi: ");
>>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>>>        }
>>>
>>> should be
>>>
>>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>>
>>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>>> the dump infrastructure provides and thus hidden.  Eventually we should
>>> have a dump_kind (msg-classification) so we can replace it with
>>>
>>>   if (dump_kind (REPORT_DETAILS))
>>>     {
>>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>>     }
>>>
>>> to reduce the runtime overhead when not diagnosing/dumping.
>>>
>>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>>     }
>>>
>>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>>> -             VEC_length (ddr_p, may_alias_ddrs));
>>> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
>>> +                 VEC_length (ddr_p, may_alias_ddrs));
>>>  }
>>>
>>> so here we have a different msg-classification,
>>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>>> -fopt-report=... we do not want to leave this implementation detail to
>>> individual passes but gather them in a central place.
>>>
>>> Thanks,
>>> Richard.
>>>
>>>> Thanks,
>>>> Sharad
>>>>
>>>>
>>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>>>> updates vectorizer passes so that instead of accessing global
>>>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>>>> The dump_printf can choose between two streams, one regular pass dump
>>>>>> file, and another optional command line provided file. Currently, it
>>>>>> doesn't discriminate and all the dump information goes to both the
>>>>>> streams.
>>>>>>
>>>>>> Thus, for example,
>>>>>>
>>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>>>
>>>>> But the default form of dump option (-fdump-tree-vect) no longer
>>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>>>> one of the main requirements). One dumped to the primary stream (named
>>>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>>>> stream.
>>>>>
>>>>> David
>>>>>
>>>>>>
>>>>>> will output the verbose vectorizer information in both *.vect file and
>>>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>>>> far, there is additional information in *.vect file which is not
>>>>>> present in foo.v file. Once other passes are converted to use this
>>>>>> scheme, then these two dump files should have identical output.
>>>>>>
>>>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>>>> information is output to both places when a command line dump file
>>>>>> option is provided.
>>>>>>
>>>>>> To summarize:
>>>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>>>> the benefit of other passes during the transition.
>>>>>> - instead of directly printing to the dump_file, as in
>>>>>> if (dump_file)
>>>>>>  fprintf (dump_file, ...);
>>>>>>
>>>>>> The passes should do
>>>>>>
>>>>>> dump_printf (dump_flag, ...);
>>>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>>>> given pass.
>>>>>>
>>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>>>
>>>>>> Thanks,
>>>>>> Sharad
>>>>>>
>>>>>>
>>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>>>> <richard.guenther@gmail.com> wrote:
>>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>>
>>>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>>>> stderr output which is less than ideal.
>>>>>>>>>
>>>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>>>
>>>>>>>>
>>>>>>>> I was talking about the transformation information difference. In
>>>>>>>> stderr (where diagnostics go to), we may have
>>>>>>>>
>>>>>>>> foo.c: in function 'foo':
>>>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>>>
>>>>>>>> but in dump file the format for the information may be different,
>>>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>>>
>>>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>>>
>>>>>>> Richard.
>>>>>>>
>>>>>>>> David
>>>>>>>>
>>>>>>>>> -- Gaby

[-- Attachment #2: msg_classification.1.diff.bz2 --]
[-- Type: application/x-bzip2, Size: 39329 bytes --]

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-07-03 21:08                                       ` Sharad Singhai
@ 2012-07-04 13:33                                         ` Richard Guenther
  2012-08-24  8:07                                           ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-07-04 13:33 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Tue, Jul 3, 2012 at 11:07 PM, Sharad Singhai <singhai@google.com> wrote:
> Apologies for the spam. Attempting to resend the patch after shrinking it.
>
> I have updated the attached patch to use a new dump message
> classification system for the vectorizer. It currently uses four
> classes, viz, MSG_OPTIMIZED_LOCATIONS, MSG_UNOPTIMIZED_LOCATION,
> MSG_MISSING_OPTIMIZATION, and MSG_NOTE. I have gone through the
> vectorizer passes and have converted each call to fprintf (dump_file,
> ....) to a message classification matching in spirit. Most often, it
> is MSG_OPTIMIZED_LOCATIONS, but occasionally others as well.
>
> For example, the following
>
> if (vect_print_dump_info (REPORT_DETAILS))
>   {
>     fprintf (vect_dump, "niters for prolog loop: ");
>     print_generic_expr (vect_dump, iters, TDF_SLIM);
>   }
>
> gets converted to
>
> if (dump_kind (MSG_OPTIMIZED_LOCATIONS))
>   {
>      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>                       "niters for prolog loop: ");
>      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
>   }
>
> The asymmetry between the first printf and the second is due to the
> fact that 'vect_print_dump_info (xxx)' prints the location as a
> "side-effect". To preserve the original intent somewhat, I have
> converted the first call within a dump sequence to a dump_printf_loc
> (xxx) which prints the location while the subsequence calls within the
> same conditional get converted to the corresponding plain variants.

Ok, that looks reasonable.

> I considered removing the support for alternate dump file, but ended
> up preserving it instead since it is needed for setting the alternate
> dump file to stderr for the case when -fopt-info is given but no dump
> file is available.
>
> The following invocation
> g++ ... -ftree-vectorize -fopt-info=4
>
> dumps *all* available information to stderr. Currently, the opt-info
> level is common to all passes, i.e., a pass can't specify if wants a
> different level of diagnostic info. This can be added as an
> enhancement with a suitable syntax for selecting passes.
>
> I haven't fixed up the documentation/tests but wanted to get some
> feedback about the current state of patch before doing that.

Some comments / questions.

+  if (dump_file && (dump_kind & opt_info_flags))
+    {
+      dump_loc (dump_kind, dump_file, loc);
+      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
+    }
+
+  if (alt_dump_file && (dump_kind & opt_info_flags))
+    {

you always test dump_kind against the same opt_info_flags variable.
I would have thought that the alternate dump file has a different opt_info_flags
setting so I can have -fdump-tree-vect-details -fopt-info=1.  Am I missing
something?

If I do

> gcc file1.c file2.c -O3 -fdump-tree-vectorize=foo

what will foo contain afterwards?  I think you need to document the behavior
when such redirection is used with the compiler-driver feature of handling
multiple translation units.  Especially the difference (or not difference) to

> gcc file1.c -O3 -fdump-tree-vectorize=foo
> gcc file2.c -O3 -fdump-tree-vectorize=foo

I suppose we do not want to append to foo (but eventually support that
with some alternate syntax?  Like -fdump-tree-vectorize=+foo?)

+
+static void
+set_opt_info (int opt_info_level)
+{

This function needs a comment.  How do the dump flags translate to
the opt-info flags?  Is this documented anywhere?  I only see

+/* Different types of dump classifications.  */
+enum dump_msg_kind {
+  MSG_NONE                     = 1 << 0,
+  MSG_OPTIMIZED_LOCATIONS      = 1 << 1,
+  MSG_UNOPTIMIZED_LOCATIONS    = 1 << 2,
+  MSG_MISSED_OPTIMIZATION      = 1 << 3,
+  MSG_NOTE                     = 1 << 4
+};

I suppose the TDF_* flags would all map to
MSG_OPTIMIZED_LOCATIONS|MSG_UNOPTIMIZED_LOCATIONS|MSG_MISSED_OPTIMIZATION
and only TDF_DETAILS would enable MSG_NOTE?

In the above a flag for MSG_NONE does not make much sense?

How would we map TDF_SCEV?  I suppose we'd add MSG_SCEV for this
(we talked about the possibility of having some special flags for
special passes).

But this also means a linear "opt-info-level" as in

+static void
+set_opt_info (int opt_info_level)

may not be a good representation.  Not a pass-ignorant opt_info_flags
value, if you consider -fopt-info=vect,3 (details from the vectorizer please).

+}
+
+
+
+DEBUG_FUNCTION void
+dump_combine_stats (int flags)

debug functions should be called debug_*, please add a comment and
avoid excessive vertical space

Index: tree-pass.h
===================================================================
--- tree-pass.h (revision 188966)
+++ tree-pass.h (working copy)
@@ -85,7 +85,6 @@ enum tree_dump_index
 #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
 #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */

-
 /* In tree-dump.c */

 extern char *get_dump_file_name (int);

please avoid whitespace-only changes (also elsewhere).

 /* Global variables used to communicate with passes.  */
 extern FILE *dump_file;
+extern FILE *alt_dump_file;
 extern int dump_flags;
+extern int opt_info_flags;

so I expected the primary dump_file to be controlled with dump_flags,
or with a (cached) translation of them to a primary_opt_info_flags.

Index: gimple-pretty-print.h
===================================================================
--- gimple-pretty-print.h       (revision 188966)
+++ gimple-pretty-print.h       (working copy)
@@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
 extern void print_gimple_stmt (FILE *, gimple, int, int);
 extern void print_gimple_expr (FILE *, gimple, int, int);
-extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
+extern void print_gimple_stmt_1 (pretty_printer *, gimple, int, int);

I'd call this pp_gimple_stmt instead.

@@ -1418,6 +1419,16 @@ init_branch_prob (void)
 void
 end_branch_prob (void)
 {
+  end_branch_prob_1 (dump_file);
+  end_branch_prob_1 (alt_dump_file);
+}
+
+/* Helper function for file-level cleanup for DUMP_FILE after
+   branch-prob processing is completed. */
+
+static void
+end_branch_prob_1 (FILE *dump_file)
+{
   if (dump_file)
     {
       fprintf (dump_file, "\n");

That change looks odd ;)  Can you instead use the new dump_printf
interface?  (side-note: we should not need to export alt_dump_file at all!)

@@ -2166,10 +2177,6 @@ ftree-vect-loop-version
 Common Report Var(flag_tree_vect_loop_version) Init(1) Optimization
 Enable loop versioning when doing loop vectorization on trees

-ftree-vectorizer-verbose=
-Common RejectNegative Joined UInteger
--ftree-vectorizer-verbose=<number>     Set the verbosity level of the
vectorizer
-

we need to preserve old switches for backward compatibility, I suggest
to alias it to -fopt-info for now.

@@ -13909,7 +13909,7 @@ unmentioned_reg_p (rtx equiv, rtx expr)
 }
 ^L
 DEBUG_FUNCTION void
-dump_combine_stats (FILE *file)
+print_combine_stats (FILE *file)

see above, debug_combine_stats.

Index: system.h
===================================================================
--- system.h    (revision 188966)
+++ system.h    (working copy)
@@ -669,6 +669,7 @@ extern int vsnprintf(char *, size_t, const char *,
    except, maybe, something to the dump file.  */
 #ifdef BUFSIZ
 extern FILE *dump_file;
+extern FILE *alt_dump_file;

see above - we should not need to export this (nor opt_info_flags).

Overall I like the patch!

Thanks,
Richard.

> Thanks,
> Sharad
>
> On Fri, Jun 15, 2012 at 1:18 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Fri, Jun 15, 2012 at 7:47 AM, Sharad Singhai <singhai@google.com> wrote:
>>> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
>>> <richard.guenther@gmail.com> wrote:
>>>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>> Okay, I have updated the attached patch so that the output from
>>>>> -ftree-vectorizer-verbose is considered diagnostic information and is
>>>>> always
>>>>> sent to stderr. Other functionality remains unchanged. Here is some
>>>>> more context about this patch.
>>>>>
>>>>> This patch improves the dump infrastructure and public interfaces so
>>>>> that the existing private pass-specific dump stream is separated from
>>>>> the diagnostic dump stream (typically stderr).  The optimization
>>>>> passes can output information on the two streams independently.
>>>>>
>>>>> The newly defined interfaces are:
>>>>>
>>>>> Individual passes do not need to access the dump file directly. Thus Instead
>>>>> of doing
>>>>>
>>>>>   if (dump_file && (flags & dump_flags))
>>>>>      fprintf (dump_file, ...);
>>>>>
>>>>> they can do
>>>>>
>>>>>     dump_printf (flags, ...);
>>>>>
>>>>> If the current pass has FLAGS enabled then the information gets
>>>>> printed into the dump file otherwise not.
>>>>>
>>>>> Similar to the dump_printf (), another function is defined, called
>>>>>
>>>>>        diag_printf (dump_flags, ...)
>>>>>
>>>>> This prints information only onto the diagnostic stream, typically
>>>>> standard error. It is useful for separating pass-specific dump
>>>>> information from
>>>>> the diagnostic information.
>>>>>
>>>>> Currently, as a proof of concept, I have converted vectorizer passes
>>>>> to use the new dump format. For this, I have considered
>>>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>>>>> calls are changed to 'diag_printf'. Some other information printed to
>>>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>>>>> helps to separate the two streams because they might serve different
>>>>> purposes and might have different formatting requirements.
>>>>>
>>>>> For example, using the trunk compiler, the following invocation
>>>>>
>>>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>>>>
>>>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>>>>> However, the verbose diagnostic output is silently
>>>>> ignored. This is not desirable as the two types of dump should not interfere.
>>>>>
>>>>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>>>>> as before, but the verbose vectorizer diagnostic is additionally
>>>>> printed on stderr. Thus both types of dump information are output.
>>>>>
>>>>> An additional feature of this patch is that individual passes can
>>>>> print dump information into command-line named files instead of auto
>>>>> numbered filename. For example,
>>>>
>>>> I'd wish you'd leave out this part for a followup.
>>>>
>>>>>
>>>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>>>>     -ftree-vectorizer-verbose=2
>>>>>     -fdump-tree-pre=foo.pre
>>>>>
>>>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>>>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>>>>
>>>>> Please take another look.
>>>>
>>>> --- tree-vect-loop-manip.c      (revision 188325)
>>>> +++ tree-vect-loop-manip.c      (working copy)
>>>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>>>   gsi_remove (&loop_cond_gsi, true);
>>>>
>>>>   loop_loc = find_loop_location (loop);
>>>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>>>> -    {
>>>> -      if (loop_loc != UNKNOWN_LOC)
>>>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>>>> +  if (loop_loc != UNKNOWN_LOC)
>>>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>>>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>>>> -    }
>>>> -
>>>> +  if (dump_flags & TDF_DETAILS)
>>>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>>>>   loop->nb_iterations = niters;
>>>>
>>>> I'm confused by this.  Why is this not simply
>>>>
>>>>  if (loop_loc != UNKNOWN_LOC)
>>>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>>>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>>>>
>>>> for example.  I notice that you maybe mis-understood the message classification
>>>> I asked you to add (maybe I confused you by mentioning to eventually re-use
>>>> the TDF_* flags).  I think you basically provided this message classification
>>>> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
>>>> But still in the above you keep a dump_flags test _and_ you pass in
>>>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>>>>
>>>> +void
>>>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>>>> +{
>>>> +  if (dump_file)
>>>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>>>> +}
>>>>
>>>> +void
>>>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>>>> +{
>>>> +  if (alt_dump_file)
>>>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>>>> +}
>>>>
>>>> I'd say it should have been a single function:
>>>>
>>>> void
>>>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>>>> gimple gs, int spc)
>>>> {
>>>>  if (msg_classification & go-to-dumpfile
>>>>      && dump_file)
>>>>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>>>>  if (msg_classification & go-to-alt-dump-file
>>>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>>>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>>>> additional_flags);
>>>> }
>>>
>>> Yes,  I can make the single function work for both regular (dump_file)
>>> and diagnostic (stderr for now) dump streams. In fact, my original
>>> patch did just that. However, it duplicated output on *both* the
>>> streams. For example,
>>>
>>> gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
>>> -ftree-vectorizer-verbose=2 foo.c
>>>
>>> Since both streams are enabled in this case, a call to dump_printf ()
>>> would duplicate the information to both files, i.e., the dump and
>>> diagnostic will be intermixed. Is that intended? My first thought was
>>> to keep them separated via dump_*() and diag_* () methods.
>>
>> No, I think that's intended.  The regular dump-files should contain
>> everything, the secondary stream (eventually enabled by -fopt-info)
>> should be a filtered regular dump-file.
>>
>> Thanks,
>> Richard.
>>
>>> Thanks,
>>> Sharad
>>>
>>>> where msg_classification would include things to suitably classify messages
>>>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>>>>
>>>> In another place we have
>>>>
>>>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>>>   /* Analyze phi functions of the loop header.  */
>>>>
>>>>   if (vect_print_dump_info (REPORT_DETAILS))
>>>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>>>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>>>>
>>>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>>>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>>>> think it should have been
>>>>
>>>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>>>>
>>>> thus dump_printf only gets the msg-classification and the printf args
>>>> (dump-flags
>>>> are only meaningful when passed down to pretty-printers).  Thus
>>>>
>>>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>>>       phi = gsi_stmt (gsi);
>>>>       if (vect_print_dump_info (REPORT_DETAILS))
>>>>        {
>>>> -          fprintf (vect_dump, "Analyze phi: ");
>>>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>>>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>>>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>>>>        }
>>>>
>>>> should be
>>>>
>>>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>>>
>>>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>>>> the dump infrastructure provides and thus hidden.  Eventually we should
>>>> have a dump_kind (msg-classification) so we can replace it with
>>>>
>>>>   if (dump_kind (REPORT_DETAILS))
>>>>     {
>>>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>>>     }
>>>>
>>>> to reduce the runtime overhead when not diagnosing/dumping.
>>>>
>>>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>>>     }
>>>>
>>>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>>>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>>>> -             VEC_length (ddr_p, may_alias_ddrs));
>>>> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
>>>> +                 VEC_length (ddr_p, may_alias_ddrs));
>>>>  }
>>>>
>>>> so here we have a different msg-classification,
>>>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>>>> -fopt-report=... we do not want to leave this implementation detail to
>>>> individual passes but gather them in a central place.
>>>>
>>>> Thanks,
>>>> Richard.
>>>>
>>>>> Thanks,
>>>>> Sharad
>>>>>
>>>>>
>>>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>>>>> updates vectorizer passes so that instead of accessing global
>>>>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>>>>> The dump_printf can choose between two streams, one regular pass dump
>>>>>>> file, and another optional command line provided file. Currently, it
>>>>>>> doesn't discriminate and all the dump information goes to both the
>>>>>>> streams.
>>>>>>>
>>>>>>> Thus, for example,
>>>>>>>
>>>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>>>>
>>>>>> But the default form of dump option (-fdump-tree-vect) no longer
>>>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>>>>> one of the main requirements). One dumped to the primary stream (named
>>>>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>>>>> stream.
>>>>>>
>>>>>> David
>>>>>>
>>>>>>>
>>>>>>> will output the verbose vectorizer information in both *.vect file and
>>>>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>>>>> far, there is additional information in *.vect file which is not
>>>>>>> present in foo.v file. Once other passes are converted to use this
>>>>>>> scheme, then these two dump files should have identical output.
>>>>>>>
>>>>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>>>>> information is output to both places when a command line dump file
>>>>>>> option is provided.
>>>>>>>
>>>>>>> To summarize:
>>>>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>>>>> the benefit of other passes during the transition.
>>>>>>> - instead of directly printing to the dump_file, as in
>>>>>>> if (dump_file)
>>>>>>>  fprintf (dump_file, ...);
>>>>>>>
>>>>>>> The passes should do
>>>>>>>
>>>>>>> dump_printf (dump_flag, ...);
>>>>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>>>>> given pass.
>>>>>>>
>>>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Sharad
>>>>>>>
>>>>>>>
>>>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>>>>> <richard.guenther@gmail.com> wrote:
>>>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>>>
>>>>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>>>>> stderr output which is less than ideal.
>>>>>>>>>>
>>>>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> I was talking about the transformation information difference. In
>>>>>>>>> stderr (where diagnostics go to), we may have
>>>>>>>>>
>>>>>>>>> foo.c: in function 'foo':
>>>>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>>>>
>>>>>>>>> but in dump file the format for the information may be different,
>>>>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>>>>
>>>>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>>>>
>>>>>>>> Richard.
>>>>>>>>
>>>>>>>>> David
>>>>>>>>>
>>>>>>>>>> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-07-04 13:33                                         ` Richard Guenther
@ 2012-08-24  8:07                                           ` Sharad Singhai
       [not found]                                             ` <CAKxPW67Nn9YSwH_xwFXBM7=y=32s_HpQ4fUAE+E8GoRSsVjxbA@mail.gmail.com>
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-08-24  8:07 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

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

Sorry about the delay. Please see comments inline.

On Wed, Jul 4, 2012 at 6:33 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Tue, Jul 3, 2012 at 11:07 PM, Sharad Singhai <singhai@google.com> wrote:
>> Apologies for the spam. Attempting to resend the patch after shrinking it.
>>
>> I have updated the attached patch to use a new dump message
>> classification system for the vectorizer. It currently uses four
>> classes, viz, MSG_OPTIMIZED_LOCATIONS, MSG_UNOPTIMIZED_LOCATION,
>> MSG_MISSING_OPTIMIZATION, and MSG_NOTE. I have gone through the
>> vectorizer passes and have converted each call to fprintf (dump_file,
>> ....) to a message classification matching in spirit. Most often, it
>> is MSG_OPTIMIZED_LOCATIONS, but occasionally others as well.
>>
>> For example, the following
>>
>> if (vect_print_dump_info (REPORT_DETAILS))
>>   {
>>     fprintf (vect_dump, "niters for prolog loop: ");
>>     print_generic_expr (vect_dump, iters, TDF_SLIM);
>>   }
>>
>> gets converted to
>>
>> if (dump_kind (MSG_OPTIMIZED_LOCATIONS))
>>   {
>>      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>>                       "niters for prolog loop: ");
>>      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
>>   }
>>
>> The asymmetry between the first printf and the second is due to the
>> fact that 'vect_print_dump_info (xxx)' prints the location as a
>> "side-effect". To preserve the original intent somewhat, I have
>> converted the first call within a dump sequence to a dump_printf_loc
>> (xxx) which prints the location while the subsequence calls within the
>> same conditional get converted to the corresponding plain variants.
>
> Ok, that looks reasonable.
>
>> I considered removing the support for alternate dump file, but ended
>> up preserving it instead since it is needed for setting the alternate
>> dump file to stderr for the case when -fopt-info is given but no dump
>> file is available.
>>
>> The following invocation
>> g++ ... -ftree-vectorize -fopt-info=4
>>
>> dumps *all* available information to stderr. Currently, the opt-info
>> level is common to all passes, i.e., a pass can't specify if wants a
>> different level of diagnostic info. This can be added as an
>> enhancement with a suitable syntax for selecting passes.
>>
>> I haven't fixed up the documentation/tests but wanted to get some
>> feedback about the current state of patch before doing that.
>
> Some comments / questions.
>
> +  if (dump_file && (dump_kind & opt_info_flags))
> +    {
> +      dump_loc (dump_kind, dump_file, loc);
> +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
> +    }
> +
> +  if (alt_dump_file && (dump_kind & opt_info_flags))
> +    {
>
> you always test dump_kind against the same opt_info_flags variable.
> I would have thought that the alternate dump file has a different opt_info_flags
> setting so I can have -fdump-tree-vect-details -fopt-info=1.  Am I missing
> something?

It was an oversight on my part. I have since fixed this. There are two
separate flags corresponding to the two types of dump files,

pflags ==> pass private dump file
alt_flags ==> opt-info dump file

> If I do
>
>> gcc file1.c file2.c -O3 -fdump-tree-vectorize=foo
>
> what will foo contain afterwards?  I think you need to document the behavior
> when such redirection is used with the compiler-driver feature of handling
> multiple translation units.  Especially the difference (or not difference) to
>
>> gcc file1.c -O3 -fdump-tree-vectorize=foo
>> gcc file2.c -O3 -fdump-tree-vectorize=foo

Yes, the dump file gets overwritten during each invocation. I have
noted this in the documentation.

> I suppose we do not want to append to foo (but eventually support that
> with some alternate syntax?  Like -fdump-tree-vectorize=+foo?)

Yes, I agree. We could define a new syntax as you suggested for
appending to a dump file. However, this feature can wait for a
separate patch.

> +
> +static void
> +set_opt_info (int opt_info_level)
> +{
>
> This function needs a comment.  How do the dump flags translate to
> the opt-info flags?  Is this documented anywhere?  I only see
>
> +/* Different types of dump classifications.  */
> +enum dump_msg_kind {
> +  MSG_NONE                     = 1 << 0,
> +  MSG_OPTIMIZED_LOCATIONS      = 1 << 1,
> +  MSG_UNOPTIMIZED_LOCATIONS    = 1 << 2,
> +  MSG_MISSED_OPTIMIZATION      = 1 << 3,
> +  MSG_NOTE                     = 1 << 4
> +};

Yes, my mapping was static (pass-agnostic), defined inside the set_opt_info. I
have now documented it and revamped it so that -fopt-info is applied
to specific passes as explained below.

> I suppose the TDF_* flags would all map to
> MSG_OPTIMIZED_LOCATIONS|MSG_UNOPTIMIZED_LOCATIONS|MSG_MISSED_OPTIMIZATION
> and only TDF_DETAILS would enable MSG_NOTE?

Yes, the mapping is very coarse-grained right now. Currently I have
made MSG_* flags an extension of TDF_* flags. This way both kinds of
flags can be present in a single word yet still be interpreted by the
dumps which are interested in them. TDF_DETAILS gets mapped to a union
of all the MSG_* flags. This will allow flags such -fdump-vect-details
to continue to work as expected during the transition to the new dump
infrastructure. Of coure,  during the transition, we would need to
rejigger flags to express the desired behavior.

> In the above a flag for MSG_NONE does not make much sense?

Removed. It is now implicitly 0.

>
> How would we map TDF_SCEV?  I suppose we'd add MSG_SCEV for this
> (we talked about the possibility of having some special flags for
> special passes).

Yes, I think this would be necessary. So far, I haven't converted any
passes other than vectorization, and I suspect a handful of special
case flags would be needed. During the transition, the TDF_* flags are
assumed to be an extension of MSG_* flags and things won't break.

>
> But this also means a linear "opt-info-level" as in
>
> +static void
> +set_opt_info (int opt_info_level)
>
> may not be a good representation.  Not a pass-ignorant opt_info_flags
> value, if you consider -fopt-info=vect,3 (details from the vectorizer please).

Agreed. As I mentioned earlier, I was considering a simple linear view
of -fopt-info. However, I understand that making it pass cognizant is
certainly better. To this end, I have modified the syntax of
-fopt-info somewhat along the lines of -fdump-xxx format. For example,

gcc ... -fopt-info-tree-vect-optimized=foo.vect.optimized
-fdump-tree-pre-details=stderr ...

This would dump info about optimized locations from the vectorizer
pass into foo.vect.optimized, and pass dump from the PRE pass on to
stderr.

>
> +}
> +
> +
> +
> +DEBUG_FUNCTION void
> +dump_combine_stats (int flags)
>
> debug functions should be called debug_*, please add a comment and
> avoid excessive vertical space

Fixed.

>
> Index: tree-pass.h
> ===================================================================
> --- tree-pass.h (revision 188966)
> +++ tree-pass.h (working copy)
> @@ -85,7 +85,6 @@ enum tree_dump_index
>  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>
> -
>  /* In tree-dump.c */
>
>  extern char *get_dump_file_name (int);
>
> please avoid whitespace-only changes (also elsewhere).

Fixed.

>
>  /* Global variables used to communicate with passes.  */
>  extern FILE *dump_file;
> +extern FILE *alt_dump_file;
>  extern int dump_flags;
> +extern int opt_info_flags;
>
> so I expected the primary dump_file to be controlled with dump_flags,
> or with a (cached) translation of them to a primary_opt_info_flags.

Yes, now I have two sets of flags.

>
> Index: gimple-pretty-print.h
> ===================================================================
> --- gimple-pretty-print.h       (revision 188966)
> +++ gimple-pretty-print.h       (working copy)
> @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>  extern void print_gimple_stmt (FILE *, gimple, int, int);
>  extern void print_gimple_expr (FILE *, gimple, int, int);
> -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
> +extern void print_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>
> I'd call this pp_gimple_stmt instead.

Fixed.

>
> @@ -1418,6 +1419,16 @@ init_branch_prob (void)
>  void
>  end_branch_prob (void)
>  {
> +  end_branch_prob_1 (dump_file);
> +  end_branch_prob_1 (alt_dump_file);
> +}
> +
> +/* Helper function for file-level cleanup for DUMP_FILE after
> +   branch-prob processing is completed. */
> +
> +static void
> +end_branch_prob_1 (FILE *dump_file)
> +{
>    if (dump_file)
>      {
>        fprintf (dump_file, "\n");
>
> That change looks odd ;)  Can you instead use the new dump_printf
> interface?  (side-note: we should not need to export alt_dump_file at all!)

Sorry, it was my ill conceived attempt to avoid converting this pass.
:) Anyway, I did a proper fix now, and converted an additional file
(profile.c) as a side benefit.

>
> @@ -2166,10 +2177,6 @@ ftree-vect-loop-version
>  Common Report Var(flag_tree_vect_loop_version) Init(1) Optimization
>  Enable loop versioning when doing loop vectorization on trees
>
> -ftree-vectorizer-verbose=
> -Common RejectNegative Joined UInteger
> --ftree-vectorizer-verbose=<number>     Set the verbosity level of the
> vectorizer
> -
>
> we need to preserve old switches for backward compatibility, I suggest
> to alias it to -fopt-info for now.

Okay. I mapped -ftree-vectorizer-verbose=<number> as
0 ==> No dump output
1 ==> dump optimized locations
2 ==> dump missed optimizations
3 ==> dump notes
4 and up ==> dump all, i.e., 1, 2, 3

Curiously, several tests are casualties of reinterpretation of this
flag. Here is how -- the old (and odd) behavior was that

gcc ... -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=3

would output tree-vect dump as usual but nothing would get printed by
-ftree-vectorizer-verbose=3. In this patch I have "fixed" this
behavior so that -ftree-vectorizer-verbose=<n> prints on stderr
regardless of other flags present(*). This has the unfortunate side
effect of extra output being sent to stderr which is interpreted as a
test failure. Please advise how to ignore that additional stderr
output in tests.

(*) Well, not entirely true. Since -ftree-vectorizer-verbose=<n> is
implemented in terms of -fopt-info, the output of verbose flag is the
stream where ever vectorizer's opt-info is being sent.

> @@ -13909,7 +13909,7 @@ unmentioned_reg_p (rtx equiv, rtx expr)
>  }
>  ^L
>  DEBUG_FUNCTION void
> -dump_combine_stats (FILE *file)
> +print_combine_stats (FILE *file)
>
> see above, debug_combine_stats.

Fixed.

>
> Index: system.h
> ===================================================================
> --- system.h    (revision 188966)
> +++ system.h    (working copy)
> @@ -669,6 +669,7 @@ extern int vsnprintf(char *, size_t, const char *,
>     except, maybe, something to the dump file.  */
>  #ifdef BUFSIZ
>  extern FILE *dump_file;
> +extern FILE *alt_dump_file;
>
> see above - we should not need to export this (nor opt_info_flags).

Fixed.

Please take another look and see if the attached patch looks okay? I
still need to fix the failing tests due to intentional output on
stderr.

Thanks,
Sharad

>
> Overall I like the patch!
>
> Thanks,
> Richard.
>
>> Thanks,
>> Sharad
>>
>> On Fri, Jun 15, 2012 at 1:18 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Fri, Jun 15, 2012 at 7:47 AM, Sharad Singhai <singhai@google.com> wrote:
>>>> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
>>>> <richard.guenther@gmail.com> wrote:
>>>>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com> wrote:
>>>>>> Okay, I have updated the attached patch so that the output from
>>>>>> -ftree-vectorizer-verbose is considered diagnostic information and is
>>>>>> always
>>>>>> sent to stderr. Other functionality remains unchanged. Here is some
>>>>>> more context about this patch.
>>>>>>
>>>>>> This patch improves the dump infrastructure and public interfaces so
>>>>>> that the existing private pass-specific dump stream is separated from
>>>>>> the diagnostic dump stream (typically stderr).  The optimization
>>>>>> passes can output information on the two streams independently.
>>>>>>
>>>>>> The newly defined interfaces are:
>>>>>>
>>>>>> Individual passes do not need to access the dump file directly. Thus Instead
>>>>>> of doing
>>>>>>
>>>>>>   if (dump_file && (flags & dump_flags))
>>>>>>      fprintf (dump_file, ...);
>>>>>>
>>>>>> they can do
>>>>>>
>>>>>>     dump_printf (flags, ...);
>>>>>>
>>>>>> If the current pass has FLAGS enabled then the information gets
>>>>>> printed into the dump file otherwise not.
>>>>>>
>>>>>> Similar to the dump_printf (), another function is defined, called
>>>>>>
>>>>>>        diag_printf (dump_flags, ...)
>>>>>>
>>>>>> This prints information only onto the diagnostic stream, typically
>>>>>> standard error. It is useful for separating pass-specific dump
>>>>>> information from
>>>>>> the diagnostic information.
>>>>>>
>>>>>> Currently, as a proof of concept, I have converted vectorizer passes
>>>>>> to use the new dump format. For this, I have considered
>>>>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>>>>>> calls are changed to 'diag_printf'. Some other information printed to
>>>>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>>>>>> helps to separate the two streams because they might serve different
>>>>>> purposes and might have different formatting requirements.
>>>>>>
>>>>>> For example, using the trunk compiler, the following invocation
>>>>>>
>>>>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=2
>>>>>>
>>>>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>>>>>> However, the verbose diagnostic output is silently
>>>>>> ignored. This is not desirable as the two types of dump should not interfere.
>>>>>>
>>>>>> After this patch, the vectorizer dump is available in 'v.cc.113t.vect'
>>>>>> as before, but the verbose vectorizer diagnostic is additionally
>>>>>> printed on stderr. Thus both types of dump information are output.
>>>>>>
>>>>>> An additional feature of this patch is that individual passes can
>>>>>> print dump information into command-line named files instead of auto
>>>>>> numbered filename. For example,
>>>>>
>>>>> I'd wish you'd leave out this part for a followup.
>>>>>
>>>>>>
>>>>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>>>>>     -ftree-vectorizer-verbose=2
>>>>>>     -fdump-tree-pre=foo.pre
>>>>>>
>>>>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>>>>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>>>>>
>>>>>> Please take another look.
>>>>>
>>>>> --- tree-vect-loop-manip.c      (revision 188325)
>>>>> +++ tree-vect-loop-manip.c      (working copy)
>>>>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>>>>   gsi_remove (&loop_cond_gsi, true);
>>>>>
>>>>>   loop_loc = find_loop_location (loop);
>>>>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>>>>> -    {
>>>>> -      if (loop_loc != UNKNOWN_LOC)
>>>>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>>>>> +  if (loop_loc != UNKNOWN_LOC)
>>>>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>>>>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>>>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>>>>> -    }
>>>>> -
>>>>> +  if (dump_flags & TDF_DETAILS)
>>>>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>>>>>   loop->nb_iterations = niters;
>>>>>
>>>>> I'm confused by this.  Why is this not simply
>>>>>
>>>>>  if (loop_loc != UNKNOWN_LOC)
>>>>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>>>>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>>>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>>>>>
>>>>> for example.  I notice that you maybe mis-understood the message classification
>>>>> I asked you to add (maybe I confused you by mentioning to eventually re-use
>>>>> the TDF_* flags).  I think you basically provided this message classification
>>>>> by adding two classes by providing both dump_gimple_stmt and diag_gimple_stmt.
>>>>> But still in the above you keep a dump_flags test _and_ you pass in
>>>>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me quote them:
>>>>>
>>>>> +void
>>>>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>>>>> +{
>>>>> +  if (dump_file)
>>>>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>>>>> +}
>>>>>
>>>>> +void
>>>>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>>>>> +{
>>>>> +  if (alt_dump_file)
>>>>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>>>>> +}
>>>>>
>>>>> I'd say it should have been a single function:
>>>>>
>>>>> void
>>>>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>>>>> gimple gs, int spc)
>>>>> {
>>>>>  if (msg_classification & go-to-dumpfile
>>>>>      && dump_file)
>>>>>    print_gimple_stmt (dump_file, gs, spc, dump_flags | additional_flags);
>>>>>  if (msg_classification & go-to-alt-dump-file
>>>>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>>>>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>>>>> additional_flags);
>>>>> }
>>>>
>>>> Yes,  I can make the single function work for both regular (dump_file)
>>>> and diagnostic (stderr for now) dump streams. In fact, my original
>>>> patch did just that. However, it duplicated output on *both* the
>>>> streams. For example,
>>>>
>>>> gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
>>>> -ftree-vectorizer-verbose=2 foo.c
>>>>
>>>> Since both streams are enabled in this case, a call to dump_printf ()
>>>> would duplicate the information to both files, i.e., the dump and
>>>> diagnostic will be intermixed. Is that intended? My first thought was
>>>> to keep them separated via dump_*() and diag_* () methods.
>>>
>>> No, I think that's intended.  The regular dump-files should contain
>>> everything, the secondary stream (eventually enabled by -fopt-info)
>>> should be a filtered regular dump-file.
>>>
>>> Thanks,
>>> Richard.
>>>
>>>> Thanks,
>>>> Sharad
>>>>
>>>>> where msg_classification would include things to suitably classify messages
>>>>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED, MSG_NOTE.
>>>>>
>>>>> In another place we have
>>>>>
>>>>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>>>>   /* Analyze phi functions of the loop header.  */
>>>>>
>>>>>   if (vect_print_dump_info (REPORT_DETAILS))
>>>>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>>>>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>>>>>
>>>>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>>>>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>>>>> think it should have been
>>>>>
>>>>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>>>>>
>>>>> thus dump_printf only gets the msg-classification and the printf args
>>>>> (dump-flags
>>>>> are only meaningful when passed down to pretty-printers).  Thus
>>>>>
>>>>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>>>>       phi = gsi_stmt (gsi);
>>>>>       if (vect_print_dump_info (REPORT_DETAILS))
>>>>>        {
>>>>> -          fprintf (vect_dump, "Analyze phi: ");
>>>>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>>>>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>>>>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>>>>>        }
>>>>>
>>>>> should be
>>>>>
>>>>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>>>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>>>>
>>>>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>>>>> the dump infrastructure provides and thus hidden.  Eventually we should
>>>>> have a dump_kind (msg-classification) so we can replace it with
>>>>>
>>>>>   if (dump_kind (REPORT_DETAILS))
>>>>>     {
>>>>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>>>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>>>>     }
>>>>>
>>>>> to reduce the runtime overhead when not diagnosing/dumping.
>>>>>
>>>>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>>>>     }
>>>>>
>>>>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>>>>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>>>>> -             VEC_length (ddr_p, may_alias_ddrs));
>>>>> +    diag_printf (TDF_TREE, "created %u versioning for alias checks.\n",
>>>>> +                 VEC_length (ddr_p, may_alias_ddrs));
>>>>>  }
>>>>>
>>>>> so here we have a different msg-classification,
>>>>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>>>>> -fopt-report=... we do not want to leave this implementation detail to
>>>>> individual passes but gather them in a central place.
>>>>>
>>>>> Thanks,
>>>>> Richard.
>>>>>
>>>>>> Thanks,
>>>>>> Sharad
>>>>>>
>>>>>>
>>>>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>>>> Sorry about the delay. I have finally incorporated all the suggestions
>>>>>>>> and reorganized the dump infrastructure a bit. The attached patch
>>>>>>>> updates vectorizer passes so that instead of accessing global
>>>>>>>> dump_file directly, these passes call dump_printf (FLAG, format, ...).
>>>>>>>> The dump_printf can choose between two streams, one regular pass dump
>>>>>>>> file, and another optional command line provided file. Currently, it
>>>>>>>> doesn't discriminate and all the dump information goes to both the
>>>>>>>> streams.
>>>>>>>>
>>>>>>>> Thus, for example,
>>>>>>>>
>>>>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v -ftree-vectorizer-verbose=3
>>>>>>>
>>>>>>> But the default form of dump option (-fdump-tree-vect) no longer
>>>>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this is
>>>>>>> one of the main requirements). One dumped to the primary stream (named
>>>>>>> dump file) and the other to the stderr -- the default diagnostic (alt)
>>>>>>> stream.
>>>>>>>
>>>>>>> David
>>>>>>>
>>>>>>>>
>>>>>>>> will output the verbose vectorizer information in both *.vect file and
>>>>>>>> foo.v file. However, as I have converted only vectorizer passes so
>>>>>>>> far, there is additional information in *.vect file which is not
>>>>>>>> present in foo.v file. Once other passes are converted to use this
>>>>>>>> scheme, then these two dump files should have identical output.
>>>>>>>>
>>>>>>>> Also note that in this patch -fdump-xxx=yyy format does not override
>>>>>>>> any auto named dump files as in my earlier patches. Instead the dump
>>>>>>>> information is output to both places when a command line dump file
>>>>>>>> option is provided.
>>>>>>>>
>>>>>>>> To summarize:
>>>>>>>> - instead of using dump_begin () / dump_end (), the passes should use
>>>>>>>> dump_start ()/dump_finish (). These new variants do not return the
>>>>>>>> dump_file. However, they still set the global dump_file/dump_flags for
>>>>>>>> the benefit of other passes during the transition.
>>>>>>>> - instead of directly printing to the dump_file, as in
>>>>>>>> if (dump_file)
>>>>>>>>  fprintf (dump_file, ...);
>>>>>>>>
>>>>>>>> The passes should do
>>>>>>>>
>>>>>>>> dump_printf (dump_flag, ...);
>>>>>>>> This will output to dump file(s) only when dump_flag is enabled for a
>>>>>>>> given pass.
>>>>>>>>
>>>>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> Sharad
>>>>>>>>
>>>>>>>>
>>>>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>>>>>>> <richard.guenther@gmail.com> wrote:
>>>>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>>>>>>>>> <gdr@integrable-solutions.net> wrote:
>>>>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li <davidxl@google.com> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> The downside is that the dump file format will look different from the
>>>>>>>>>>>> stderr output which is less than ideal.
>>>>>>>>>>>
>>>>>>>>>>> BTW, why do people want to use stderr for dumping internal IRs,
>>>>>>>>>>> as opposed to stdout or other files?  That does not sound right.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> I was talking about the transformation information difference. In
>>>>>>>>>> stderr (where diagnostics go to), we may have
>>>>>>>>>>
>>>>>>>>>> foo.c: in function 'foo':
>>>>>>>>>> foo.c:5:6: note: loop was vectorized
>>>>>>>>>>
>>>>>>>>>> but in dump file the format for the information may be different,
>>>>>>>>>> unless we want to duplicate the machinery in diagnostics.
>>>>>>>>>
>>>>>>>>> So?  What's the problem with that ("different" diagnostics)?
>>>>>>>>>
>>>>>>>>> Richard.
>>>>>>>>>
>>>>>>>>>> David
>>>>>>>>>>
>>>>>>>>>>> -- Gaby

[-- Attachment #2: opt-info.diff.bz2 --]
[-- Type: application/x-bzip2, Size: 45666 bytes --]

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
       [not found]                                             ` <CAKxPW67Nn9YSwH_xwFXBM7=y=32s_HpQ4fUAE+E8GoRSsVjxbA@mail.gmail.com>
@ 2012-09-10 18:21                                               ` Sharad Singhai
  2012-09-11 20:16                                                 ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-09-10 18:21 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Ping.

Thanks,
Sharad
Sharad


On Wed, Sep 5, 2012 at 10:34 AM, Sharad Singhai <singhai@google.com> wrote:
> Ping.
>
> Thanks,
> Sharad
>
> Sharad
>
>
>
>
> On Fri, Aug 24, 2012 at 1:06 AM, Sharad Singhai <singhai@google.com> wrote:
>>
>> Sorry about the delay. Please see comments inline.
>>
>> On Wed, Jul 4, 2012 at 6:33 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>> > On Tue, Jul 3, 2012 at 11:07 PM, Sharad Singhai <singhai@google.com>
>> > wrote:
>> >> Apologies for the spam. Attempting to resend the patch after shrinking
>> >> it.
>> >>
>> >> I have updated the attached patch to use a new dump message
>> >> classification system for the vectorizer. It currently uses four
>> >> classes, viz, MSG_OPTIMIZED_LOCATIONS, MSG_UNOPTIMIZED_LOCATION,
>> >> MSG_MISSING_OPTIMIZATION, and MSG_NOTE. I have gone through the
>> >> vectorizer passes and have converted each call to fprintf (dump_file,
>> >> ....) to a message classification matching in spirit. Most often, it
>> >> is MSG_OPTIMIZED_LOCATIONS, but occasionally others as well.
>> >>
>> >> For example, the following
>> >>
>> >> if (vect_print_dump_info (REPORT_DETAILS))
>> >>   {
>> >>     fprintf (vect_dump, "niters for prolog loop: ");
>> >>     print_generic_expr (vect_dump, iters, TDF_SLIM);
>> >>   }
>> >>
>> >> gets converted to
>> >>
>> >> if (dump_kind (MSG_OPTIMIZED_LOCATIONS))
>> >>   {
>> >>      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> >>                       "niters for prolog loop: ");
>> >>      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
>> >>   }
>> >>
>> >> The asymmetry between the first printf and the second is due to the
>> >> fact that 'vect_print_dump_info (xxx)' prints the location as a
>> >> "side-effect". To preserve the original intent somewhat, I have
>> >> converted the first call within a dump sequence to a dump_printf_loc
>> >> (xxx) which prints the location while the subsequence calls within the
>> >> same conditional get converted to the corresponding plain variants.
>> >
>> > Ok, that looks reasonable.
>> >
>> >> I considered removing the support for alternate dump file, but ended
>> >> up preserving it instead since it is needed for setting the alternate
>> >> dump file to stderr for the case when -fopt-info is given but no dump
>> >> file is available.
>> >>
>> >> The following invocation
>> >> g++ ... -ftree-vectorize -fopt-info=4
>> >>
>> >> dumps *all* available information to stderr. Currently, the opt-info
>> >> level is common to all passes, i.e., a pass can't specify if wants a
>> >> different level of diagnostic info. This can be added as an
>> >> enhancement with a suitable syntax for selecting passes.
>> >>
>> >> I haven't fixed up the documentation/tests but wanted to get some
>> >> feedback about the current state of patch before doing that.
>> >
>> > Some comments / questions.
>> >
>> > +  if (dump_file && (dump_kind & opt_info_flags))
>> > +    {
>> > +      dump_loc (dump_kind, dump_file, loc);
>> > +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
>> > +    }
>> > +
>> > +  if (alt_dump_file && (dump_kind & opt_info_flags))
>> > +    {
>> >
>> > you always test dump_kind against the same opt_info_flags variable.
>> > I would have thought that the alternate dump file has a different
>> > opt_info_flags
>> > setting so I can have -fdump-tree-vect-details -fopt-info=1.  Am I
>> > missing
>> > something?
>>
>> It was an oversight on my part. I have since fixed this. There are two
>> separate flags corresponding to the two types of dump files,
>>
>> pflags ==> pass private dump file
>> alt_flags ==> opt-info dump file
>>
>> > If I do
>> >
>> >> gcc file1.c file2.c -O3 -fdump-tree-vectorize=foo
>> >
>> > what will foo contain afterwards?  I think you need to document the
>> > behavior
>> > when such redirection is used with the compiler-driver feature of
>> > handling
>> > multiple translation units.  Especially the difference (or not
>> > difference) to
>> >
>> >> gcc file1.c -O3 -fdump-tree-vectorize=foo
>> >> gcc file2.c -O3 -fdump-tree-vectorize=foo
>>
>> Yes, the dump file gets overwritten during each invocation. I have
>> noted this in the documentation.
>>
>> > I suppose we do not want to append to foo (but eventually support that
>> > with some alternate syntax?  Like -fdump-tree-vectorize=+foo?)
>>
>> Yes, I agree. We could define a new syntax as you suggested for
>> appending to a dump file. However, this feature can wait for a
>> separate patch.
>>
>> > +
>> > +static void
>> > +set_opt_info (int opt_info_level)
>> > +{
>> >
>> > This function needs a comment.  How do the dump flags translate to
>> > the opt-info flags?  Is this documented anywhere?  I only see
>> >
>> > +/* Different types of dump classifications.  */
>> > +enum dump_msg_kind {
>> > +  MSG_NONE                     = 1 << 0,
>> > +  MSG_OPTIMIZED_LOCATIONS      = 1 << 1,
>> > +  MSG_UNOPTIMIZED_LOCATIONS    = 1 << 2,
>> > +  MSG_MISSED_OPTIMIZATION      = 1 << 3,
>> > +  MSG_NOTE                     = 1 << 4
>> > +};
>>
>> Yes, my mapping was static (pass-agnostic), defined inside the
>> set_opt_info. I
>> have now documented it and revamped it so that -fopt-info is applied
>> to specific passes as explained below.
>>
>> > I suppose the TDF_* flags would all map to
>> >
>> > MSG_OPTIMIZED_LOCATIONS|MSG_UNOPTIMIZED_LOCATIONS|MSG_MISSED_OPTIMIZATION
>> > and only TDF_DETAILS would enable MSG_NOTE?
>>
>> Yes, the mapping is very coarse-grained right now. Currently I have
>> made MSG_* flags an extension of TDF_* flags. This way both kinds of
>> flags can be present in a single word yet still be interpreted by the
>> dumps which are interested in them. TDF_DETAILS gets mapped to a union
>> of all the MSG_* flags. This will allow flags such -fdump-vect-details
>> to continue to work as expected during the transition to the new dump
>> infrastructure. Of coure,  during the transition, we would need to
>> rejigger flags to express the desired behavior.
>>
>> > In the above a flag for MSG_NONE does not make much sense?
>>
>> Removed. It is now implicitly 0.
>>
>> >
>> > How would we map TDF_SCEV?  I suppose we'd add MSG_SCEV for this
>> > (we talked about the possibility of having some special flags for
>> > special passes).
>>
>> Yes, I think this would be necessary. So far, I haven't converted any
>> passes other than vectorization, and I suspect a handful of special
>> case flags would be needed. During the transition, the TDF_* flags are
>> assumed to be an extension of MSG_* flags and things won't break.
>>
>> >
>> > But this also means a linear "opt-info-level" as in
>> >
>> > +static void
>> > +set_opt_info (int opt_info_level)
>> >
>> > may not be a good representation.  Not a pass-ignorant opt_info_flags
>> > value, if you consider -fopt-info=vect,3 (details from the vectorizer
>> > please).
>>
>> Agreed. As I mentioned earlier, I was considering a simple linear view
>> of -fopt-info. However, I understand that making it pass cognizant is
>> certainly better. To this end, I have modified the syntax of
>> -fopt-info somewhat along the lines of -fdump-xxx format. For example,
>>
>> gcc ... -fopt-info-tree-vect-optimized=foo.vect.optimized
>> -fdump-tree-pre-details=stderr ...
>>
>> This would dump info about optimized locations from the vectorizer
>> pass into foo.vect.optimized, and pass dump from the PRE pass on to
>> stderr.
>>
>> >
>> > +}
>> > +
>> > +
>> > +
>> > +DEBUG_FUNCTION void
>> > +dump_combine_stats (int flags)
>> >
>> > debug functions should be called debug_*, please add a comment and
>> > avoid excessive vertical space
>>
>> Fixed.
>>
>> >
>> > Index: tree-pass.h
>> > ===================================================================
>> > --- tree-pass.h (revision 188966)
>> > +++ tree-pass.h (working copy)
>> > @@ -85,7 +85,6 @@ enum tree_dump_index
>> >  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>> >  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>> >
>> > -
>> >  /* In tree-dump.c */
>> >
>> >  extern char *get_dump_file_name (int);
>> >
>> > please avoid whitespace-only changes (also elsewhere).
>>
>> Fixed.
>>
>> >
>> >  /* Global variables used to communicate with passes.  */
>> >  extern FILE *dump_file;
>> > +extern FILE *alt_dump_file;
>> >  extern int dump_flags;
>> > +extern int opt_info_flags;
>> >
>> > so I expected the primary dump_file to be controlled with dump_flags,
>> > or with a (cached) translation of them to a primary_opt_info_flags.
>>
>> Yes, now I have two sets of flags.
>>
>> >
>> > Index: gimple-pretty-print.h
>> > ===================================================================
>> > --- gimple-pretty-print.h       (revision 188966)
>> > +++ gimple-pretty-print.h       (working copy)
>> > @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>> >  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>> >  extern void print_gimple_stmt (FILE *, gimple, int, int);
>> >  extern void print_gimple_expr (FILE *, gimple, int, int);
>> > -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
>> > +extern void print_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>> >
>> > I'd call this pp_gimple_stmt instead.
>>
>> Fixed.
>>
>> >
>> > @@ -1418,6 +1419,16 @@ init_branch_prob (void)
>> >  void
>> >  end_branch_prob (void)
>> >  {
>> > +  end_branch_prob_1 (dump_file);
>> > +  end_branch_prob_1 (alt_dump_file);
>> > +}
>> > +
>> > +/* Helper function for file-level cleanup for DUMP_FILE after
>> > +   branch-prob processing is completed. */
>> > +
>> > +static void
>> > +end_branch_prob_1 (FILE *dump_file)
>> > +{
>> >    if (dump_file)
>> >      {
>> >        fprintf (dump_file, "\n");
>> >
>> > That change looks odd ;)  Can you instead use the new dump_printf
>> > interface?  (side-note: we should not need to export alt_dump_file at
>> > all!)
>>
>> Sorry, it was my ill conceived attempt to avoid converting this pass.
>> :) Anyway, I did a proper fix now, and converted an additional file
>> (profile.c) as a side benefit.
>>
>> >
>> > @@ -2166,10 +2177,6 @@ ftree-vect-loop-version
>> >  Common Report Var(flag_tree_vect_loop_version) Init(1) Optimization
>> >  Enable loop versioning when doing loop vectorization on trees
>> >
>> > -ftree-vectorizer-verbose=
>> > -Common RejectNegative Joined UInteger
>> > --ftree-vectorizer-verbose=<number>     Set the verbosity level of the
>> > vectorizer
>> > -
>> >
>> > we need to preserve old switches for backward compatibility, I suggest
>> > to alias it to -fopt-info for now.
>>
>> Okay. I mapped -ftree-vectorizer-verbose=<number> as
>> 0 ==> No dump output
>> 1 ==> dump optimized locations
>> 2 ==> dump missed optimizations
>> 3 ==> dump notes
>> 4 and up ==> dump all, i.e., 1, 2, 3
>>
>> Curiously, several tests are casualties of reinterpretation of this
>> flag. Here is how -- the old (and odd) behavior was that
>>
>> gcc ... -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=3
>>
>> would output tree-vect dump as usual but nothing would get printed by
>> -ftree-vectorizer-verbose=3. In this patch I have "fixed" this
>> behavior so that -ftree-vectorizer-verbose=<n> prints on stderr
>> regardless of other flags present(*). This has the unfortunate side
>> effect of extra output being sent to stderr which is interpreted as a
>> test failure. Please advise how to ignore that additional stderr
>> output in tests.
>>
>> (*) Well, not entirely true. Since -ftree-vectorizer-verbose=<n> is
>> implemented in terms of -fopt-info, the output of verbose flag is the
>> stream where ever vectorizer's opt-info is being sent.
>>
>> > @@ -13909,7 +13909,7 @@ unmentioned_reg_p (rtx equiv, rtx expr)
>> >  }
>> >  ^L
>> >  DEBUG_FUNCTION void
>> > -dump_combine_stats (FILE *file)
>> > +print_combine_stats (FILE *file)
>> >
>> > see above, debug_combine_stats.
>>
>> Fixed.
>>
>> >
>> > Index: system.h
>> > ===================================================================
>> > --- system.h    (revision 188966)
>> > +++ system.h    (working copy)
>> > @@ -669,6 +669,7 @@ extern int vsnprintf(char *, size_t, const char *,
>> >     except, maybe, something to the dump file.  */
>> >  #ifdef BUFSIZ
>> >  extern FILE *dump_file;
>> > +extern FILE *alt_dump_file;
>> >
>> > see above - we should not need to export this (nor opt_info_flags).
>>
>> Fixed.
>>
>> Please take another look and see if the attached patch looks okay? I
>> still need to fix the failing tests due to intentional output on
>> stderr.
>>
>> Thanks,
>> Sharad
>>
>> >
>> > Overall I like the patch!
>> >
>> > Thanks,
>> > Richard.
>> >
>> >> Thanks,
>> >> Sharad
>> >>
>> >> On Fri, Jun 15, 2012 at 1:18 AM, Richard Guenther
>> >> <richard.guenther@gmail.com> wrote:
>> >>> On Fri, Jun 15, 2012 at 7:47 AM, Sharad Singhai <singhai@google.com>
>> >>> wrote:
>> >>>> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
>> >>>> <richard.guenther@gmail.com> wrote:
>> >>>>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com>
>> >>>>> wrote:
>> >>>>>> Okay, I have updated the attached patch so that the output from
>> >>>>>> -ftree-vectorizer-verbose is considered diagnostic information and
>> >>>>>> is
>> >>>>>> always
>> >>>>>> sent to stderr. Other functionality remains unchanged. Here is some
>> >>>>>> more context about this patch.
>> >>>>>>
>> >>>>>> This patch improves the dump infrastructure and public interfaces
>> >>>>>> so
>> >>>>>> that the existing private pass-specific dump stream is separated
>> >>>>>> from
>> >>>>>> the diagnostic dump stream (typically stderr).  The optimization
>> >>>>>> passes can output information on the two streams independently.
>> >>>>>>
>> >>>>>> The newly defined interfaces are:
>> >>>>>>
>> >>>>>> Individual passes do not need to access the dump file directly.
>> >>>>>> Thus Instead
>> >>>>>> of doing
>> >>>>>>
>> >>>>>>   if (dump_file && (flags & dump_flags))
>> >>>>>>      fprintf (dump_file, ...);
>> >>>>>>
>> >>>>>> they can do
>> >>>>>>
>> >>>>>>     dump_printf (flags, ...);
>> >>>>>>
>> >>>>>> If the current pass has FLAGS enabled then the information gets
>> >>>>>> printed into the dump file otherwise not.
>> >>>>>>
>> >>>>>> Similar to the dump_printf (), another function is defined, called
>> >>>>>>
>> >>>>>>        diag_printf (dump_flags, ...)
>> >>>>>>
>> >>>>>> This prints information only onto the diagnostic stream, typically
>> >>>>>> standard error. It is useful for separating pass-specific dump
>> >>>>>> information from
>> >>>>>> the diagnostic information.
>> >>>>>>
>> >>>>>> Currently, as a proof of concept, I have converted vectorizer
>> >>>>>> passes
>> >>>>>> to use the new dump format. For this, I have considered
>> >>>>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>> >>>>>> calls are changed to 'diag_printf'. Some other information printed
>> >>>>>> to
>> >>>>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>> >>>>>> helps to separate the two streams because they might serve
>> >>>>>> different
>> >>>>>> purposes and might have different formatting requirements.
>> >>>>>>
>> >>>>>> For example, using the trunk compiler, the following invocation
>> >>>>>>
>> >>>>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect
>> >>>>>> -ftree-vectorizer-verbose=2
>> >>>>>>
>> >>>>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>> >>>>>> However, the verbose diagnostic output is silently
>> >>>>>> ignored. This is not desirable as the two types of dump should not
>> >>>>>> interfere.
>> >>>>>>
>> >>>>>> After this patch, the vectorizer dump is available in
>> >>>>>> 'v.cc.113t.vect'
>> >>>>>> as before, but the verbose vectorizer diagnostic is additionally
>> >>>>>> printed on stderr. Thus both types of dump information are output.
>> >>>>>>
>> >>>>>> An additional feature of this patch is that individual passes can
>> >>>>>> print dump information into command-line named files instead of
>> >>>>>> auto
>> >>>>>> numbered filename. For example,
>> >>>>>
>> >>>>> I'd wish you'd leave out this part for a followup.
>> >>>>>
>> >>>>>>
>> >>>>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>> >>>>>>     -ftree-vectorizer-verbose=2
>> >>>>>>     -fdump-tree-pre=foo.pre
>> >>>>>>
>> >>>>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>> >>>>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>> >>>>>>
>> >>>>>> Please take another look.
>> >>>>>
>> >>>>> --- tree-vect-loop-manip.c      (revision 188325)
>> >>>>> +++ tree-vect-loop-manip.c      (working copy)
>> >>>>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop
>> >>>>> *loop
>> >>>>>   gsi_remove (&loop_cond_gsi, true);
>> >>>>>
>> >>>>>   loop_loc = find_loop_location (loop);
>> >>>>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> >>>>> -    {
>> >>>>> -      if (loop_loc != UNKNOWN_LOC)
>> >>>>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>> >>>>> +  if (loop_loc != UNKNOWN_LOC)
>> >>>>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>> >>>>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> >>>>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>> >>>>> -    }
>> >>>>> -
>> >>>>> +  if (dump_flags & TDF_DETAILS)
>> >>>>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>> >>>>>   loop->nb_iterations = niters;
>> >>>>>
>> >>>>> I'm confused by this.  Why is this not simply
>> >>>>>
>> >>>>>  if (loop_loc != UNKNOWN_LOC)
>> >>>>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>> >>>>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> >>>>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>> >>>>>
>> >>>>> for example.  I notice that you maybe mis-understood the message
>> >>>>> classification
>> >>>>> I asked you to add (maybe I confused you by mentioning to eventually
>> >>>>> re-use
>> >>>>> the TDF_* flags).  I think you basically provided this message
>> >>>>> classification
>> >>>>> by adding two classes by providing both dump_gimple_stmt and
>> >>>>> diag_gimple_stmt.
>> >>>>> But still in the above you keep a dump_flags test _and_ you pass in
>> >>>>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me
>> >>>>> quote them:
>> >>>>>
>> >>>>> +void
>> >>>>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>> >>>>> +{
>> >>>>> +  if (dump_file)
>> >>>>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>> >>>>> +}
>> >>>>>
>> >>>>> +void
>> >>>>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>> >>>>> +{
>> >>>>> +  if (alt_dump_file)
>> >>>>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>> >>>>> +}
>> >>>>>
>> >>>>> I'd say it should have been a single function:
>> >>>>>
>> >>>>> void
>> >>>>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>> >>>>> gimple gs, int spc)
>> >>>>> {
>> >>>>>  if (msg_classification & go-to-dumpfile
>> >>>>>      && dump_file)
>> >>>>>    print_gimple_stmt (dump_file, gs, spc, dump_flags |
>> >>>>> additional_flags);
>> >>>>>  if (msg_classification & go-to-alt-dump-file
>> >>>>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>> >>>>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>> >>>>> additional_flags);
>> >>>>> }
>> >>>>
>> >>>> Yes,  I can make the single function work for both regular
>> >>>> (dump_file)
>> >>>> and diagnostic (stderr for now) dump streams. In fact, my original
>> >>>> patch did just that. However, it duplicated output on *both* the
>> >>>> streams. For example,
>> >>>>
>> >>>> gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
>> >>>> -ftree-vectorizer-verbose=2 foo.c
>> >>>>
>> >>>> Since both streams are enabled in this case, a call to dump_printf ()
>> >>>> would duplicate the information to both files, i.e., the dump and
>> >>>> diagnostic will be intermixed. Is that intended? My first thought was
>> >>>> to keep them separated via dump_*() and diag_* () methods.
>> >>>
>> >>> No, I think that's intended.  The regular dump-files should contain
>> >>> everything, the secondary stream (eventually enabled by -fopt-info)
>> >>> should be a filtered regular dump-file.
>> >>>
>> >>> Thanks,
>> >>> Richard.
>> >>>
>> >>>> Thanks,
>> >>>> Sharad
>> >>>>
>> >>>>> where msg_classification would include things to suitably classify
>> >>>>> messages
>> >>>>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED,
>> >>>>> MSG_NOTE.
>> >>>>>
>> >>>>> In another place we have
>> >>>>>
>> >>>>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info
>> >>>>> loop_vinfo)
>> >>>>>   /* Analyze phi functions of the loop header.  */
>> >>>>>
>> >>>>>   if (vect_print_dump_info (REPORT_DETAILS))
>> >>>>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>> >>>>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>> >>>>>
>> >>>>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>> >>>>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>> >>>>> think it should have been
>> >>>>>
>> >>>>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>> >>>>>
>> >>>>> thus dump_printf only gets the msg-classification and the printf
>> >>>>> args
>> >>>>> (dump-flags
>> >>>>> are only meaningful when passed down to pretty-printers).  Thus
>> >>>>>
>> >>>>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info
>> >>>>> loop_vinfo)
>> >>>>>       phi = gsi_stmt (gsi);
>> >>>>>       if (vect_print_dump_info (REPORT_DETAILS))
>> >>>>>        {
>> >>>>> -          fprintf (vect_dump, "Analyze phi: ");
>> >>>>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> >>>>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>> >>>>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>> >>>>>        }
>> >>>>>
>> >>>>> should be
>> >>>>>
>> >>>>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>> >>>>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>> >>>>>
>> >>>>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>> >>>>> the dump infrastructure provides and thus hidden.  Eventually we
>> >>>>> should
>> >>>>> have a dump_kind (msg-classification) so we can replace it with
>> >>>>>
>> >>>>>   if (dump_kind (REPORT_DETAILS))
>> >>>>>     {
>> >>>>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>> >>>>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>> >>>>>     }
>> >>>>>
>> >>>>> to reduce the runtime overhead when not diagnosing/dumping.
>> >>>>>
>> >>>>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks
>> >>>>> (loop_vec_info l
>> >>>>>     }
>> >>>>>
>> >>>>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> >>>>> -    fprintf (vect_dump, "created %u versioning for alias
>> >>>>> checks.\n",
>> >>>>> -             VEC_length (ddr_p, may_alias_ddrs));
>> >>>>> +    diag_printf (TDF_TREE, "created %u versioning for alias
>> >>>>> checks.\n",
>> >>>>> +                 VEC_length (ddr_p, may_alias_ddrs));
>> >>>>>  }
>> >>>>>
>> >>>>> so here we have a different msg-classification,
>> >>>>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>> >>>>> -fopt-report=... we do not want to leave this implementation detail
>> >>>>> to
>> >>>>> individual passes but gather them in a central place.
>> >>>>>
>> >>>>> Thanks,
>> >>>>> Richard.
>> >>>>>
>> >>>>>> Thanks,
>> >>>>>> Sharad
>> >>>>>>
>> >>>>>>
>> >>>>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li
>> >>>>>> <davidxl@google.com> wrote:
>> >>>>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai
>> >>>>>>> <singhai@google.com> wrote:
>> >>>>>>>> Sorry about the delay. I have finally incorporated all the
>> >>>>>>>> suggestions
>> >>>>>>>> and reorganized the dump infrastructure a bit. The attached patch
>> >>>>>>>> updates vectorizer passes so that instead of accessing global
>> >>>>>>>> dump_file directly, these passes call dump_printf (FLAG, format,
>> >>>>>>>> ...).
>> >>>>>>>> The dump_printf can choose between two streams, one regular pass
>> >>>>>>>> dump
>> >>>>>>>> file, and another optional command line provided file. Currently,
>> >>>>>>>> it
>> >>>>>>>> doesn't discriminate and all the dump information goes to both
>> >>>>>>>> the
>> >>>>>>>> streams.
>> >>>>>>>>
>> >>>>>>>> Thus, for example,
>> >>>>>>>>
>> >>>>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v
>> >>>>>>>> -ftree-vectorizer-verbose=3
>> >>>>>>>
>> >>>>>>> But the default form of dump option (-fdump-tree-vect) no longer
>> >>>>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this
>> >>>>>>> is
>> >>>>>>> one of the main requirements). One dumped to the primary stream
>> >>>>>>> (named
>> >>>>>>> dump file) and the other to the stderr -- the default diagnostic
>> >>>>>>> (alt)
>> >>>>>>> stream.
>> >>>>>>>
>> >>>>>>> David
>> >>>>>>>
>> >>>>>>>>
>> >>>>>>>> will output the verbose vectorizer information in both *.vect
>> >>>>>>>> file and
>> >>>>>>>> foo.v file. However, as I have converted only vectorizer passes
>> >>>>>>>> so
>> >>>>>>>> far, there is additional information in *.vect file which is not
>> >>>>>>>> present in foo.v file. Once other passes are converted to use
>> >>>>>>>> this
>> >>>>>>>> scheme, then these two dump files should have identical output.
>> >>>>>>>>
>> >>>>>>>> Also note that in this patch -fdump-xxx=yyy format does not
>> >>>>>>>> override
>> >>>>>>>> any auto named dump files as in my earlier patches. Instead the
>> >>>>>>>> dump
>> >>>>>>>> information is output to both places when a command line dump
>> >>>>>>>> file
>> >>>>>>>> option is provided.
>> >>>>>>>>
>> >>>>>>>> To summarize:
>> >>>>>>>> - instead of using dump_begin () / dump_end (), the passes should
>> >>>>>>>> use
>> >>>>>>>> dump_start ()/dump_finish (). These new variants do not return
>> >>>>>>>> the
>> >>>>>>>> dump_file. However, they still set the global
>> >>>>>>>> dump_file/dump_flags for
>> >>>>>>>> the benefit of other passes during the transition.
>> >>>>>>>> - instead of directly printing to the dump_file, as in
>> >>>>>>>> if (dump_file)
>> >>>>>>>>  fprintf (dump_file, ...);
>> >>>>>>>>
>> >>>>>>>> The passes should do
>> >>>>>>>>
>> >>>>>>>> dump_printf (dump_flag, ...);
>> >>>>>>>> This will output to dump file(s) only when dump_flag is enabled
>> >>>>>>>> for a
>> >>>>>>>> given pass.
>> >>>>>>>>
>> >>>>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>> >>>>>>>>
>> >>>>>>>> Thanks,
>> >>>>>>>> Sharad
>> >>>>>>>>
>> >>>>>>>>
>> >>>>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>> >>>>>>>> <richard.guenther@gmail.com> wrote:
>> >>>>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li
>> >>>>>>>>> <davidxl@google.com> wrote:
>> >>>>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>> >>>>>>>>>> <gdr@integrable-solutions.net> wrote:
>> >>>>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li
>> >>>>>>>>>>> <davidxl@google.com> wrote:
>> >>>>>>>>>>>
>> >>>>>>>>>>>> The downside is that the dump file format will look different
>> >>>>>>>>>>>> from the
>> >>>>>>>>>>>> stderr output which is less than ideal.
>> >>>>>>>>>>>
>> >>>>>>>>>>> BTW, why do people want to use stderr for dumping internal
>> >>>>>>>>>>> IRs,
>> >>>>>>>>>>> as opposed to stdout or other files?  That does not sound
>> >>>>>>>>>>> right.
>> >>>>>>>>>>>
>> >>>>>>>>>>
>> >>>>>>>>>> I was talking about the transformation information difference.
>> >>>>>>>>>> In
>> >>>>>>>>>> stderr (where diagnostics go to), we may have
>> >>>>>>>>>>
>> >>>>>>>>>> foo.c: in function 'foo':
>> >>>>>>>>>> foo.c:5:6: note: loop was vectorized
>> >>>>>>>>>>
>> >>>>>>>>>> but in dump file the format for the information may be
>> >>>>>>>>>> different,
>> >>>>>>>>>> unless we want to duplicate the machinery in diagnostics.
>> >>>>>>>>>
>> >>>>>>>>> So?  What's the problem with that ("different" diagnostics)?
>> >>>>>>>>>
>> >>>>>>>>> Richard.
>> >>>>>>>>>
>> >>>>>>>>>> David
>> >>>>>>>>>>
>> >>>>>>>>>>> -- Gaby
>
>

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-10 18:21                                               ` Sharad Singhai
@ 2012-09-11 20:16                                                 ` Xinliang David Li
  2012-09-12  8:15                                                   ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-09-11 20:16 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Can you resend your patch in text form (also need to resolve the
latest conflicts) so that it can be commented inline?

Please also provide as summary a more up-to-date description of
1) Command line option syntax and semantics
2) New dumping APIs and semantics
3) Conversion changes

Looking at the patch briefly, I am confused with the opt-info syntax.
I thought the following is desired:

-fopt-info=pass-flags

where pass is the pass name, and flags is one of [optimized, notes,
missed].  Both pass and flags can be omitted.

Is it implemented this way in your patch?

David




On Mon, Sep 10, 2012 at 11:20 AM, Sharad Singhai <singhai@google.com> wrote:
> Ping.
>
> Thanks,
> Sharad
> Sharad
>
>
> On Wed, Sep 5, 2012 at 10:34 AM, Sharad Singhai <singhai@google.com> wrote:
>> Ping.
>>
>> Thanks,
>> Sharad
>>
>> Sharad
>>
>>
>>
>>
>> On Fri, Aug 24, 2012 at 1:06 AM, Sharad Singhai <singhai@google.com> wrote:
>>>
>>> Sorry about the delay. Please see comments inline.
>>>
>>> On Wed, Jul 4, 2012 at 6:33 AM, Richard Guenther
>>> <richard.guenther@gmail.com> wrote:
>>> > On Tue, Jul 3, 2012 at 11:07 PM, Sharad Singhai <singhai@google.com>
>>> > wrote:
>>> >> Apologies for the spam. Attempting to resend the patch after shrinking
>>> >> it.
>>> >>
>>> >> I have updated the attached patch to use a new dump message
>>> >> classification system for the vectorizer. It currently uses four
>>> >> classes, viz, MSG_OPTIMIZED_LOCATIONS, MSG_UNOPTIMIZED_LOCATION,
>>> >> MSG_MISSING_OPTIMIZATION, and MSG_NOTE. I have gone through the
>>> >> vectorizer passes and have converted each call to fprintf (dump_file,
>>> >> ....) to a message classification matching in spirit. Most often, it
>>> >> is MSG_OPTIMIZED_LOCATIONS, but occasionally others as well.
>>> >>
>>> >> For example, the following
>>> >>
>>> >> if (vect_print_dump_info (REPORT_DETAILS))
>>> >>   {
>>> >>     fprintf (vect_dump, "niters for prolog loop: ");
>>> >>     print_generic_expr (vect_dump, iters, TDF_SLIM);
>>> >>   }
>>> >>
>>> >> gets converted to
>>> >>
>>> >> if (dump_kind (MSG_OPTIMIZED_LOCATIONS))
>>> >>   {
>>> >>      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>>> >>                       "niters for prolog loop: ");
>>> >>      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
>>> >>   }
>>> >>
>>> >> The asymmetry between the first printf and the second is due to the
>>> >> fact that 'vect_print_dump_info (xxx)' prints the location as a
>>> >> "side-effect". To preserve the original intent somewhat, I have
>>> >> converted the first call within a dump sequence to a dump_printf_loc
>>> >> (xxx) which prints the location while the subsequence calls within the
>>> >> same conditional get converted to the corresponding plain variants.
>>> >
>>> > Ok, that looks reasonable.
>>> >
>>> >> I considered removing the support for alternate dump file, but ended
>>> >> up preserving it instead since it is needed for setting the alternate
>>> >> dump file to stderr for the case when -fopt-info is given but no dump
>>> >> file is available.
>>> >>
>>> >> The following invocation
>>> >> g++ ... -ftree-vectorize -fopt-info=4
>>> >>
>>> >> dumps *all* available information to stderr. Currently, the opt-info
>>> >> level is common to all passes, i.e., a pass can't specify if wants a
>>> >> different level of diagnostic info. This can be added as an
>>> >> enhancement with a suitable syntax for selecting passes.
>>> >>
>>> >> I haven't fixed up the documentation/tests but wanted to get some
>>> >> feedback about the current state of patch before doing that.
>>> >
>>> > Some comments / questions.
>>> >
>>> > +  if (dump_file && (dump_kind & opt_info_flags))
>>> > +    {
>>> > +      dump_loc (dump_kind, dump_file, loc);
>>> > +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
>>> > +    }
>>> > +
>>> > +  if (alt_dump_file && (dump_kind & opt_info_flags))
>>> > +    {
>>> >
>>> > you always test dump_kind against the same opt_info_flags variable.
>>> > I would have thought that the alternate dump file has a different
>>> > opt_info_flags
>>> > setting so I can have -fdump-tree-vect-details -fopt-info=1.  Am I
>>> > missing
>>> > something?
>>>
>>> It was an oversight on my part. I have since fixed this. There are two
>>> separate flags corresponding to the two types of dump files,
>>>
>>> pflags ==> pass private dump file
>>> alt_flags ==> opt-info dump file
>>>
>>> > If I do
>>> >
>>> >> gcc file1.c file2.c -O3 -fdump-tree-vectorize=foo
>>> >
>>> > what will foo contain afterwards?  I think you need to document the
>>> > behavior
>>> > when such redirection is used with the compiler-driver feature of
>>> > handling
>>> > multiple translation units.  Especially the difference (or not
>>> > difference) to
>>> >
>>> >> gcc file1.c -O3 -fdump-tree-vectorize=foo
>>> >> gcc file2.c -O3 -fdump-tree-vectorize=foo
>>>
>>> Yes, the dump file gets overwritten during each invocation. I have
>>> noted this in the documentation.
>>>
>>> > I suppose we do not want to append to foo (but eventually support that
>>> > with some alternate syntax?  Like -fdump-tree-vectorize=+foo?)
>>>
>>> Yes, I agree. We could define a new syntax as you suggested for
>>> appending to a dump file. However, this feature can wait for a
>>> separate patch.
>>>
>>> > +
>>> > +static void
>>> > +set_opt_info (int opt_info_level)
>>> > +{
>>> >
>>> > This function needs a comment.  How do the dump flags translate to
>>> > the opt-info flags?  Is this documented anywhere?  I only see
>>> >
>>> > +/* Different types of dump classifications.  */
>>> > +enum dump_msg_kind {
>>> > +  MSG_NONE                     = 1 << 0,
>>> > +  MSG_OPTIMIZED_LOCATIONS      = 1 << 1,
>>> > +  MSG_UNOPTIMIZED_LOCATIONS    = 1 << 2,
>>> > +  MSG_MISSED_OPTIMIZATION      = 1 << 3,
>>> > +  MSG_NOTE                     = 1 << 4
>>> > +};
>>>
>>> Yes, my mapping was static (pass-agnostic), defined inside the
>>> set_opt_info. I
>>> have now documented it and revamped it so that -fopt-info is applied
>>> to specific passes as explained below.
>>>
>>> > I suppose the TDF_* flags would all map to
>>> >
>>> > MSG_OPTIMIZED_LOCATIONS|MSG_UNOPTIMIZED_LOCATIONS|MSG_MISSED_OPTIMIZATION
>>> > and only TDF_DETAILS would enable MSG_NOTE?
>>>
>>> Yes, the mapping is very coarse-grained right now. Currently I have
>>> made MSG_* flags an extension of TDF_* flags. This way both kinds of
>>> flags can be present in a single word yet still be interpreted by the
>>> dumps which are interested in them. TDF_DETAILS gets mapped to a union
>>> of all the MSG_* flags. This will allow flags such -fdump-vect-details
>>> to continue to work as expected during the transition to the new dump
>>> infrastructure. Of coure,  during the transition, we would need to
>>> rejigger flags to express the desired behavior.
>>>
>>> > In the above a flag for MSG_NONE does not make much sense?
>>>
>>> Removed. It is now implicitly 0.
>>>
>>> >
>>> > How would we map TDF_SCEV?  I suppose we'd add MSG_SCEV for this
>>> > (we talked about the possibility of having some special flags for
>>> > special passes).
>>>
>>> Yes, I think this would be necessary. So far, I haven't converted any
>>> passes other than vectorization, and I suspect a handful of special
>>> case flags would be needed. During the transition, the TDF_* flags are
>>> assumed to be an extension of MSG_* flags and things won't break.
>>>
>>> >
>>> > But this also means a linear "opt-info-level" as in
>>> >
>>> > +static void
>>> > +set_opt_info (int opt_info_level)
>>> >
>>> > may not be a good representation.  Not a pass-ignorant opt_info_flags
>>> > value, if you consider -fopt-info=vect,3 (details from the vectorizer
>>> > please).
>>>
>>> Agreed. As I mentioned earlier, I was considering a simple linear view
>>> of -fopt-info. However, I understand that making it pass cognizant is
>>> certainly better. To this end, I have modified the syntax of
>>> -fopt-info somewhat along the lines of -fdump-xxx format. For example,
>>>
>>> gcc ... -fopt-info-tree-vect-optimized=foo.vect.optimized
>>> -fdump-tree-pre-details=stderr ...
>>>
>>> This would dump info about optimized locations from the vectorizer
>>> pass into foo.vect.optimized, and pass dump from the PRE pass on to
>>> stderr.
>>>
>>> >
>>> > +}
>>> > +
>>> > +
>>> > +
>>> > +DEBUG_FUNCTION void
>>> > +dump_combine_stats (int flags)
>>> >
>>> > debug functions should be called debug_*, please add a comment and
>>> > avoid excessive vertical space
>>>
>>> Fixed.
>>>
>>> >
>>> > Index: tree-pass.h
>>> > ===================================================================
>>> > --- tree-pass.h (revision 188966)
>>> > +++ tree-pass.h (working copy)
>>> > @@ -85,7 +85,6 @@ enum tree_dump_index
>>> >  #define TDF_CSELIB     (1 << 23)       /* Dump cselib details.  */
>>> >  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>> >
>>> > -
>>> >  /* In tree-dump.c */
>>> >
>>> >  extern char *get_dump_file_name (int);
>>> >
>>> > please avoid whitespace-only changes (also elsewhere).
>>>
>>> Fixed.
>>>
>>> >
>>> >  /* Global variables used to communicate with passes.  */
>>> >  extern FILE *dump_file;
>>> > +extern FILE *alt_dump_file;
>>> >  extern int dump_flags;
>>> > +extern int opt_info_flags;
>>> >
>>> > so I expected the primary dump_file to be controlled with dump_flags,
>>> > or with a (cached) translation of them to a primary_opt_info_flags.
>>>
>>> Yes, now I have two sets of flags.
>>>
>>> >
>>> > Index: gimple-pretty-print.h
>>> > ===================================================================
>>> > --- gimple-pretty-print.h       (revision 188966)
>>> > +++ gimple-pretty-print.h       (working copy)
>>> > @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>>> >  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>>> >  extern void print_gimple_stmt (FILE *, gimple, int, int);
>>> >  extern void print_gimple_expr (FILE *, gimple, int, int);
>>> > -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
>>> > +extern void print_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>>> >
>>> > I'd call this pp_gimple_stmt instead.
>>>
>>> Fixed.
>>>
>>> >
>>> > @@ -1418,6 +1419,16 @@ init_branch_prob (void)
>>> >  void
>>> >  end_branch_prob (void)
>>> >  {
>>> > +  end_branch_prob_1 (dump_file);
>>> > +  end_branch_prob_1 (alt_dump_file);
>>> > +}
>>> > +
>>> > +/* Helper function for file-level cleanup for DUMP_FILE after
>>> > +   branch-prob processing is completed. */
>>> > +
>>> > +static void
>>> > +end_branch_prob_1 (FILE *dump_file)
>>> > +{
>>> >    if (dump_file)
>>> >      {
>>> >        fprintf (dump_file, "\n");
>>> >
>>> > That change looks odd ;)  Can you instead use the new dump_printf
>>> > interface?  (side-note: we should not need to export alt_dump_file at
>>> > all!)
>>>
>>> Sorry, it was my ill conceived attempt to avoid converting this pass.
>>> :) Anyway, I did a proper fix now, and converted an additional file
>>> (profile.c) as a side benefit.
>>>
>>> >
>>> > @@ -2166,10 +2177,6 @@ ftree-vect-loop-version
>>> >  Common Report Var(flag_tree_vect_loop_version) Init(1) Optimization
>>> >  Enable loop versioning when doing loop vectorization on trees
>>> >
>>> > -ftree-vectorizer-verbose=
>>> > -Common RejectNegative Joined UInteger
>>> > --ftree-vectorizer-verbose=<number>     Set the verbosity level of the
>>> > vectorizer
>>> > -
>>> >
>>> > we need to preserve old switches for backward compatibility, I suggest
>>> > to alias it to -fopt-info for now.
>>>
>>> Okay. I mapped -ftree-vectorizer-verbose=<number> as
>>> 0 ==> No dump output
>>> 1 ==> dump optimized locations
>>> 2 ==> dump missed optimizations
>>> 3 ==> dump notes
>>> 4 and up ==> dump all, i.e., 1, 2, 3
>>>
>>> Curiously, several tests are casualties of reinterpretation of this
>>> flag. Here is how -- the old (and odd) behavior was that
>>>
>>> gcc ... -ftree-vectorize -fdump-tree-vect -ftree-vectorizer-verbose=3
>>>
>>> would output tree-vect dump as usual but nothing would get printed by
>>> -ftree-vectorizer-verbose=3. In this patch I have "fixed" this
>>> behavior so that -ftree-vectorizer-verbose=<n> prints on stderr
>>> regardless of other flags present(*). This has the unfortunate side
>>> effect of extra output being sent to stderr which is interpreted as a
>>> test failure. Please advise how to ignore that additional stderr
>>> output in tests.
>>>
>>> (*) Well, not entirely true. Since -ftree-vectorizer-verbose=<n> is
>>> implemented in terms of -fopt-info, the output of verbose flag is the
>>> stream where ever vectorizer's opt-info is being sent.
>>>
>>> > @@ -13909,7 +13909,7 @@ unmentioned_reg_p (rtx equiv, rtx expr)
>>> >  }
>>> >  ^L
>>> >  DEBUG_FUNCTION void
>>> > -dump_combine_stats (FILE *file)
>>> > +print_combine_stats (FILE *file)
>>> >
>>> > see above, debug_combine_stats.
>>>
>>> Fixed.
>>>
>>> >
>>> > Index: system.h
>>> > ===================================================================
>>> > --- system.h    (revision 188966)
>>> > +++ system.h    (working copy)
>>> > @@ -669,6 +669,7 @@ extern int vsnprintf(char *, size_t, const char *,
>>> >     except, maybe, something to the dump file.  */
>>> >  #ifdef BUFSIZ
>>> >  extern FILE *dump_file;
>>> > +extern FILE *alt_dump_file;
>>> >
>>> > see above - we should not need to export this (nor opt_info_flags).
>>>
>>> Fixed.
>>>
>>> Please take another look and see if the attached patch looks okay? I
>>> still need to fix the failing tests due to intentional output on
>>> stderr.
>>>
>>> Thanks,
>>> Sharad
>>>
>>> >
>>> > Overall I like the patch!
>>> >
>>> > Thanks,
>>> > Richard.
>>> >
>>> >> Thanks,
>>> >> Sharad
>>> >>
>>> >> On Fri, Jun 15, 2012 at 1:18 AM, Richard Guenther
>>> >> <richard.guenther@gmail.com> wrote:
>>> >>> On Fri, Jun 15, 2012 at 7:47 AM, Sharad Singhai <singhai@google.com>
>>> >>> wrote:
>>> >>>> On Wed, Jun 13, 2012 at 4:48 AM, Richard Guenther
>>> >>>> <richard.guenther@gmail.com> wrote:
>>> >>>>> On Fri, Jun 8, 2012 at 7:16 AM, Sharad Singhai <singhai@google.com>
>>> >>>>> wrote:
>>> >>>>>> Okay, I have updated the attached patch so that the output from
>>> >>>>>> -ftree-vectorizer-verbose is considered diagnostic information and
>>> >>>>>> is
>>> >>>>>> always
>>> >>>>>> sent to stderr. Other functionality remains unchanged. Here is some
>>> >>>>>> more context about this patch.
>>> >>>>>>
>>> >>>>>> This patch improves the dump infrastructure and public interfaces
>>> >>>>>> so
>>> >>>>>> that the existing private pass-specific dump stream is separated
>>> >>>>>> from
>>> >>>>>> the diagnostic dump stream (typically stderr).  The optimization
>>> >>>>>> passes can output information on the two streams independently.
>>> >>>>>>
>>> >>>>>> The newly defined interfaces are:
>>> >>>>>>
>>> >>>>>> Individual passes do not need to access the dump file directly.
>>> >>>>>> Thus Instead
>>> >>>>>> of doing
>>> >>>>>>
>>> >>>>>>   if (dump_file && (flags & dump_flags))
>>> >>>>>>      fprintf (dump_file, ...);
>>> >>>>>>
>>> >>>>>> they can do
>>> >>>>>>
>>> >>>>>>     dump_printf (flags, ...);
>>> >>>>>>
>>> >>>>>> If the current pass has FLAGS enabled then the information gets
>>> >>>>>> printed into the dump file otherwise not.
>>> >>>>>>
>>> >>>>>> Similar to the dump_printf (), another function is defined, called
>>> >>>>>>
>>> >>>>>>        diag_printf (dump_flags, ...)
>>> >>>>>>
>>> >>>>>> This prints information only onto the diagnostic stream, typically
>>> >>>>>> standard error. It is useful for separating pass-specific dump
>>> >>>>>> information from
>>> >>>>>> the diagnostic information.
>>> >>>>>>
>>> >>>>>> Currently, as a proof of concept, I have converted vectorizer
>>> >>>>>> passes
>>> >>>>>> to use the new dump format. For this, I have considered
>>> >>>>>> information printed in vect_dump file as diagnostic. Thus 'fprintf'
>>> >>>>>> calls are changed to 'diag_printf'. Some other information printed
>>> >>>>>> to
>>> >>>>>> dump_file is sent to the regular dump file via 'dump_printf ()'. It
>>> >>>>>> helps to separate the two streams because they might serve
>>> >>>>>> different
>>> >>>>>> purposes and might have different formatting requirements.
>>> >>>>>>
>>> >>>>>> For example, using the trunk compiler, the following invocation
>>> >>>>>>
>>> >>>>>> g++ -S v.cc -ftree-vectorize -fdump-tree-vect
>>> >>>>>> -ftree-vectorizer-verbose=2
>>> >>>>>>
>>> >>>>>> prints tree vectorizer dump into a file named 'v.cc.113t.vect'.
>>> >>>>>> However, the verbose diagnostic output is silently
>>> >>>>>> ignored. This is not desirable as the two types of dump should not
>>> >>>>>> interfere.
>>> >>>>>>
>>> >>>>>> After this patch, the vectorizer dump is available in
>>> >>>>>> 'v.cc.113t.vect'
>>> >>>>>> as before, but the verbose vectorizer diagnostic is additionally
>>> >>>>>> printed on stderr. Thus both types of dump information are output.
>>> >>>>>>
>>> >>>>>> An additional feature of this patch is that individual passes can
>>> >>>>>> print dump information into command-line named files instead of
>>> >>>>>> auto
>>> >>>>>> numbered filename. For example,
>>> >>>>>
>>> >>>>> I'd wish you'd leave out this part for a followup.
>>> >>>>>
>>> >>>>>>
>>> >>>>>> g++ -S -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.vect
>>> >>>>>>     -ftree-vectorizer-verbose=2
>>> >>>>>>     -fdump-tree-pre=foo.pre
>>> >>>>>>
>>> >>>>>> This prints the tree vectorizer dump into 'foo.vect', PRE dump into
>>> >>>>>> 'foo.pre', and the vectorizer verbose diagnostic dump onto stderr.
>>> >>>>>>
>>> >>>>>> Please take another look.
>>> >>>>>
>>> >>>>> --- tree-vect-loop-manip.c      (revision 188325)
>>> >>>>> +++ tree-vect-loop-manip.c      (working copy)
>>> >>>>> @@ -789,14 +789,11 @@ slpeel_make_loop_iterate_ntimes (struct loop
>>> >>>>> *loop
>>> >>>>>   gsi_remove (&loop_cond_gsi, true);
>>> >>>>>
>>> >>>>>   loop_loc = find_loop_location (loop);
>>> >>>>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>>> >>>>> -    {
>>> >>>>> -      if (loop_loc != UNKNOWN_LOC)
>>> >>>>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>>> >>>>> +  if (loop_loc != UNKNOWN_LOC)
>>> >>>>> +    dump_printf (TDF_DETAILS, "\nloop at %s:%d: ",
>>> >>>>>                  LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>> >>>>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>>> >>>>> -    }
>>> >>>>> -
>>> >>>>> +  if (dump_flags & TDF_DETAILS)
>>> >>>>> +    dump_gimple_stmt (TDF_SLIM, cond_stmt, 0);
>>> >>>>>   loop->nb_iterations = niters;
>>> >>>>>
>>> >>>>> I'm confused by this.  Why is this not simply
>>> >>>>>
>>> >>>>>  if (loop_loc != UNKNOWN_LOC)
>>> >>>>>    dump_printf (dump_flags, "\nloop at %s:%d: ",
>>> >>>>>                       LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>>> >>>>>  dump_gimple_stmt (dump_flags | TDF_SLIM, cond_stmt, 0);
>>> >>>>>
>>> >>>>> for example.  I notice that you maybe mis-understood the message
>>> >>>>> classification
>>> >>>>> I asked you to add (maybe I confused you by mentioning to eventually
>>> >>>>> re-use
>>> >>>>> the TDF_* flags).  I think you basically provided this message
>>> >>>>> classification
>>> >>>>> by adding two classes by providing both dump_gimple_stmt and
>>> >>>>> diag_gimple_stmt.
>>> >>>>> But still in the above you keep a dump_flags test _and_ you pass in
>>> >>>>> (altered) dump_flags to the dump/diag_gimple_stmt routines.  Let me
>>> >>>>> quote them:
>>> >>>>>
>>> >>>>> +void
>>> >>>>> +dump_gimple_stmt (int flags, gimple gs, int spc)
>>> >>>>> +{
>>> >>>>> +  if (dump_file)
>>> >>>>> +    print_gimple_stmt (dump_file, gs, spc, flags);
>>> >>>>> +}
>>> >>>>>
>>> >>>>> +void
>>> >>>>> +diag_gimple_stmt (int flags, gimple gs, int spc)
>>> >>>>> +{
>>> >>>>> +  if (alt_dump_file)
>>> >>>>> +    print_gimple_stmt (alt_dump_file, gs, spc, flags);
>>> >>>>> +}
>>> >>>>>
>>> >>>>> I'd say it should have been a single function:
>>> >>>>>
>>> >>>>> void
>>> >>>>> dump_gimple_stmt (enum msg_classification, int additional_flags,
>>> >>>>> gimple gs, int spc)
>>> >>>>> {
>>> >>>>>  if (msg_classification & go-to-dumpfile
>>> >>>>>      && dump_file)
>>> >>>>>    print_gimple_stmt (dump_file, gs, spc, dump_flags |
>>> >>>>> additional_flags);
>>> >>>>>  if (msg_classification & go-to-alt-dump-file
>>> >>>>>      && alt_dump_file && (alt_dump_flags & msg_classification))
>>> >>>>>    print_gimple_stmt (alt_dump_file, gs, spc, alt_dump_flags |
>>> >>>>> additional_flags);
>>> >>>>> }
>>> >>>>
>>> >>>> Yes,  I can make the single function work for both regular
>>> >>>> (dump_file)
>>> >>>> and diagnostic (stderr for now) dump streams. In fact, my original
>>> >>>> patch did just that. However, it duplicated output on *both* the
>>> >>>> streams. For example,
>>> >>>>
>>> >>>> gcc -O2 -ftree-vectorize -fdump-tree-vect=foo.vect
>>> >>>> -ftree-vectorizer-verbose=2 foo.c
>>> >>>>
>>> >>>> Since both streams are enabled in this case, a call to dump_printf ()
>>> >>>> would duplicate the information to both files, i.e., the dump and
>>> >>>> diagnostic will be intermixed. Is that intended? My first thought was
>>> >>>> to keep them separated via dump_*() and diag_* () methods.
>>> >>>
>>> >>> No, I think that's intended.  The regular dump-files should contain
>>> >>> everything, the secondary stream (eventually enabled by -fopt-info)
>>> >>> should be a filtered regular dump-file.
>>> >>>
>>> >>> Thanks,
>>> >>> Richard.
>>> >>>
>>> >>>> Thanks,
>>> >>>> Sharad
>>> >>>>
>>> >>>>> where msg_classification would include things to suitably classify
>>> >>>>> messages
>>> >>>>> for -fopt-info, like MSG_MISSED_OPTIMIZATION, MSG_OPTIMIZED,
>>> >>>>> MSG_NOTE.
>>> >>>>>
>>> >>>>> In another place we have
>>> >>>>>
>>> >>>>> @@ -1648,7 +1642,7 @@ vect_can_advance_ivs_p (loop_vec_info
>>> >>>>> loop_vinfo)
>>> >>>>>   /* Analyze phi functions of the loop header.  */
>>> >>>>>
>>> >>>>>   if (vect_print_dump_info (REPORT_DETAILS))
>>> >>>>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>>> >>>>> +    diag_printf (TDF_TREE, "vect_can_advance_ivs_p:");
>>> >>>>>
>>> >>>>> so why's that diag_printf and why TDF_TREE?  I suppose you made all
>>> >>>>> dumps to vect_dump diag_* and all dumps to dump_file dump_*?  I
>>> >>>>> think it should have been
>>> >>>>>
>>> >>>>>   dump_printf (REPORT_DETAILS, "vect_can_advance_ivs_p:");
>>> >>>>>
>>> >>>>> thus dump_printf only gets the msg-classification and the printf
>>> >>>>> args
>>> >>>>> (dump-flags
>>> >>>>> are only meaningful when passed down to pretty-printers).  Thus
>>> >>>>>
>>> >>>>> @@ -1658,8 +1652,8 @@ vect_can_advance_ivs_p (loop_vec_info
>>> >>>>> loop_vinfo)
>>> >>>>>       phi = gsi_stmt (gsi);
>>> >>>>>       if (vect_print_dump_info (REPORT_DETAILS))
>>> >>>>>        {
>>> >>>>> -          fprintf (vect_dump, "Analyze phi: ");
>>> >>>>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>>> >>>>> +          diag_printf (TDF_TREE, "Analyze phi: ");
>>> >>>>> +          diag_gimple_stmt (TDF_SLIM, phi, 0);
>>> >>>>>        }
>>> >>>>>
>>> >>>>> should be
>>> >>>>>
>>> >>>>>  dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>> >>>>>  dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>> >>>>>
>>> >>>>> and the if (vect_print_dump_info (REPORT_DETAILS)) should be what
>>> >>>>> the dump infrastructure provides and thus hidden.  Eventually we
>>> >>>>> should
>>> >>>>> have a dump_kind (msg-classification) so we can replace it with
>>> >>>>>
>>> >>>>>   if (dump_kind (REPORT_DETAILS))
>>> >>>>>     {
>>> >>>>>       dump_printf (REPORT_DETAILS, "Analyze phi: ");
>>> >>>>>       dump_gimple_stmt (REPORT_DETAILS, TDF_SLIM, phi, 0);
>>> >>>>>     }
>>> >>>>>
>>> >>>>> to reduce the runtime overhead when not diagnosing/dumping.
>>> >>>>>
>>> >>>>> @@ -2464,8 +2458,8 @@ vect_create_cond_for_alias_checks
>>> >>>>> (loop_vec_info l
>>> >>>>>     }
>>> >>>>>
>>> >>>>>   if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>>> >>>>> -    fprintf (vect_dump, "created %u versioning for alias
>>> >>>>> checks.\n",
>>> >>>>> -             VEC_length (ddr_p, may_alias_ddrs));
>>> >>>>> +    diag_printf (TDF_TREE, "created %u versioning for alias
>>> >>>>> checks.\n",
>>> >>>>> +                 VEC_length (ddr_p, may_alias_ddrs));
>>> >>>>>  }
>>> >>>>>
>>> >>>>> so here we have a different msg-classification,
>>> >>>>> REPORT_VECTORIZED_LOCATIONS.  As we eventually want a central
>>> >>>>> -fopt-report=... we do not want to leave this implementation detail
>>> >>>>> to
>>> >>>>> individual passes but gather them in a central place.
>>> >>>>>
>>> >>>>> Thanks,
>>> >>>>> Richard.
>>> >>>>>
>>> >>>>>> Thanks,
>>> >>>>>> Sharad
>>> >>>>>>
>>> >>>>>>
>>> >>>>>> On Thu, Jun 7, 2012 at 12:19 AM, Xinliang David Li
>>> >>>>>> <davidxl@google.com> wrote:
>>> >>>>>>> On Wed, Jun 6, 2012 at 10:58 PM, Sharad Singhai
>>> >>>>>>> <singhai@google.com> wrote:
>>> >>>>>>>> Sorry about the delay. I have finally incorporated all the
>>> >>>>>>>> suggestions
>>> >>>>>>>> and reorganized the dump infrastructure a bit. The attached patch
>>> >>>>>>>> updates vectorizer passes so that instead of accessing global
>>> >>>>>>>> dump_file directly, these passes call dump_printf (FLAG, format,
>>> >>>>>>>> ...).
>>> >>>>>>>> The dump_printf can choose between two streams, one regular pass
>>> >>>>>>>> dump
>>> >>>>>>>> file, and another optional command line provided file. Currently,
>>> >>>>>>>> it
>>> >>>>>>>> doesn't discriminate and all the dump information goes to both
>>> >>>>>>>> the
>>> >>>>>>>> streams.
>>> >>>>>>>>
>>> >>>>>>>> Thus, for example,
>>> >>>>>>>>
>>> >>>>>>>> g++ -O2 v.cc -ftree-vectorize -fdump-tree-vect=foo.v
>>> >>>>>>>> -ftree-vectorizer-verbose=3
>>> >>>>>>>
>>> >>>>>>> But the default form of dump option (-fdump-tree-vect) no longer
>>> >>>>>>> interferes with -ftree-vectorize-verbose=xxx output right? (this
>>> >>>>>>> is
>>> >>>>>>> one of the main requirements). One dumped to the primary stream
>>> >>>>>>> (named
>>> >>>>>>> dump file) and the other to the stderr -- the default diagnostic
>>> >>>>>>> (alt)
>>> >>>>>>> stream.
>>> >>>>>>>
>>> >>>>>>> David
>>> >>>>>>>
>>> >>>>>>>>
>>> >>>>>>>> will output the verbose vectorizer information in both *.vect
>>> >>>>>>>> file and
>>> >>>>>>>> foo.v file. However, as I have converted only vectorizer passes
>>> >>>>>>>> so
>>> >>>>>>>> far, there is additional information in *.vect file which is not
>>> >>>>>>>> present in foo.v file. Once other passes are converted to use
>>> >>>>>>>> this
>>> >>>>>>>> scheme, then these two dump files should have identical output.
>>> >>>>>>>>
>>> >>>>>>>> Also note that in this patch -fdump-xxx=yyy format does not
>>> >>>>>>>> override
>>> >>>>>>>> any auto named dump files as in my earlier patches. Instead the
>>> >>>>>>>> dump
>>> >>>>>>>> information is output to both places when a command line dump
>>> >>>>>>>> file
>>> >>>>>>>> option is provided.
>>> >>>>>>>>
>>> >>>>>>>> To summarize:
>>> >>>>>>>> - instead of using dump_begin () / dump_end (), the passes should
>>> >>>>>>>> use
>>> >>>>>>>> dump_start ()/dump_finish (). These new variants do not return
>>> >>>>>>>> the
>>> >>>>>>>> dump_file. However, they still set the global
>>> >>>>>>>> dump_file/dump_flags for
>>> >>>>>>>> the benefit of other passes during the transition.
>>> >>>>>>>> - instead of directly printing to the dump_file, as in
>>> >>>>>>>> if (dump_file)
>>> >>>>>>>>  fprintf (dump_file, ...);
>>> >>>>>>>>
>>> >>>>>>>> The passes should do
>>> >>>>>>>>
>>> >>>>>>>> dump_printf (dump_flag, ...);
>>> >>>>>>>> This will output to dump file(s) only when dump_flag is enabled
>>> >>>>>>>> for a
>>> >>>>>>>> given pass.
>>> >>>>>>>>
>>> >>>>>>>> I have bootstrapped and tested it on x86_64. Does it look okay?
>>> >>>>>>>>
>>> >>>>>>>> Thanks,
>>> >>>>>>>> Sharad
>>> >>>>>>>>
>>> >>>>>>>>
>>> >>>>>>>> On Mon, May 14, 2012 at 12:26 AM, Richard Guenther
>>> >>>>>>>> <richard.guenther@gmail.com> wrote:
>>> >>>>>>>>> On Sat, May 12, 2012 at 6:39 PM, Xinliang David Li
>>> >>>>>>>>> <davidxl@google.com> wrote:
>>> >>>>>>>>>> On Sat, May 12, 2012 at 9:26 AM, Gabriel Dos Reis
>>> >>>>>>>>>> <gdr@integrable-solutions.net> wrote:
>>> >>>>>>>>>>> On Sat, May 12, 2012 at 11:05 AM, Xinliang David Li
>>> >>>>>>>>>>> <davidxl@google.com> wrote:
>>> >>>>>>>>>>>
>>> >>>>>>>>>>>> The downside is that the dump file format will look different
>>> >>>>>>>>>>>> from the
>>> >>>>>>>>>>>> stderr output which is less than ideal.
>>> >>>>>>>>>>>
>>> >>>>>>>>>>> BTW, why do people want to use stderr for dumping internal
>>> >>>>>>>>>>> IRs,
>>> >>>>>>>>>>> as opposed to stdout or other files?  That does not sound
>>> >>>>>>>>>>> right.
>>> >>>>>>>>>>>
>>> >>>>>>>>>>
>>> >>>>>>>>>> I was talking about the transformation information difference.
>>> >>>>>>>>>> In
>>> >>>>>>>>>> stderr (where diagnostics go to), we may have
>>> >>>>>>>>>>
>>> >>>>>>>>>> foo.c: in function 'foo':
>>> >>>>>>>>>> foo.c:5:6: note: loop was vectorized
>>> >>>>>>>>>>
>>> >>>>>>>>>> but in dump file the format for the information may be
>>> >>>>>>>>>> different,
>>> >>>>>>>>>> unless we want to duplicate the machinery in diagnostics.
>>> >>>>>>>>>
>>> >>>>>>>>> So?  What's the problem with that ("different" diagnostics)?
>>> >>>>>>>>>
>>> >>>>>>>>> Richard.
>>> >>>>>>>>>
>>> >>>>>>>>>> David
>>> >>>>>>>>>>
>>> >>>>>>>>>>> -- Gaby
>>
>>

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-11 20:16                                                 ` Xinliang David Li
@ 2012-09-12  8:15                                                   ` Sharad Singhai
       [not found]                                                     ` <CAFiYyc3AJ1C92QhZHTk83rZPgLSqwk+=qgYDeY9HG-p4UPRrMA@mail.gmail.com>
       [not found]                                                     ` <CAAe5K+WvHvnmT8QvKbs9+kxNwO1xdm=RxqqGU3T=z7tcRzQVZg@mail.gmail.com>
  0 siblings, 2 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-09-12  8:15 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Thanks for your comments. Please see my responses inline.

On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
> Can you resend your patch in text form (also need to resolve the
> latest conflicts) so that it can be commented inline?

I tried to include inline patch earlier but my message was bounced
back from patches mailing list. I am trying it again.

> Please also provide as summary a more up-to-date description of
> 1) Command line option syntax and semantics

I added some documentation in the patch. Here are the relevant bits
from invoke.texi.

`-fdump-tree-SWITCH-OPTIONS=FILENAME'
     Control the dumping at various stages of processing the
     intermediate language tree to a file.  The file name is generated
     by appending a switch-specific suffix to the source file name, and
     the file is created in the same directory as the output file. In
     case of `=FILENAME' option, the dump is output on the given file
     instead of the auto named dump files.
     ...

    `=FILENAME'
          Instead of an auto named dump file, output into the given file
          name. The file names `stdout' and `stderr' are treated
          specially and are considered already open standard streams.
          For example,

               gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
                    -fdump-tree-pre=stderr file.c

          outputs vectorizer dump into `foo.dump', while the PRE dump
	  is output on to `stderr'. If two conflicting dump filenames
	  are given for the same pass, then the latter option
	  overrides the earlier one.

`-fopt-info-PASS'
`-fopt-info-PASS-OPTIONS'
`-fopt-info-PASS-OPTIONS=FILENAME'
     Controls optimization dumps from various passes. If the `-OPTIONS'
     form is used, OPTIONS is a list of `-' separated options which
     controls the details of the dump.  If OPTIONS is not specified, it
     defaults to `optimized'. If the FILENAME is not specified, it
     defaults to `stderr'. Note that the output FILENAME will be
     overwritten in case of multiple translation units. If a combined
     output from multiple the translation units is desired, `stderr'
     should be used instead.

     The PASS could be one of the tree or rtl passes. The following
     options are available

    `optimized'
          Print information when a particular optimization is
          successfully applied. It is up to the pass to decide which
          information is relevant. For example, the vectorizer pass
          prints the location of loop which got vectorized.

    `missed'
          Print information about missed optimizations. Individual
          passes control which information to include in the output.
          For example,

               gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed

          will print information about missed vectorization
          opportunities on to stderr.

    `note'
          Print verbose information about optimizations, such as certain
          transformations, more detailed information about decisions
          etc.

    `details'
          Print detailed information from a particular pass. This
          includes OPTIMIZED, MISSED, and NOTE. For example,

               gcc -O2 -ftree-vectorize
-fopt-info-tree-vect-details=vect.details

          outputs detailed optimization report from the vectorization
          pass into `vect.details'.

`-fopt-info-tree-all'
`-fopt-info-tree-all-OPTIONS'
`-fopt-info-tree-all-OPTIONS=FILENAME'
     This is similar to `-fopt-info' but instead of a single pass, it
     applies the dump options to all the tree passes. If the FILENAME
     is provided, the dump from all the passes is concatenated,
     otherwise the dump is output onto `stderr'. If OPTIONS is omitted,
     it defaults to `optimized'.

          gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump

     This will output information about missed optimizations as well as
     optimized locations from all the tree passes into `tree.optdump'.

> 2) New dumping APIs and semantics

New dumping API:

dump_kind_p ==> predicate for whether a particular type of dump is enabled
or not. Uses both dump_flags (TDF_*) and opt_info_flags (MSG_*).

There are two variants, dump_xxx and dump_xxx_loc, the _loc variant is similar,
except it also prints the source location. The source location is
useful in certain
type of dumps, specially for -fopt-info.

Most of these are straightforward.

dump_gimple_stmt
dump_gimple_stmt_loc
dump_generic_expr
dump_generic_expr_loc
dump_printf
dump_printf_loc
dump_basic_block
dump_combine_total_stats

dump_start/dump_finish:

Before beginning of each pass, one needs to call dump_start ()
and at the end must call dump_finish (). I have already added the required
calls in passes.c.

Instead of using dump_file directly, use one of the dump_* functions
declared in dumpfile.h. For example, dump_basic_block (...)
should be used for printing a basic block instead of accessing a dump stream
directly.

> 3) Conversion changes

I have converted vectorizer passes to use the new API. Here is an example

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "=== vect_do_peeling_for_loop_bound ===");

Instead of calling fprintf on vect_dump directly, use
dump_printf_loc. This dump is done only when the
MSG_OPTIMIZED_LOCATIONS dump is enabled. Both -fopt-info dumps and
regular pass dumps are handled uniformly by treating MSG_* flags as
extensions of dump flags.

Unfortunately, for vectorizer passes the change was not mechanical. I had to
decide for each individual dump site what type of dump was appropriate there.
Another added wrinkle was that the source location was printed as a side-effect.
Thus I had to convert some calls to use dump_*_loc variant, but not others.

> Looking at the patch briefly, I am confused with the opt-info syntax.
> I thought the following is desired:
>
> -fopt-info=pass-flags
>
> where pass is the pass name, and flags is one of [optimized, notes,
> missed].  Both pass and flags can be omitted.
>
> Is it implemented this way in your patch?

Close to it but not quite the same way.
I considered this syntax and in fact implemented it. But later updated it to
use -fopt-info-PASS-FLAGS=filename instead, since it was consistent with the
-fdump-PASS-FLAGS=filename. Thus it is very easy to specify opt info
flags for a specific
pass. For example,

-fdump-tree-pre=filename ==> dump PRE pass info
-fopt-info-tree-pre=filename  ==> dump PRE optimization info

Hopefully this syntax is not confusing.

Thanks,
Sharad

Actual patch follows.
-------------------------------------------

2012-09-12  Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for the new option.
	* tree-dump.c: Include "gimple-pretty-print.h".
	Include "rtl.h".
	(pflags): New variable.
	(alt_flags): Ditto.
	(alt_dump_file): Ditto.
	(dump_files):  Update to include additional fields.
	(struct dump_option_value_info): Add additional field.
	(get_dump_file_name): Use command line filename if available.
	(dump_open_alternate_stream): New function.
	(dump_loc): Ditto.
	(dump_gimple_stmt): Ditto.
	(dump_gimple_stmt_loc): Ditto.
	(dump_generic_expr): Ditto.
	(dump_generic_expr_loc): Ditto.
	(dump_printf): Ditto.
	(dump_printf_loc): Ditto.
	(dump_start): Ditto.
	(dump_finish): Ditto.
	(dump_begin): Ditto.
	(dump_enabled_p): Return true if either of the dump types is enabled.
	(dump_initialized_p): Return true if either type of dump is initialized.
	(dump_end): Do not close standard streams.
	(dump_enable_all): Handle filenames for regular dumps.
	(dump_switch_p_1): Handle command-line dump filenames.
	(opt_info_enable_all): New function.
	(remap_tdf_to_msg_flags): Ditto.
	(opt_info_switch_p_1): Ditto.
	(opt_info_switch_p): Ditto.
	(dump_kind_p): Ditto.
	(dump_basic_block): Ditto.
	(dump_combine_total_stats): Ditto.
	(dump_remap_tree_vectorizer_verbose): Ditto.
	* tree-dump.h: Include "input.h".
	* dumpfile.h: Include "coretypes.h".
	Include "input.h".
	(enum dump_msg_kind): New flags for opt-info.
	(struct dump_file_info): Rename flags to pflags, state to pstate,
	stream to pstream, filename to pfilename. All callers updated. Add
	alt_flags, alt_state, alt_filenmae, alt_stream.
	* opts.c: Include "dumpfile.h".
	(vect_set_verbosity_level): Remove.
	(common_handle_option): Handle -fopt-info flag. Deprecate
	-ftree-vectorizer-verbose.
	* tree-parloops.c (gather_scalar_reductions): Remove reference to
	vect_dump.
	* gimple-pretty-print.h: Rename dump_gimple_stmt to
	pp_gimple_stmt_1.  All callers updated.
	* tree-vect-loop-manip.c: Use dump_printf instead of directly
	printing to vect_dump file.
	* tree-vect-patterns.c: Include "dumpfile.h".
	* tree-vectorizer.c: Include "dumpfile.h". Remove vect_dump.
	(vect_set_dump_settings): Remove.
	(vect_print_dump_info): Ditto.
	* tree-vectorizer.h: Remove declaration of vect_dump and
	vect_print_dump_info.
	* profile.c: Include "dumpfile.h".
	Instead of dump_bb use dump_basic_block.
	* tree-vect-loop.c: Include "dumpfile.h".
	* tree-vect-data-refs.c: Include "dumpfile.h".
	* tree-vect-stmts.c: Include "dumpfile.h".
	* tree-vect-slp.c: Include "dumpfile.h".
	* flag-types.h: Remove vect_verbosity_levels.
	* common.opt: Add -fopt-info. Deprecate -ftree-vectorizer-verbose.
	* combine.c: rename dump_combine_stats to debug_combine_stats, and
	rename dump_combine_total_stats to print_combine_total_stats. All
	callers updated.
	* opts-global.c (handle_common_deferred_options): Handle -fopt-info
	and -ftree-vectorizer-verbose.
	* Makefile.in (tree-dump.o): Update dependencies.
	(tree-vect-loop.o): Ditto.
	(tree-vect-loop-manip.o): Ditto.
	(tree-vect-slp.o): Ditto.
	(tree-vect-stmts.o): Ditto.
	(tree-vectorizer.o): Ditto.
	(opts.o): Ditto.
	* passes.c (finish_optimization_passes): Instead of using
	dump_begin/dump_end, use dump_start/dump_finish. Do not use dump_file.
	(pass_init_dump_file): Ditto.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 191208)
+++ doc/invoke.texi	(working copy)
@@ -330,6 +330,9 @@ Objective-C and Objective-C++ Dialects}.
 -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
 -fdebug-types-section -fmem-report-wpa @gol
 -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs @gol
+-fopt-info-@var{pass}@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
+-fopt-info-tree-all@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
+-fopt-info-rtl-all@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
 -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
 -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
 -fstack-usage  -ftest-coverage  -ftime-report -fvar-tracking @gol
@@ -5345,20 +5348,23 @@ Here are some examples showing uses of these optio

 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass}=@var{filename}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
 compiler.  The file names for most of the dumps are made by appending
 a pass number and a word to the @var{dumpname}, and the files are
-created in the directory of the output file.  Note that the pass
-number is computed statically as passes get registered into the pass
-manager.  Thus the numbering is not related to the dynamic order of
-execution of passes.  In particular, a pass installed by a plugin
-could have a number over 200 even if it executed quite early.
-@var{dumpname} is generated from the name of the output file, if
-explicitly specified and it is not an executable, otherwise it is the
-basename of the source file. These switches may have different effects
-when @option{-E} is used for preprocessing.
+created in the directory of the output file. In case of
+@option{=@var{filename}} option, the dump is output on the given file
+instead of the pass numbered dump files. Note that the pass number is
+computed statically as passes get registered into the pass manager.
+Thus the numbering is not related to the dynamic order of execution of
+passes.  In particular, a pass installed by a plugin could have a
+number over 200 even if it executed quite early.  @var{dumpname} is
+generated from the name of the output file, if explicitly specified
+and it is not an executable, otherwise it is the basename of the
+source file. These switches may have different effects when
+@option{-E} is used for preprocessing.

 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
 @option{-d} option @var{letters}.  Here are the possible
@@ -5739,15 +5745,18 @@ counters for each function compiled.

 @item -fdump-tree-@var{switch}
 @itemx -fdump-tree-@var{switch}-@var{options}
+@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
 @opindex fdump-tree
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch-specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
-@samp{-@var{options}} form is used, @var{options} is a list of
-@samp{-} separated options which control the details of the dump.  Not
-all options are applicable to all dumps; those that are not
-meaningful are ignored.  The following options are available
+created in the same directory as the output file. In case of
+@option{=@var{filename}} option, the dump is output on the given file
+instead of the auto named dump files.  If the @samp{-@var{options}}
+form is used, @var{options} is a list of @samp{-} separated options
+which control the details of the dump.  Not all options are applicable
+to all dumps; those that are not meaningful are ignored.  The
+following options are available

 @table @samp
 @item address
@@ -5785,6 +5794,22 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item =@var{filename}
+Instead of an auto named dump file, output into the given file
+name. The file names @file{stdout} and @file{stderr} are treated
+specially and are considered already open standard streams. For
+example,
+
+@smallexample
+gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
+     -fdump-tree-pre=stderr file.c
+@end smallexample
+
+outputs vectorizer dump into @file{foo.dump}, while the PRE dump is
+output on to @file{stderr}. If two conflicting dump filenames are
+given for the same pass, then the latter option overrides the earlier
+one.
+
 @item all
 Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
 and @option{lineno}.
@@ -5935,34 +5960,98 @@ is made by appending @file{.vrp} to the source fil
 Enable all the available tree dumps with the flags provided in this option.
 @end table

+@item -fopt-info-@var{pass}
+@itemx -fopt-info-@var{pass}-@var{options}
+@itemx -fopt-info-@var{pass}-@var{options}=@var{filename}
+@opindex fopt-info
+Controls optimization dumps from various passes. If the
+@samp{-@var{options}} form is used, @var{options} is a list of
+@samp{-} separated options which controls the details of the dump.  If
+@var{options} is not specified, it defaults to @option{optimized}. If
+the @var{filename} is not specified, it defaults to
+@file{stderr}. Note that the output @var{filename} will be overwritten
+in case of multiple translation units. If a combined output from
+multiple the translation units is desired, @file{stderr} should be
+used instead.
+
+The @var{pass} could be one of the tree or rtl passes. The following
+options are available
+
+@table @samp
+@item optimized
+Print information when a particular optimization is successfully
+applied. It is up to the pass to decide which information is
+relevant. For example, the vectorizer pass prints the location of loop
+which got vectorized.
+@item missed
+Print information about missed optimizations. Individual passes
+control which information to include in the output. For example,
+
+@smallexample
+gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed
+@end smallexample
+
+will print information about missed vectorization opportunities on
+to stderr.
+@item note
+Print verbose information about optimizations, such as certain
+transformations, more detailed information about decisions etc.
+@item details
+Print detailed information from a particular pass. This includes
+@var{optimized}, @var{missed}, and @var{note}. For example,
+
+@smallexample
+gcc -O2 -ftree-vectorize -fopt-info-tree-vect-details=vect.details
+@end smallexample
+
+outputs detailed optimization report from the vectorization pass into
+@file{vect.details}.
+@end table
+
+@item -fopt-info-tree-all
+@itemx -fopt-info-tree-all-@var{options}
+@itemx -fopt-info-tree-all-@var{options}=@var{filename}
+@opindex fopt-info-tree-all
+This is similar to @option{-fopt-info} but instead of a single pass,
+it applies the dump options to all the tree passes. If the
+@var{filename} is provided, the dump from all the passes is
+concatenated, otherwise the dump is output onto @file{stderr}. If
+@var{options} is omitted, it defaults to @option{optimized}.
+
+@smallexample
+gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump
+@end smallexample
+
+This will output information about missed optimizations as well as
+optimized locations from all the tree passes into @file{tree.optdump}.
+
+@item -fopt-info-rtl-all
+@itemx -fopt-info-rtl-all-@var{options}
+@itemx -fopt-info-rtl-all-@var{options}=@var{filename}
+@opindex fopt-info-rtl-all
+This is similar to @option{-fopt-info-tree-all} but instead of tree
+passes, it applies the dump options to all the rtl passes.
+
 @item -ftree-vectorizer-verbose=@var{n}
 @opindex ftree-vectorizer-verbose
-This option controls the amount of debugging output the vectorizer prints.
-This information is written to standard error, unless
-@option{-fdump-tree-all} or @option{-fdump-tree-vect} is specified,
-in which case it is output to the usual dump listing file, @file{.vect}.
-For @var{n}=0 no diagnostic information is reported.
-If @var{n}=1 the vectorizer reports each loop that got vectorized,
-and the total number of loops that got vectorized.
-If @var{n}=2 the vectorizer also reports non-vectorized loops that passed
-the first analysis phase (vect_analyze_loop_form) - i.e.@: countable,
-inner-most, single-bb, single-entry/exit loops.  This is the same verbosity
-level that @option{-fdump-tree-vect-stats} uses.
-Higher verbosity levels mean either more information dumped for each
-reported loop, or same amount of information reported for more loops:
-if @var{n}=3, vectorizer cost model information is reported.
-If @var{n}=4, alignment related information is added to the reports.
-If @var{n}=5, data-references related information (e.g.@: memory dependences,
-memory access-patterns) is added to the reports.
-If @var{n}=6, the vectorizer reports also non-vectorized inner-most loops
-that did not pass the first analysis phase (i.e., may not be countable, or
-may have complicated control-flow).
-If @var{n}=7, the vectorizer reports also non-vectorized nested loops.
-If @var{n}=8, SLP related information is added to the reports.
-For @var{n}=9, all the information the vectorizer generates during its
-analysis and transformation is reported.  This is the same verbosity level
-that @option{-fdump-tree-vect-details} uses.
+This option is deprecated and is implemented in terms of
+@option{-fopt-info}. Please use
+@option{-fopt-info-tree-vect-@var{kind}} form instead, where
+@var{kind} is one of the valid opt-info kinds. It prints additional
+information about the vectorizer pass.  For @var{n}=0 no diagnostic
+information is reported.  If @var{n}=1 the vectorizer reports each
+loop that got vectorized, and the total number of loops that got
+vectorized.  If @var{n}=2 the vectorizer reports locations which could
+not be vectorized and the reasons for those. For any higher verbosity
+levels all the analysis and transformation information is reported.
+This is the same verbosity level that
+@option{-fdump-tree-vect-details} uses.

+Note that the information output by @option{-ftree-vectorizer-verbose}
+option is sent to @file{stderr}. If the equivalent form
+@option{-fopt-info-tree-vect-@var{options}=@var{filename}}
+is used then the information is output into @var{filename} instead.
+
 @item -frandom-seed=@var{string}
 @opindex frandom-seed
 This option provides a seed that GCC uses in place of
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 191208)
+++ tree-dump.c	(working copy)
@@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "gimple-pretty-print.h"
 #include "splay-tree.h"
 #include "filenames.h"
 #include "diagnostic-core.h"
+#include "rtl.h"
 #include "toplev.h"
 #include "tree-dump.h"
 #include "langhooks.h"
@@ -37,12 +39,18 @@ along with GCC; see the file COPYING3.  If not see
 #define skip_leading_substring(whole,  part) \
    (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))

+static int pflags;                   /* current dump_flags */
+static int alt_flags;                /* current opt_info flags */
+static FILE *alt_dump_file = NULL;
 static unsigned int queue (dump_info_p, const_tree, int);
 static void dump_index (dump_info_p, unsigned int);
 static void dequeue_and_dump (dump_info_p);
 static void dump_new_line (dump_info_p);
 static void dump_maybe_newline (dump_info_p);
+static void dump_loc (int, FILE *, source_location);

+extern void dump_bb (FILE *, basic_block, int, int);
+
 /* Add T to the end of the queue of nodes to dump.  Returns the index
    assigned to T.  */

@@ -769,23 +777,28 @@ dump_node (const_tree t, int flags, FILE *stream)
 \f

 /* Table of tree dump switches. This must be consistent with the
-   tree_dump_index enumeration in tree-pass.h.  */
+   TREE_DUMP_INDEX enumeration in dumpfile.h.  */
 static struct dump_file_info dump_files[TDI_end] =
 {
-  {NULL, NULL, NULL, 0, 0, 0},
-  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
-  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
-  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
-  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
-  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
-  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
-  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
-  {".ads", "ada-spec", NULL, 0, 0, 7},
+  {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0},
+  {".cgraph", "ipa-cgraph", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0},
+  {".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   0, 1},
+  {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   0, 2},
+  {".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   0, 3},
+  {".gimple", "tree-gimple", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   0, 4},
+  {".nested", "tree-nested", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
+   0, 5},
+  {".vcg", "tree-vcg", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 6},
+  {".ads", "ada-spec", NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 7},
 #define FIRST_AUTO_NUMBERED_DUMP 8

-  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
-  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
-  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
+  {NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 0},
+  {NULL, "rtl-all", NULL, NULL, NULL, NULL, NULL, TDF_RTL, 0, 0, 0, 0},
+  {NULL, "ipa-all", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0},
 };

 /* Dynamically registered tree dump files and switches.  */
@@ -798,38 +811,57 @@ struct dump_option_value_info
 {
   const char *const name;	/* the name of the value */
   const int value;		/* the value of the name */
+  const int msg_flags;           /* corresponding MSG_* flags */
 };

 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in dumpfile.h and opt_info_options below. */
 static const struct dump_option_value_info dump_options[] =
 {
-  {"address", TDF_ADDRESS},
-  {"asmname", TDF_ASMNAME},
-  {"slim", TDF_SLIM},
-  {"raw", TDF_RAW},
-  {"graph", TDF_GRAPH},
-  {"details", TDF_DETAILS},
-  {"cselib", TDF_CSELIB},
-  {"stats", TDF_STATS},
-  {"blocks", TDF_BLOCKS},
-  {"vops", TDF_VOPS},
-  {"lineno", TDF_LINENO},
-  {"uid", TDF_UID},
-  {"stmtaddr", TDF_STMTADDR},
-  {"memsyms", TDF_MEMSYMS},
-  {"verbose", TDF_VERBOSE},
-  {"eh", TDF_EH},
-  {"alias", TDF_ALIAS},
-  {"nouid", TDF_NOUID},
-  {"enumerate_locals", TDF_ENUMERATE_LOCALS},
-  {"scev", TDF_SCEV},
+  {"address", TDF_ADDRESS, 0},
+  {"asmname", TDF_ASMNAME, 0},
+  {"slim", TDF_SLIM, 0},
+  {"raw", TDF_RAW, 0},
+  {"graph", TDF_GRAPH, 0},
+  {"details", TDF_DETAILS, (MSG_OPTIMIZED_LOCATIONS
+                            | MSG_MISSED_OPTIMIZATION
+                            | MSG_NOTE)},
+  {"cselib", TDF_CSELIB, 0},
+  {"stats", TDF_STATS, 0},
+  {"blocks", TDF_BLOCKS, 0},
+  {"vops", TDF_VOPS, 0},
+  {"lineno", TDF_LINENO, 0},
+  {"uid", TDF_UID, 0},
+  {"stmtaddr", TDF_STMTADDR, 0},
+  {"memsyms", TDF_MEMSYMS, 0},
+  {"verbose", TDF_VERBOSE, 0},
+  {"eh", TDF_EH, 0},
+  {"alias", TDF_ALIAS, 0},
+  {"nouid", TDF_NOUID, 0},
+  {"enumerate_locals", TDF_ENUMERATE_LOCALS, 0},
+  {"scev", TDF_SCEV, 0},
   {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
 	    | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
-	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV)},
-  {NULL, 0}
+	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV),
+   (MSG_OPTIMIZED_LOCATIONS
+    | MSG_MISSED_OPTIMIZATION
+    | MSG_NOTE)},
+  {NULL, 0, 0}
 };

+/* Table of opt-info options. This must be consistent with the MSG_*
+   flags in dumpfile.h. The third field of this table is unused. */
+static const struct dump_option_value_info opt_info_options[] =
+{
+  {"optimized", MSG_OPTIMIZED_LOCATIONS, 0},
+  {"missed", MSG_MISSED_OPTIMIZATION, 0},
+  {"note", MSG_NOTE, 0},
+  {"details", (MSG_OPTIMIZED_LOCATIONS
+               | MSG_MISSED_OPTIMIZATION
+               | MSG_NOTE), 0},
+  {NULL, 0, 0}
+};
+
 unsigned int
 dump_register (const char *suffix, const char *swtch, const char *glob,
 	       int flags)
@@ -854,7 +886,7 @@ dump_register (const char *suffix, const char *swt
   extra_dump_files[count].suffix = suffix;
   extra_dump_files[count].swtch = swtch;
   extra_dump_files[count].glob = glob;
-  extra_dump_files[count].flags = flags;
+  extra_dump_files[count].pflags = flags;
   extra_dump_files[count].num = num;

   return count + TDI_end;
@@ -888,17 +920,21 @@ get_dump_file_name (int phase)
     return NULL;

   dfi = get_dump_file_info (phase);
-  if (dfi->state == 0)
+  if (dfi->pstate == 0)
     return NULL;

+  /* If available, use the command line dump filename. */
+  if (dfi->pfilename)
+    return xstrdup (dfi->pfilename);
+
   if (dfi->num < 0)
     dump_id[0] = '\0';
   else
     {
       char suffix;
-      if (dfi->flags & TDF_TREE)
+      if (dfi->pflags & TDF_TREE)
 	suffix = 't';
-      else if (dfi->flags & TDF_IPA)
+      else if (dfi->pflags & TDF_IPA)
 	suffix = 'i';
       else
 	suffix = 'r';
@@ -910,6 +946,248 @@ get_dump_file_name (int phase)
   return concat (dump_base_name, dump_id, dfi->suffix, NULL);
 }

+/* Open an alternate dump filename for PHASE (which could also be a
+   standard stream such as stdout/stderr). If the alternate dump file
+   cannot be opened, return NULL.  */
+
+static FILE *
+dump_open_alternate_stream (int phase)
+{
+  FILE *stream ;
+  struct dump_file_info *dfi;
+
+  dfi = get_dump_file_info (phase);
+  if (!dfi->alt_filename)
+    return NULL;
+
+  if (dfi->alt_stream)
+    return dfi->alt_stream;
+
+  stream = strcmp("stderr", dfi->alt_filename) == 0
+    ? stderr
+    : strcmp("stdout", dfi->alt_filename) == 0
+    ?  stdout
+    : fopen (dfi->alt_filename, dfi->alt_state < 0 ? "w" : "a");
+
+  if (!stream)
+    error ("could not open dump file %qs: %m", dfi->alt_filename);
+  else
+    dfi->alt_state = 1;
+
+  return stream;
+}
+
+/* Print source location on DFILE if enabled.  */
+
+void
+dump_loc (int dump_kind, FILE *dfile, source_location loc)
+{
+  /* Currently vectorization passes print location information.  */
+  if (dump_kind)
+    {
+      if (loc == UNKNOWN_LOCATION)
+        fprintf (dfile, "\n%s:%d: note: ",
+                 DECL_SOURCE_FILE (current_function_decl),
+                 DECL_SOURCE_LINE (current_function_decl));
+     else
+        fprintf (dfile, "\n%d: ", LOCATION_LINE (loc));
+    }
+}
+
+/* Dump gimple statement GS with SPC indentation spaces and
+   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
+
+void
+dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int spc)
+{
+  if (dump_file && (dump_kind & pflags))
+    print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
+
+  if (alt_dump_file && (dump_kind & alt_flags))
+    print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
+}
+
+/* Similar to dump_gimple_stmt, except additionally print source location.  */
+
+void
+dump_gimple_stmt_loc (int dump_kind, source_location loc, int extra_dump_flags,
+                      gimple gs, int spc)
+{
+  if (dump_file && (dump_kind & pflags))
+    {
+      dump_loc (dump_kind, dump_file, loc);
+      print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
+    }
+
+  if (alt_dump_file && (dump_kind & alt_flags))
+    {
+      dump_loc (dump_kind, alt_dump_file, loc);
+      print_gimple_stmt (alt_dump_file, gs, spc, dump_flags |
extra_dump_flags);
+    }
+}
+
+/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
+   enabled.  */
+
+void
+dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
+{
+  if (dump_file && (dump_kind & pflags))
+      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
+
+  if (alt_dump_file && (dump_kind & alt_flags))
+      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
+}
+
+
+/* Similar to dump_generic_expr, except additionally print the source
+   location.  */
+
+void
+dump_generic_expr_loc (int dump_kind, source_location loc,
+                       int extra_dump_flags, tree t)
+{
+  if (dump_file && (dump_kind & pflags))
+    {
+      dump_loc (dump_kind, dump_file, loc);
+      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
+    }
+
+  if (alt_dump_file && (dump_kind & alt_flags))
+    {
+      dump_loc (dump_kind, alt_dump_file, loc);
+      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
+    }
+}
+
+/* Output a formatted message using FORMAT on appropriate dump streams.  */
+
+void
+dump_printf (int dump_kind, const char *format, ...)
+{
+  if (dump_file && (dump_kind & pflags))
+    {
+      va_list ap;
+      va_start (ap, format);
+      vfprintf (dump_file, format, ap);
+      va_end (ap);
+    }
+
+  if (alt_dump_file && (dump_kind & alt_flags))
+    {
+      va_list ap;
+      va_start (ap, format);
+      vfprintf (alt_dump_file, format, ap);
+      va_end (ap);
+    }
+}
+
+/* Similar to dump_printf, except source location is also printed.  */
+
+void
+dump_printf_loc (int dump_kind, source_location loc, const char *format, ...)
+{
+  if (dump_file && (dump_kind & pflags))
+    {
+      va_list ap;
+      dump_loc (dump_kind, dump_file, loc);
+      va_start (ap, format);
+      vfprintf (dump_file, format, ap);
+      va_end (ap);
+    }
+
+  if (alt_dump_file && (dump_kind & alt_flags))
+    {
+      va_list ap;
+      dump_loc (dump_kind, alt_dump_file, loc);
+      va_start (ap, format);
+      vfprintf (alt_dump_file, format, ap);
+      va_end (ap);
+    }
+}
+
+/* Start a dump for PHASE. Store user-supplied dump flags in
+   *FLAG_PTR.  Return the number of streams opened.  Set globals
+   DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
+   set dump_flags appropriately for both pass dump stream and opt-info
+   stream. */
+
+int
+dump_start (int phase, int *flag_ptr)
+{
+  int count = 0;
+  char *name;
+  struct dump_file_info *dfi;
+  FILE *stream;
+  if (phase == TDI_none || !dump_enabled_p (phase))
+    return 0;
+
+  dfi = get_dump_file_info (phase);
+  name = get_dump_file_name (phase);
+  if (name)
+    {
+      stream = strcmp("stderr", name) == 0
+          ? stderr
+          : strcmp("stdout", name) == 0
+          ?  stdout
+          : fopen (name, dfi->pstate < 0 ? "w" : "a");
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        {
+          dfi->pstate = 1;
+          count++;
+        }
+      free (name);
+      dfi->pstream = stream;
+      dump_file = dfi->pstream;
+      /* Initialize current dump flags. */
+      pflags = dfi->pflags;
+    }
+
+  stream = dump_open_alternate_stream (phase);
+  if (stream)
+    {
+      dfi->alt_stream = stream;
+      count++;
+      alt_dump_file = dfi->alt_stream;
+      /* Initialize current opt-info flags. */
+      alt_flags = dfi->alt_flags;
+    }
+
+  if (flag_ptr)
+    *flag_ptr = dfi->pflags;
+
+  return count;
+}
+
+/* Finish a tree dump for PHASE and close associated dump streams.  Also
+   reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS.  */
+
+void
+dump_finish (int phase)
+{
+  struct dump_file_info *dfi;
+
+  if (phase < 0)
+    return;
+  dfi = get_dump_file_info (phase);
+  if (dfi->pstream)
+    fclose (dfi->pstream);
+
+  if (dfi->alt_stream && strcmp("stderr", dfi->alt_filename) != 0
+      && strcmp("stdout", dfi->alt_filename) != 0)
+    fclose (dfi->alt_stream);
+
+  dfi->alt_stream = NULL;
+  dfi->pstream = NULL;
+  dump_file = NULL;
+  alt_dump_file = NULL;
+  dump_flags = TDI_none;
+  alt_flags = 0;
+  pflags = 0;
+}
+
 /* Begin a tree dump for PHASE. Stores any user supplied flag in
    *FLAG_PTR and returns a stream to write to. If the dump is not
    enabled, returns NULL.
@@ -926,22 +1204,33 @@ dump_begin (int phase, int *flag_ptr)
     return NULL;

   name = get_dump_file_name (phase);
+  if (!name)
+    return NULL;
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
+
+  stream = strcmp("stderr", name) == 0
+    ? stderr
+    : strcmp("stdout", name) == 0
+    ?  stdout
+    : fopen (name, dfi->pstate < 0 ? "w" : "a");
+
   if (!stream)
     error ("could not open dump file %qs: %m", name);
   else
-    dfi->state = 1;
+    dfi->pstate = 1;
   free (name);

   if (flag_ptr)
-    *flag_ptr = dfi->flags;
+    *flag_ptr = dfi->pflags;

+  /* Initialize current flags */
+  pflags = dfi->pflags;
   return stream;
 }

-/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
-   TDI_tree_all, return nonzero if any dump is enabled.  */
+/* Returns nonzero if dump PHASE is enabled for at least one stream.
+   If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
+   any phase.  */

 int
 dump_enabled_p (int phase)
@@ -950,17 +1239,17 @@ dump_enabled_p (int phase)
     {
       size_t i;
       for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-	if (dump_files[i].state)
+	if (dump_files[i].pstate || dump_files[i].alt_state)
 	  return 1;
       for (i = 0; i < extra_dump_files_in_use; i++)
-	if (extra_dump_files[i].state)
+	if (extra_dump_files[i].pstate || extra_dump_files[i].alt_state)
 	  return 1;
       return 0;
     }
   else
     {
       struct dump_file_info *dfi = get_dump_file_info (phase);
-      return dfi->state;
+      return dfi->pstate || dfi->alt_state;
     }
 }

@@ -970,7 +1259,7 @@ int
 dump_initialized_p (int phase)
 {
   struct dump_file_info *dfi = get_dump_file_info (phase);
-  return dfi->state > 0;
+  return dfi->pstate > 0 || dfi->alt_state > 0;
 }

 /* Returns the switch name of PHASE.  */
@@ -988,37 +1277,130 @@ dump_flag_name (int phase)
 void
 dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
 {
-  fclose (stream);
+  if (stream != stderr && stream != stdout)
+    fclose (stream);
 }

-/* Enable all tree dumps.  Return number of enabled tree dumps.  */
+/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
+   enabled tree dumps.  */

 static int
-dump_enable_all (int flags)
+dump_enable_all (int flags, const char *filename)
 {
   int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
   int n = 0;
   size_t i;

   for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
-    if ((dump_files[i].flags & ir_dump_type))
-      {
-        dump_files[i].state = -1;
-        dump_files[i].flags |= flags;
-        n++;
-      }
+    {
+      if ((dump_files[i].pflags & ir_dump_type))
+        {
+          const char *old_filename = dump_files[i].pfilename;
+          dump_files[i].pstate = -1;
+          dump_files[i].pflags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            {
+              dump_files[i].pfilename = xstrdup (filename);
+              /* Since it is a command-line provided file, which is
+                 common to all the phases, use it in append mode.  */
+              dump_files[i].pstate = 1;
+            }
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }

   for (i = 0; i < extra_dump_files_in_use; i++)
-    if ((extra_dump_files[i].flags & ir_dump_type))
-      {
-        extra_dump_files[i].state = -1;
-        extra_dump_files[i].flags |= flags;
-	n++;
-      }
+    {
+      if ((extra_dump_files[i].pflags & ir_dump_type))
+        {
+          const char *old_filename = extra_dump_files[i].pfilename;
+          extra_dump_files[i].pstate = -1;
+          extra_dump_files[i].pflags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            {
+              extra_dump_files[i].pfilename = xstrdup (filename);
+              /* Since it is a command-line provided file, which is
+                 common to all the phases, use it in append mode.  */
+              extra_dump_files[i].pstate = 1;
+            }
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }

   return n;
 }

+/* Enable opt-info dumps on all IR_DUMP_TYPE passes with FLAGS on
+   FILENAME.  Return the number of enabled dumps.  */
+
+static int
+opt_info_enable_all (int ir_dump_type, int flags, const char *filename)
+{
+  int n = 0;
+  size_t i;
+
+  for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
+    {
+      if ((dump_files[i].pflags & ir_dump_type))
+        {
+          const char *old_filename = dump_files[i].alt_filename;
+          dump_files[i].alt_state = -1;
+          dump_files[i].alt_flags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            dump_files[i].alt_filename = xstrdup (filename);
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }
+
+  for (i = 0; i < extra_dump_files_in_use; i++)
+    {
+      if ((extra_dump_files[i].pflags & ir_dump_type))
+        {
+          const char *old_filename = extra_dump_files[i].alt_filename;
+          extra_dump_files[i].alt_state = -1;
+          extra_dump_files[i].alt_flags |= flags;
+          n++;
+          /* Override the existing filename.  */
+          if (filename)
+            extra_dump_files[i].alt_filename = xstrdup (filename);
+          if (old_filename && filename != old_filename)
+            free (CONST_CAST (char *, old_filename));
+        }
+    }
+
+  return n;
+}
+
+/* For given TDF_FLAGS, return corresponding MSG_* flags. */
+
+static int
+remap_tdf_to_msg_flags (const int tdf_flags)
+{
+  const struct dump_option_value_info *option_ptr;
+  int msg_flags = 0;
+
+  for (option_ptr = dump_options; option_ptr->name; option_ptr++)
+    if ((tdf_flags & option_ptr->value))
+      {
+        /* If we have msg flags in the table use those, otherwise just
+           use tdf_flags for compatibility reasons. Recall that TDF_*
+           and MSG_* flags are in exclusive range.  */
+        msg_flags |= (option_ptr->msg_flags)
+          ? option_ptr->msg_flags
+          : option_ptr->value;
+      }
+  return msg_flags;
+}
+
 /* Parse ARG as a dump switch. Return nonzero if it is, and store the
    relevant details in the dump_files array.  */

@@ -1036,7 +1418,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
   if (!option_value)
     return 0;

-  if (*option_value && *option_value != '-')
+  if (*option_value && *option_value != '-' && *option_value != '=')
     return 0;

   ptr = option_value;
@@ -1046,11 +1428,17 @@ dump_switch_p_1 (const char *arg, struct dump_file
     {
       const struct dump_option_value_info *option_ptr;
       const char *end_ptr;
+      const char *eq_ptr;
       unsigned length;

       while (*ptr == '-')
 	ptr++;
       end_ptr = strchr (ptr, '-');
+      eq_ptr = strchr (ptr, '=');
+
+      if (eq_ptr && !end_ptr)
+        end_ptr = eq_ptr;
+
       if (!end_ptr)
 	end_ptr = ptr + strlen (ptr);
       length = end_ptr - ptr;
@@ -1058,23 +1446,36 @@ dump_switch_p_1 (const char *arg, struct dump_file
       for (option_ptr = dump_options; option_ptr->name; option_ptr++)
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
-	  {
-	    flags |= option_ptr->value;
+          {
+            flags |= option_ptr->value;
 	    goto found;
-	  }
-      warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
-	       length, ptr, dfi->swtch);
+          }
+
+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  This
+             filename overrides other command line filenames.  */
+          if (dfi->pfilename)
+            free (CONST_CAST (char *, dfi->pfilename));
+          dfi->pfilename = xstrdup (ptr + 1);
+          break;
+        }
+      else
+        warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
+                 length, ptr, dfi->swtch);
     found:;
       ptr = end_ptr;
     }

-  dfi->state = -1;
-  dfi->flags |= flags;
+  dfi->pstate = -1;
+  dfi->pflags |= flags;
+  /* Translate these TDF_* flags to the additional MSG_* flags.  */
+  dfi->pflags |= remap_tdf_to_msg_flags (flags);

   /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
      known dumps.  */
   if (dfi->suffix == NULL)
-    dump_enable_all (dfi->flags);
+    dump_enable_all (dfi->pflags, dfi->pfilename);

   return 1;
 }
@@ -1104,6 +1505,101 @@ dump_switch_p (const char *arg)
   return any;
 }

+/* Parse ARG as a -fopt-info= switch and store corresponding info in
+   DFI.  Return non-zero if it is a recognized switch.  */
+
+static int
+opt_info_switch_p_1 (const char *arg, struct dump_file_info *dfi)
+{
+  const char *option_value;
+  const char *ptr;
+  int flags;
+
+  option_value = skip_leading_substring (arg, dfi->swtch);
+  if (!option_value)
+    return 0;
+
+  if (*option_value && *option_value != '-' && *option_value != '=')
+    return 0;
+
+  ptr = option_value;
+  flags = 0;
+
+  while (*ptr)
+    {
+      const struct dump_option_value_info *option_ptr;
+      const char *end_ptr;
+      const char *eq_ptr;
+      unsigned length;
+
+      while (*ptr == '-')
+	ptr++;
+      end_ptr = strchr (ptr, '-');
+      eq_ptr = strchr (ptr, '=');
+
+      if (eq_ptr && !end_ptr)
+        end_ptr = eq_ptr;
+
+      if (!end_ptr)
+	end_ptr = ptr + strlen (ptr);
+      length = end_ptr - ptr;
+
+      for (option_ptr = opt_info_options; option_ptr->name; option_ptr++)
+	if (strlen (option_ptr->name) == length
+	    && !memcmp (option_ptr->name, ptr, length))
+          {
+            flags |= option_ptr->value;
+	    goto found;
+          }
+
+      if (*ptr == '=')
+        {
+          /* Interpret rest of the argument as a dump filename.  This
+             filename overrides other command line filenames.  */
+          if (dfi->alt_filename)
+            free (CONST_CAST (char *, dfi->alt_filename));
+          dfi->alt_filename = xstrdup (ptr + 1);
+          break;
+        }
+      else
+        warning (0, "ignoring unknown option %q.*s in %<-fopt-info=%s%>",
+                 length, ptr, dfi->swtch);
+    found:;
+      ptr = end_ptr;
+    }
+
+  dfi->alt_state = -1;
+  /* If there was no command line opt-info dump option, use a default.  */
+  if (!flags)
+    flags = MSG_OPTIMIZED_LOCATIONS;
+  dfi->alt_flags |= flags;
+  /* If no filename was provided, use 'stderr'. */
+  if (!dfi->alt_filename)
+    dfi->alt_filename = xstrdup ("stderr");
+
+  /* Process -fopt-info-tree-all and -fopt-info-rtl-all, by enabling
+     all the known dumps.  */
+  if (dfi->suffix == NULL)
+    opt_info_enable_all (dfi->pflags, dfi->alt_flags, dfi->alt_filename);
+
+  return 1;
+}
+
+int
+opt_info_switch_p (const char *arg)
+{
+  size_t i;
+  int any = 0;
+
+  for (i = TDI_none + 1; i != TDI_end; i++)
+    any |= opt_info_switch_p_1 (arg, &dump_files[i]);
+
+  for (i = 0; i < extra_dump_files_in_use; i++)
+    any |= opt_info_switch_p_1 (arg, &extra_dump_files[i]);
+
+  return any;
+}
+
 /* Dump FUNCTION_DECL FN as tree dump PHASE.  */

 void
@@ -1123,5 +1619,71 @@ dump_function (int phase, tree fn)
 bool
 enable_rtl_dump_file (void)
 {
-  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
+  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
 }
+
+/* Return true if any dumps are enabled for the given MSG_TYPE, false
+   otherwise.  */
+
+bool
+dump_kind_p (int msg_type)
+{
+  if (!current_function_decl)
+    return 0;
+  return ((msg_type & pflags) || (msg_type & alt_flags));
+}
+
+/* Print basic block on the dump streams.  */
+
+void
+dump_basic_block (int dump_kind, basic_block bb, int indent)
+{
+  if (dump_file && (dump_kind & pflags))
+    dump_bb (dump_file, bb, indent, TDF_DETAILS);
+  if (alt_dump_file && (dump_kind & alt_flags))
+    dump_bb (alt_dump_file, bb, indent, TDF_DETAILS);
+}
+
+void
+dump_combine_total_stats (void)
+{
+  if (dump_file)
+    print_combine_total_stats (dump_file);
+  if (alt_dump_file && (alt_flags & MSG_NOTE))
+    print_combine_total_stats (alt_dump_file);
+}
+
+/* Handle -ftree-vectorizer-verbose ARG by remapping it to -fopt-info.
+   It remaps the old verbosity values as following:
+
+   REPORT_NONE ==> No dump is output
+   REPORT_VECTORIZED_LOCATIONS ==> "-optimized"
+   REPORT_UNVECTORIZED_LOCATIONS ==> "-missed"
+
+   Any higher verbosity levels result get mapped to "-details" flags.
+  */
+
+void
+dump_remap_tree_vectorizer_verbose (const char *arg)
+{
+  int value = atoi (arg);
+  const char *remapped_opt_info = NULL;
+
+  switch (value)
+    {
+    case 0:
+      break;
+    case 1:
+      remapped_opt_info = "tree-vect-optimized";
+      break;
+    case 2:
+      remapped_opt_info = "tree-vect-missed";
+      break;
+    default:
+      remapped_opt_info = "tree-vect-details";
+      break;
+    }
+
+  if (remapped_opt_info)
+    opt_info_switch_p (remapped_opt_info);
+}
Index: tree-dump.h
===================================================================
--- tree-dump.h	(revision 191208)
+++ tree-dump.h	(working copy)
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_TREE_DUMP_H
 #define GCC_TREE_DUMP_H

+#include "input.h"
 #include "splay-tree.h"
 #include "dumpfile.h"

Index: c-family/c-ada-spec.c
===================================================================
--- c-family/c-ada-spec.c	(revision 191208)
+++ c-family/c-ada-spec.c	(working copy)
@@ -2524,7 +2524,7 @@ print_ada_declaration (pretty_printer *buffer, tre
   int is_class = false;
   tree name = TYPE_NAME (TREE_TYPE (t));
   tree decl_name = DECL_NAME (t);
-  bool dump_internal = get_dump_file_info (TDI_ada)->flags & TDF_RAW;
+  bool dump_internal = get_dump_file_info (TDI_ada)->pflags & TDF_RAW;
   tree orig = NULL_TREE;

   if (cpp_check && cpp_check (t, IS_TEMPLATE))
Index: c/c-decl.c
===================================================================
--- c/c-decl.c	(revision 191208)
+++ c/c-decl.c	(working copy)
@@ -10082,7 +10082,7 @@ c_write_global_declarations (void)
   if (dump_enabled_p (TDI_ada))
     {
       /* Build a table of files to generate specs for */
-      if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
+      if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM)
 	collect_source_ref (main_input_filename);
       else
 	for_each_global_decl (collect_source_ref_cb);
Index: dumpfile.h
===================================================================
--- dumpfile.h	(revision 191208)
+++ dumpfile.h	(working copy)
@@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_DUMPFILE_H
 #define GCC_DUMPFILE_H 1

+#include "coretypes.h"
+#include "input.h"
+
 /* Different tree dump places.  When you add new tree dump places,
    extend the DUMP_FILES array in tree-dump.c.  */
 enum tree_dump_index
@@ -43,9 +46,11 @@ enum tree_dump_index
   TDI_end
 };

-/* Bit masks to control dumping. Not all values are applicable to
-   all dumps. Add new ones at the end. When you define new
-   values, extend the DUMP_OPTIONS array in tree-dump.c */
+/* Bit masks to control dumping. Not all values are applicable to all
+   dumps. Add new ones at the end. When you define new values, extend
+   the DUMP_OPTIONS array in tree-dump.c. These TDF_* flags coexist
+   with MSG_* flags and the bit values must be chosen to allow that.
+*/
 #define TDF_ADDRESS	(1 << 0)	/* dump node addresses */
 #define TDF_SLIM	(1 << 1)	/* don't go wild following links */
 #define TDF_RAW  	(1 << 2)	/* don't unparse the function */
@@ -83,6 +88,16 @@ enum tree_dump_index
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
 #define TDF_COMMENT	(1 << 25)	/* Dump lines with prefix ";;"  */

+/* Different types of dump classifications. These are extension of
+   TDF_* flags and the bit values should be chosen accordingly. */
+enum dump_msg_kind {
+  /* During the transition to MSG_* dump system, the TDF_* flags and
+     MSG_* flags may coexist in a single word. Hence the MSG_* flag
+     bits start after the TDF_* bits. */
+  MSG_OPTIMIZED_LOCATIONS = 1 << 26,
+  MSG_MISSED_OPTIMIZATION = 1 << 27,
+  MSG_NOTE = 1 << 28
+};

 /* In tree-dump.c */

@@ -91,9 +106,23 @@ extern int dump_enabled_p (int);
 extern int dump_initialized_p (int);
 extern FILE *dump_begin (int, int *);
 extern void dump_end (int, FILE *);
+extern int dump_start (int, int *);
+extern void dump_finish (int);
 extern void dump_node (const_tree, int, FILE *);
 extern int dump_switch_p (const char *);
+extern int opt_info_switch_p (const char *);
 extern const char *dump_flag_name (int);
+extern bool dump_kind_p (int);
+extern void dump_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
+extern void dump_printf_loc (int, source_location,
+                             const char *, ...) ATTRIBUTE_PRINTF_3;
+extern void dump_basic_block (int, basic_block, int);
+extern void dump_generic_expr_loc (int, source_location, int, tree);
+extern void dump_generic_expr (int, int, tree);
+extern void dump_gimple_stmt_loc (int, source_location, int, gimple, int);
+extern void dump_gimple_stmt (int, int, gimple, int);
+extern void dump_combine_total_stats (void);
+extern void dump_remap_tree_vectorizer_verbose (const char *);

 /* Global variables used to communicate with passes.  */
 extern FILE *dump_file;
@@ -109,8 +138,14 @@ struct dump_file_info
   const char *suffix;           /* suffix to give output file.  */
   const char *swtch;            /* command line switch */
   const char *glob;             /* command line glob  */
-  int flags;                    /* user flags */
-  int state;                    /* state of play */
+  const char *pfilename;        /* filename for the pass-specific stream  */
+  const char *alt_filename;     /* filename for the opt-info stream  */
+  FILE *pstream;                /* pass-specific dump stream  */
+  FILE *alt_stream;             /* opt-info stream */
+  int pflags;                   /* dump flags */
+  int alt_flags;                /* flags for opt-info */
+  int pstate;                   /* state of pass-specific stream */
+  int alt_state;                /* state of the opt-info stream */
   int num;                      /* dump file number */
 };

Index: tree-vect-loop-manip.c
===================================================================
--- tree-vect-loop-manip.c	(revision 191208)
+++ tree-vect-loop-manip.c	(working copy)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -791,14 +792,12 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
   free_stmt_vec_info (orig_cond);

   loop_loc = find_loop_location (loop);
-  if (dump_file && (dump_flags & TDF_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      if (loop_loc != UNKNOWN_LOC)
-        fprintf (dump_file, "\nloop at %s:%d: ",
-                 LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
+      dump_printf (MSG_NOTE, "\nloop at %s:%d: ", LOC_FILE (loop_loc),
+                   LOC_LINE (loop_loc));
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0);
     }
-
   loop->nb_iterations = niters;
 }

@@ -1220,13 +1219,8 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
   if (!(new_loop = slpeel_tree_duplicate_loop_to_edge_cfg (loop, e)))
     {
       loop_loc = find_loop_location (loop);
-      if (dump_file && (dump_flags & TDF_DETAILS))
-        {
-          if (loop_loc != UNKNOWN_LOC)
-            fprintf (dump_file, "\n%s:%d: note: ",
-                     LOC_FILE (loop_loc), LOC_LINE (loop_loc));
-          fprintf (dump_file, "tree_duplicate_loop_to_edge_cfg failed.\n");
-        }
+      dump_printf_loc (MSG_MISSED_OPTIMIZATION, loop_loc,
+                       "tree_duplicate_loop_to_edge_cfg failed.\n");
       return NULL;
     }

@@ -1642,19 +1636,18 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)

   /* Analyze phi functions of the loop header.  */

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_can_advance_ivs_p:");
-
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "vect_can_advance_ivs_p:");
   for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
       tree access_fn = NULL;
       tree evolution_part;

       phi = gsi_stmt (gsi);
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
 	{
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
+          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	}

       /* Skip virtual phi's. The data dependences that are associated with
@@ -1662,8 +1655,9 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)

       if (virtual_operand_p (PHI_RESULT (phi)))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "virtual phi. skip.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "virtual phi. skip.");
 	  continue;
 	}

@@ -1671,8 +1665,9 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)

       if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc phi. skip.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "reduc phi. skip.");
           continue;
         }

@@ -1683,23 +1678,25 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)

       if (!access_fn)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "No Access function.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "No Access function.");
 	  return false;
 	}

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-	  fprintf (vect_dump, "Access function of PHI: ");
-	  print_generic_expr (vect_dump, access_fn, TDF_SLIM);
+	  dump_printf_loc (MSG_NOTE, vect_location,
+                           "Access function of PHI: ");
+	  dump_generic_expr (MSG_NOTE, TDF_SLIM, access_fn);
         }

       evolution_part = evolution_part_in_loop_num (access_fn, loop->num);

       if (evolution_part == NULL_TREE)
         {
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "No evolution.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf (MSG_MISSED_OPTIMIZATION, "No evolution.");
 	  return false;
         }

@@ -1783,17 +1780,19 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo

       phi = gsi_stmt (gsi);
       phi1 = gsi_stmt (gsi1);
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "vect_update_ivs_after_vectorizer: phi: ");
-	  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_update_ivs_after_vectorizer: phi: ");
+	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
         }

       /* Skip virtual phi's.  */
       if (virtual_operand_p (PHI_RESULT (phi)))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "virtual phi. skip.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "virtual phi. skip.");
 	  continue;
 	}

@@ -1801,8 +1800,9 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
       stmt_info = vinfo_for_stmt (phi);
       if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc phi. skip.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "reduc phi. skip.");
           continue;
         }

@@ -1863,8 +1863,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
   tree cond_expr = NULL_TREE;
   gimple_seq cond_expr_stmt_list = NULL;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "=== vect_do_peeling_for_loop_bound ===");

   initialize_original_copy_tables ();

@@ -1909,9 +1910,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
   if (check_profitability)
     max_iter = MAX (max_iter, (int) th);
   record_niter_bound (new_loop, double_int::from_shwi (max_iter), false, true);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "Setting upper bound of nb iterations for epilogue "
-	     "loop to %d\n", max_iter);
+  dump_printf (MSG_OPTIMIZED_LOCATIONS,
+               "Setting upper bound of nb iterations for epilogue "
+               "loop to %d\n", max_iter);

   /* After peeling we have to reset scalar evolution analyzer.  */
   scev_reset ();
@@ -1973,8 +1974,8 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
     {
       int npeel = LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo);

-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "known peeling = %d.", npeel);
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+        dump_printf (MSG_OPTIMIZED_LOCATIONS, "known peeling = %d.", npeel);

       iters = build_int_cst (niters_type, npeel);
     }
@@ -2024,10 +2025,11 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
   if (TREE_CODE (loop_niters) != INTEGER_CST)
     iters = fold_build2 (MIN_EXPR, niters_type, iters, loop_niters);

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
     {
-      fprintf (vect_dump, "niters for prolog loop: ");
-      print_generic_expr (vect_dump, iters, TDF_SLIM);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                       "niters for prolog loop: ");
+      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
     }

   var = create_tmp_var (niters_type, "prolog_loop_niters");
@@ -2080,10 +2082,11 @@ vect_update_inits_of_drs (loop_vec_info loop_vinfo
   unsigned int i;
   VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
   struct data_reference *dr;
+
+ if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "=== vect_update_inits_of_dr ===");

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_update_inits_of_dr ===");
-
   FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr)
     vect_update_init_of_dr (dr, niters);
 }
@@ -2108,8 +2111,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
   struct loop *new_loop;
   int max_iter;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_do_peeling_for_alignment ===");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "=== vect_do_peeling_for_alignment ===");

   initialize_original_copy_tables ();

@@ -2131,9 +2135,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
   if (check_profitability)
     max_iter = MAX (max_iter, (int) th);
   record_niter_bound (new_loop, double_int::from_shwi (max_iter), false, true);
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    fprintf (dump_file, "Setting upper bound of nb iterations for prologue "
-	     "loop to %d\n", max_iter);
+  dump_printf (MSG_OPTIMIZED_LOCATIONS,
+               "Setting upper bound of nb iterations for prologue "
+               "loop to %d\n", max_iter);

   /* Update number of times loop executes.  */
   n_iters = LOOP_VINFO_NITERS (loop_vinfo);
@@ -2416,13 +2420,13 @@ vect_create_cond_for_alias_checks (loop_vec_info l
       segment_length_a = vect_vfa_segment_size (dr_a, length_factor);
       segment_length_b = vect_vfa_segment_size (dr_b, length_factor);

-      if (vect_print_dump_info (REPORT_DR_DETAILS))
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
 	{
-	  fprintf (vect_dump,
-		   "create runtime check for data references ");
-	  print_generic_expr (vect_dump, DR_REF (dr_a), TDF_SLIM);
-	  fprintf (vect_dump, " and ");
-	  print_generic_expr (vect_dump, DR_REF (dr_b), TDF_SLIM);
+	  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                           "create runtime check for data references ");
+	  dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, DR_REF (dr_a));
+	  dump_printf (MSG_OPTIMIZED_LOCATIONS, " and ");
+	  dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, DR_REF (dr_b));
 	}

       seg_a_min = addr_base_a;
@@ -2447,9 +2451,10 @@ vect_create_cond_for_alias_checks (loop_vec_info l
 	*cond_expr = part_cond_expr;
     }

-  if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "created %u versioning for alias checks.\n",
-             VEC_length (ddr_p, may_alias_ddrs));
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+		     "created %u versioning for alias checks.\n",
+		     VEC_length (ddr_p, may_alias_ddrs));
 }


Index: cp/decl2.c
===================================================================
--- cp/decl2.c	(revision 191208)
+++ cp/decl2.c	(working copy)
@@ -3695,7 +3695,7 @@ cp_write_global_declarations (void)
   /* Handle -fdump-ada-spec[-slim] */
   if (dump_enabled_p (TDI_ada))
     {
-      if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
+      if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM)
 	collect_source_ref (main_input_filename);
       else
 	collect_source_refs (global_namespace);
Index: opts.c
===================================================================
--- opts.c	(revision 191208)
+++ opts.c	(working copy)
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "intl.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "opts.h"
 #include "options.h"
 #include "tm.h" /* For STACK_CHECK_BUILTIN,
@@ -139,19 +140,6 @@ set_struct_debug_option (struct gcc_options *opts,
     }
 }

-/* Handle -ftree-vectorizer-verbose=VAL for options OPTS.  */
-
-static void
-vect_set_verbosity_level (struct gcc_options *opts, int val)
-{
-   if (val < MAX_VERBOSITY_LEVEL)
-     opts->x_user_vect_verbosity_level = (enum vect_verbosity_levels) val;
-   else
-     opts->x_user_vect_verbosity_level
-      = (enum vect_verbosity_levels) (MAX_VERBOSITY_LEVEL - 1);
-}
-
-
 /* Strip off a legitimate source ending from the input string NAME of
    length LEN.  Rather than having to know the names used by all of
    our front ends, we strip off an ending of a period followed by
@@ -1671,8 +1659,14 @@ common_handle_option (struct gcc_options *opts,
       opts->x_flag_stack_usage_info = value != 0;
       break;

+    case OPT_fopt_info_:
+      /* Deferred.  */
+      break;
+
     case OPT_ftree_vectorizer_verbose_:
-      vect_set_verbosity_level (opts, value);
+      /* -ftree-vectorizer-verbose is deprecated. It is defined in
+         -terms of fopt-info=N. */
+      /* Deferred.  */
       break;

     case OPT_g:
Index: tree-parloops.c
===================================================================
--- tree-parloops.c	(revision 191208)
+++ tree-parloops.c	(working copy)
@@ -1943,7 +1943,6 @@ gather_scalar_reductions (loop_p loop, htab_t redu
   gimple_stmt_iterator gsi;
   loop_vec_info simple_loop_info;

-  vect_dump = NULL;
   simple_loop_info = vect_analyze_loop_form (loop);

   for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c	(revision 191208)
+++ gimple-pretty-print.c	(working copy)
@@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
 }


-/* Emit a newline and SPC indentantion spaces to BUFFER.  */
+/* Emit a newline and SPC indentation spaces to BUFFER.  */

 static void
 newline_and_indent (pretty_printer *buffer, int spc)
@@ -89,20 +89,20 @@ debug_gimple_stmt (gimple gs)
 }


-/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  */
+/* 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)
 {
   maybe_init_pretty_print (file);
-  dump_gimple_stmt (&buffer, g, spc, flags);
+  pp_gimple_stmt_1 (&buffer, g, spc, flags);
   pp_newline_and_flush (&buffer);
 }


-/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  Print only the right-hand side
+/* Print GIMPLE statement G to FILE using SPC indentation spaces and
+   FLAGS as in pp_gimple_stmt_1.  Print only the right-hand side
    of the statement.  */

 void
@@ -110,12 +110,12 @@ print_gimple_expr (FILE *file, gimple g, int spc,
 {
   flags |= TDF_RHS_ONLY;
   maybe_init_pretty_print (file);
-  dump_gimple_stmt (&buffer, g, spc, flags);
+  pp_gimple_stmt_1 (&buffer, g, spc, flags);
 }


-/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
-   spaces and FLAGS as in dump_gimple_stmt.
+/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
+   spaces and FLAGS as in pp_gimple_stmt_1.
    The caller is responsible for calling pp_flush on BUFFER to finalize
    the pretty printer.  */

@@ -128,15 +128,15 @@ dump_gimple_seq (pretty_printer *buffer, gimple_se
     {
       gimple gs = gsi_stmt (i);
       INDENT (spc);
-      dump_gimple_stmt (buffer, gs, spc, flags);
+      pp_gimple_stmt_1 (buffer, gs, spc, flags);
       if (!gsi_one_before_end_p (i))
 	pp_newline (buffer);
     }
 }


-/* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
-   FLAGS as in dump_gimple_stmt.  */
+/* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
+   FLAGS as in pp_gimple_stmt_1.  */

 void
 print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
@@ -245,7 +245,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc,


 /* Helper for dump_gimple_assign.  Print the unary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */

 static void
 dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -329,7 +329,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs,


 /* Helper for dump_gimple_assign.  Print the binary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */

 static void
 dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -385,7 +385,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs
 }

 /* Helper for dump_gimple_assign.  Print the ternary RHS of the
-   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
+   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */

 static void
 dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -470,7 +470,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple g


 /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   pp_gimple_stmt_1.  */

 static void
 dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -529,7 +529,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple


 /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   pp_gimple_stmt_1.  */

 static void
 dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -616,7 +616,7 @@ pp_points_to_solution (pretty_printer *buffer, str
 }

 /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   pp_gimple_stmt_1.  */

 static void
 dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -749,7 +749,7 @@ dump_gimple_call (pretty_printer *buffer, gimple g


 /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   pp_gimple_stmt_1.  */

 static void
 dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -782,7 +782,7 @@ dump_gimple_switch (pretty_printer *buffer, gimple


 /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
-   dump_gimple_stmt.  */
+   pp_gimple_stmt_1.  */

 static void
 dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -1573,7 +1573,7 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs
 }


-/* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.
+/* 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.  */

@@ -1807,7 +1807,7 @@ dump_gimple_omp_atomic_store (pretty_printer *buff


 /* Dump all the memory operands for statement GS.  BUFFER, SPC and
-   FLAGS are as in dump_gimple_stmt.  */
+   FLAGS are as in pp_gimple_stmt_1.  */

 static void
 dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
@@ -1838,13 +1838,13 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimpl
 }


-/* Dump the gimple statement GS on the pretty printer BUFFER, SPC
+/* Print the gimple statement GS on the pretty printer BUFFER, SPC
    spaces of indent.  FLAGS specifies details to show in the dump (see
    TDF_* in dumpfile.h).  The caller is responsible for calling
    pp_flush on BUFFER to finalize the pretty printer.  */

 void
-dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
+pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
 {
   if (!gs)
     return;
@@ -2253,7 +2253,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic
       curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;

       INDENT (curr_indent);
-      dump_gimple_stmt (buffer, stmt, curr_indent, flags);
+      pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
       pp_newline_and_flush (buffer);
       gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
       dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
Index: gimple-pretty-print.h
===================================================================
--- gimple-pretty-print.h	(revision 191208)
+++ gimple-pretty-print.h	(working copy)
@@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
 extern void print_gimple_stmt (FILE *, gimple, int, int);
 extern void print_gimple_expr (FILE *, gimple, int, int);
-extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
+extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);

 #endif /* ! GCC_GIMPLE_PRETTY_PRINT_H */
Index: tree-vectorizer.c
===================================================================
--- tree-vectorizer.c	(revision 191208)
+++ tree-vectorizer.c	(working copy)
@@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -67,13 +68,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-vectorizer.h"
 #include "tree-pass.h"

-/* vect_dump will be set to stderr or dump_file if exist.  */
-FILE *vect_dump;
-
-/* vect_verbosity_level set to an invalid value
-   to mark that it's uninitialized.  */
-static enum vect_verbosity_levels vect_verbosity_level = MAX_VERBOSITY_LEVEL;
-
 /* Loop or bb location.  */
 LOC vect_location;

@@ -81,82 +75,6 @@ LOC vect_location;
 VEC(vec_void_p,heap) *stmt_vec_info_vec;

 \f
-
-/* Function vect_set_dump_settings.
-
-   Fix the verbosity level of the vectorizer if the
-   requested level was not set explicitly using the flag
-   -ftree-vectorizer-verbose=N.
-   Decide where to print the debugging information (dump_file/stderr).
-   If the user defined the verbosity level, but there is no dump file,
-   print to stderr, otherwise print to the dump file.  */
-
-static void
-vect_set_dump_settings (bool slp)
-{
-  vect_dump = dump_file;
-
-  /* Check if the verbosity level was defined by the user:  */
-  if (user_vect_verbosity_level != MAX_VERBOSITY_LEVEL)
-    {
-      vect_verbosity_level = user_vect_verbosity_level;
-      /* Ignore user defined verbosity if dump flags require higher level of
-         verbosity.  */
-      if (dump_file)
-        {
-          if (((dump_flags & TDF_DETAILS)
-                && vect_verbosity_level >= REPORT_DETAILS)
-  	       || ((dump_flags & TDF_STATS)
-	            && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
-            return;
-        }
-      else
-        {
-          /* If there is no dump file, print to stderr in case of loop
-             vectorization.  */
-          if (!slp)
-            vect_dump = stderr;
-
-          return;
-        }
-    }
-
-  /* User didn't specify verbosity level:  */
-  if (dump_file && (dump_flags & TDF_DETAILS))
-    vect_verbosity_level = REPORT_DETAILS;
-  else if (dump_file && (dump_flags & TDF_STATS))
-    vect_verbosity_level = REPORT_UNVECTORIZED_LOCATIONS;
-  else
-    vect_verbosity_level = REPORT_NONE;
-
-  gcc_assert (dump_file || vect_verbosity_level == REPORT_NONE);
-}
-
-
-/* Function debug_loop_details.
-
-   For vectorization debug dumps.  */
-
-bool
-vect_print_dump_info (enum vect_verbosity_levels vl)
-{
-  if (vl > vect_verbosity_level)
-    return false;
-
-  if (!current_function_decl || !vect_dump)
-    return false;
-
-  if (vect_location == UNKNOWN_LOC)
-    fprintf (vect_dump, "\n%s:%d: note: ",
-	     DECL_SOURCE_FILE (current_function_decl),
-	     DECL_SOURCE_LINE (current_function_decl));
-  else
-    fprintf (vect_dump, "\n%d: ", LOC_LINE (vect_location));
-
-  return true;
-}
-
-
 /* Function vectorize_loops.
    Entry point to loop vectorization phase.  */
@@ -176,9 +94,6 @@ vectorize_loops (void)
   if (vect_loops_num <= 1)
     return 0;

-  /* Fix the verbosity level if not defined explicitly by the user.  */
-  vect_set_dump_settings (false);
-
   init_stmt_vec_info_vec ();

   /*  ----------- Analyze loops. -----------  */
@@ -192,10 +107,9 @@ vectorize_loops (void)
 	loop_vec_info loop_vinfo;

 	vect_location = find_loop_location (loop);
-        if (vect_location != UNKNOWN_LOC
-            && vect_verbosity_level > REPORT_NONE)
-	  fprintf (vect_dump, "\nAnalyzing loop at %s:%d\n",
-            LOC_FILE (vect_location), LOC_LINE (vect_location));
+        if (vect_location != UNKNOWN_LOC && dump_kind_p (MSG_NOTE))
+	  dump_printf (MSG_NOTE, "\nAnalyzing loop at %s:%d\n",
+                       LOC_FILE (vect_location), LOC_LINE (vect_location));

 	loop_vinfo = vect_analyze_loop (loop);
 	loop->aux = loop_vinfo;
@@ -203,11 +117,9 @@ vectorize_loops (void)
 	if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
 	  continue;

-        if (vect_location != UNKNOWN_LOC
-            && vect_verbosity_level > REPORT_NONE)
-          fprintf (vect_dump, "\n\nVectorizing loop at %s:%d\n",
-            LOC_FILE (vect_location), LOC_LINE (vect_location));
-
+        if (vect_location != UNKNOWN_LOC && dump_kind_p (MSG_NOTE))
+          dump_printf (MSG_NOTE, "\n\nVectorizing loop at %s:%d\n",
+                       LOC_FILE (vect_location), LOC_LINE (vect_location));
 	vect_transform_loop (loop_vinfo);
 	num_vectorized_loops++;
       }
@@ -215,11 +127,11 @@ vectorize_loops (void)
   vect_location = UNKNOWN_LOC;

   statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
-  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)
-      || (num_vectorized_loops > 0
-	  && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)))
-    fprintf (vect_dump, "vectorized %u loops in function.\n",
-	     num_vectorized_loops);
+  if (dump_kind_p (MSG_MISSED_OPTIMIZATION)
+      || (num_vectorized_loops > 0 && dump_kind_p (MSG_OPTIMIZED_LOCATIONS)))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION,
+                     vect_location, "vectorized %u loops in function.\n",
+                     num_vectorized_loops);

   /*  ----------- Finalize. -----------  */

@@ -248,9 +160,6 @@ execute_vect_slp (void)
 {
   basic_block bb;

-  /* Fix the verbosity level if not defined explicitly by the user.  */
-  vect_set_dump_settings (true);
-
   init_stmt_vec_info_vec ();

   FOR_EACH_BB (bb)
@@ -260,9 +169,9 @@ execute_vect_slp (void)
       if (vect_slp_analyze_bb (bb))
         {
           vect_slp_transform_bb (bb);
-
-          if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-            fprintf (vect_dump, "basic block vectorized using SLP\n");
+          if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+            dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+			     "basic block vectorized using SLP\n");
         }
     }

@@ -335,12 +244,9 @@ increase_alignment (void)
         {
           DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
           DECL_USER_ALIGN (decl) = 1;
-          if (dump_file)
-            {
-              fprintf (dump_file, "Increasing alignment of decl: ");
-              print_generic_expr (dump_file, decl, TDF_SLIM);
-	      fprintf (dump_file, "\n");
-            }
+          dump_printf (MSG_NOTE, "Increasing alignment of decl: ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, decl);
+          dump_printf (MSG_NOTE, "\n");
         }
     }
   return 0;
Index: tree-vectorizer.h
===================================================================
--- tree-vectorizer.h	(revision 191208)
+++ tree-vectorizer.h	(working copy)
@@ -848,9 +848,8 @@ known_alignment_for_access_p (struct data_referenc
   return (DR_MISALIGNMENT (data_ref_info) != -1);
 }

-/* vect_dump will be set to stderr or dump_file if exist.  */
-extern FILE *vect_dump;
-extern LOC vect_loop_location;
+/* Source location */
+extern LOC vect_location;

 /*-----------------------------------------------------------------*/
 /* Function prototypes.                                            */
@@ -1012,7 +1011,5 @@ void vect_pattern_recog (loop_vec_info, bb_vec_inf

 /* In tree-vectorizer.c.  */
 unsigned vectorize_loops (void);
-/* Vectorization debug information */
-extern bool vect_print_dump_info (enum vect_verbosity_levels);

 #endif  /* GCC_TREE_VECTORIZER_H  */
Index: profile.c
===================================================================
--- profile.c	(revision 191208)
+++ profile.c	(working copy)
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "rtl.h"
 #include "flags.h"
@@ -133,8 +134,8 @@ instrument_edges (struct edge_list *el)
 	  if (!inf->ignore && !inf->on_tree)
 	    {
 	      gcc_assert (!(e->flags & EDGE_ABNORMAL));
-	      if (dump_file)
-		fprintf (dump_file, "Edge %d to %d instrumented%s\n",
+	      if (dump_kind_p (MSG_NOTE))
+		dump_printf (MSG_NOTE, "Edge %d to %d instrumented%s\n",
 			 e->src->index, e->dest->index,
 			 EDGE_CRITICAL_P (e) ? " (and split)" : "");
 	      gimple_gen_edge_profiler (num_instr_edges++, e);
@@ -143,8 +144,8 @@ instrument_edges (struct edge_list *el)
     }

   total_num_blocks_created += num_edges;
-  if (dump_file)
-    fprintf (dump_file, "%d edges instrumented\n", num_instr_edges);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "%d edges instrumented\n", num_instr_edges);
   return num_instr_edges;
 }

@@ -397,13 +398,13 @@ is_edge_inconsistent (VEC(edge,gc) *edges)
 	      && (!(e->flags & EDGE_FAKE)
 	          || !block_ends_with_call_p (e->src)))
 	    {
-	      if (dump_file)
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (dump_file,
+		  dump_printf (MSG_NOTE,
 		  	   "Edge %i->%i is inconsistent, count"HOST_WIDEST_INT_PRINT_DEC,
 			   e->src->index, e->dest->index, e->count);
-		  dump_bb (dump_file, e->src, 0, TDF_DETAILS);
-		  dump_bb (dump_file, e->dest, 0, TDF_DETAILS);
+		  dump_basic_block (MSG_NOTE, e->src, 0);
+                  dump_basic_block (MSG_NOTE, e->dest, 0);
 		}
               return true;
 	    }
@@ -446,40 +447,40 @@ is_inconsistent (void)
 	return true;
       if (bb->count < 0)
         {
-	  if (dump_file)
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (dump_file, "BB %i count is negative "
+	      dump_printf (MSG_NOTE, "BB %i count is negative "
 		       HOST_WIDEST_INT_PRINT_DEC,
 		       bb->index,
 		       bb->count);
-	      dump_bb (dump_file, bb, 0, TDF_DETAILS);
+	      dump_basic_block (MSG_NOTE, bb, 0);
 	    }
 	  inconsistent = true;
 	}
       if (bb->count != sum_edge_counts (bb->preds))
         {
-	  if (dump_file)
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (dump_file, "BB %i count does not match sum of incoming edges "
+	      dump_printf (MSG_NOTE, "BB %i count does not match sum of
incoming edges "
 		       HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
 		       bb->index,
 		       bb->count,
 		       sum_edge_counts (bb->preds));
-	      dump_bb (dump_file, bb, 0, TDF_DETAILS);
+	      dump_basic_block (MSG_NOTE, bb, 0);
 	    }
 	  inconsistent = true;
 	}
       if (bb->count != sum_edge_counts (bb->succs) &&
           ! (find_edge (bb, EXIT_BLOCK_PTR) != NULL &&
block_ends_with_call_p (bb)))
 	{
-	  if (dump_file)
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (dump_file, "BB %i count does not match sum of outgoing edges "
+	      dump_printf (MSG_NOTE, "BB %i count does not match sum of
outgoing edges "
 		       HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
 		       bb->index,
 		       bb->count,
 		       sum_edge_counts (bb->succs));
-	      dump_bb (dump_file, bb, 0, TDF_DETAILS);
+	      dump_basic_block (MSG_NOTE, bb, 0);
 	    }
 	  inconsistent = true;
 	}
@@ -547,11 +548,11 @@ read_profile_edge_counts (gcov_type *exec_counts)
 	    EDGE_INFO (e)->count_valid = 1;
 	    BB_INFO (bb)->succ_count--;
 	    BB_INFO (e->dest)->pred_count--;
-	    if (dump_file)
+	    if (dump_kind_p (MSG_NOTE))
 	      {
-		fprintf (dump_file, "\nRead edge from %i to %i, count:",
+		dump_printf (MSG_NOTE, "\nRead edge from %i to %i, count:",
 			 bb->index, e->dest->index);
-		fprintf (dump_file, HOST_WIDEST_INT_PRINT_DEC,
+		dump_printf (MSG_NOTE, HOST_WIDEST_INT_PRINT_DEC,
 			 (HOST_WIDEST_INT) e->count);
 	      }
 	  }
@@ -647,8 +648,8 @@ compute_branch_probabilities (unsigned cfg_checksu

   num_edges = read_profile_edge_counts (exec_counts);

-  if (dump_file)
-    fprintf (dump_file, "\n%d edge counts read\n", num_edges);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "\n%d edge counts read\n", num_edges);

   /* For every block in the file,
      - if every exit/entrance edge has a known count, then set the block count
@@ -762,18 +763,18 @@ compute_branch_probabilities (unsigned cfg_checksu
 	    }
 	}
     }
-  if (dump_file)
+  if (dump_kind_p (MSG_NOTE))
     {
       int overlap = compute_frequency_overlap ();
       gimple_dump_cfg (dump_file, dump_flags);
-      fprintf (dump_file, "Static profile overlap: %d.%d%%\n",
+      dump_printf (MSG_NOTE, "Static profile overlap: %d.%d%%\n",
 	       overlap / (OVERLAP_BASE / 100),
 	       overlap % (OVERLAP_BASE / 100));
     }

   total_num_passes += passes;
-  if (dump_file)
-    fprintf (dump_file, "Graph solving took %d passes.\n\n", passes);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "Graph solving took %d passes.\n\n", passes);

   /* If the graph has been correctly solved, every block will have a
      succ and pred count of zero.  */
@@ -799,8 +800,8 @@ compute_branch_probabilities (unsigned cfg_checksu
          correct_negative_edge_counts ();
          /* Set bb counts to the sum of the outgoing edge counts */
          set_bb_counts ();
-         if (dump_file)
-           fprintf (dump_file, "\nCalling mcf_smooth_cfg\n");
+         if (dump_kind_p (MSG_NOTE))
+           dump_printf (MSG_NOTE, "\nCalling mcf_smooth_cfg\n");
          mcf_smooth_cfg ();
        }
      else
@@ -912,12 +913,12 @@ compute_branch_probabilities (unsigned cfg_checksu
   profile_status = PROFILE_READ;
   compute_function_frequency ();

-  if (dump_file)
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (dump_file, "%d branches\n", num_branches);
+      dump_printf (MSG_NOTE, "%d branches\n", num_branches);
       if (num_branches)
 	for (i = 0; i < 10; i++)
-	  fprintf (dump_file, "%d%% branches in range %d-%d%%\n",
+	  dump_printf (MSG_NOTE, "%d%% branches in range %d-%d%%\n",
 		   (hist_br_prob[i] + hist_br_prob[19-i]) * 100 / num_branches,
 		   5 * i, 5 * i + 5);

@@ -1152,15 +1153,15 @@ branch_prob (void)

       if (need_exit_edge && !have_exit_edge)
 	{
-	  if (dump_file)
-	    fprintf (dump_file, "Adding fake exit edge to bb %i\n",
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf (MSG_NOTE, "Adding fake exit edge to bb %i\n",
 		     bb->index);
 	  make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
 	}
       if (need_entry_edge && !have_entry_edge)
 	{
-	  if (dump_file)
-	    fprintf (dump_file, "Adding fake entry edge to bb %i\n",
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf (MSG_NOTE, "Adding fake entry edge to bb %i\n",
 		     bb->index);
 	  make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
 	  /* Avoid bbs that have both fake entry edge and also some
@@ -1192,8 +1193,8 @@ branch_prob (void)
 		      && (DECL_FUNCTION_CODE (fndecl)
 			  != BUILT_IN_SETJMP_DISPATCHER)))
 		{
-		  if (dump_file)
-		    fprintf (dump_file, "Splitting bb %i after labels\n",
+		  if (dump_kind_p (MSG_NOTE))
+		    dump_printf (MSG_NOTE, "Splitting bb %i after labels\n",
 			     bb->index);
 		  split_block_after_labels (bb);
 		}
@@ -1248,20 +1249,20 @@ branch_prob (void)
     }

   total_num_blocks += n_basic_blocks;
-  if (dump_file)
-    fprintf (dump_file, "%d basic blocks\n", n_basic_blocks);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "%d basic blocks\n", n_basic_blocks);

   total_num_edges += num_edges;
-  if (dump_file)
-    fprintf (dump_file, "%d edges\n", num_edges);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "%d edges\n", num_edges);

   total_num_edges_ignored += ignored_edges;
-  if (dump_file)
-    fprintf (dump_file, "%d ignored edges\n", ignored_edges);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "%d ignored edges\n", ignored_edges);

   total_num_edges_instrumented += num_instrumented;
-  if (dump_file)
-    fprintf (dump_file, "%d instrumentation edges\n", num_instrumented);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "%d instrumentation edges\n", num_instrumented);

   /* Compute two different checksums. Note that we want to compute
      the checksum in only once place, since it depends on the shape
@@ -1467,8 +1468,8 @@ find_spanning_tree (struct edge_list *el)
 	  && !EDGE_INFO (e)->ignore
 	  && (find_group (e->src) != find_group (e->dest)))
 	{
-	  if (dump_file)
-	    fprintf (dump_file, "Abnormal edge %d to %d put to tree\n",
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf (MSG_NOTE, "Abnormal edge %d to %d put to tree\n",
 		     e->src->index, e->dest->index);
 	  EDGE_INFO (e)->on_tree = 1;
 	  union_groups (e->src, e->dest);
@@ -1482,8 +1483,8 @@ find_spanning_tree (struct edge_list *el)
       if (EDGE_CRITICAL_P (e) && !EDGE_INFO (e)->ignore
 	  && find_group (e->src) != find_group (e->dest))
 	{
-	  if (dump_file)
-	    fprintf (dump_file, "Critical edge %d to %d put to tree\n",
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf (MSG_NOTE, "Critical edge %d to %d put to tree\n",
 		     e->src->index, e->dest->index);
 	  EDGE_INFO (e)->on_tree = 1;
 	  union_groups (e->src, e->dest);
@@ -1497,8 +1498,8 @@ find_spanning_tree (struct edge_list *el)
       if (!EDGE_INFO (e)->ignore
 	  && find_group (e->src) != find_group (e->dest))
 	{
-	  if (dump_file)
-	    fprintf (dump_file, "Normal edge %d to %d put to tree\n",
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf (MSG_NOTE, "Normal edge %d to %d put to tree\n",
 		     e->src->index, e->dest->index);
 	  EDGE_INFO (e)->on_tree = 1;
 	  union_groups (e->src, e->dest);
@@ -1527,40 +1528,39 @@ init_branch_prob (void)
     total_hist_br_prob[i] = 0;
 }

-/* Performs file-level cleanup after branch-prob processing
-   is completed.  */
+/* Dump statistics after branch-prob processing is completed.  */

 void
 end_branch_prob (void)
 {
-  if (dump_file)
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (dump_file, "\n");
-      fprintf (dump_file, "Total number of blocks: %d\n",
-	       total_num_blocks);
-      fprintf (dump_file, "Total number of edges: %d\n", total_num_edges);
-      fprintf (dump_file, "Total number of ignored edges: %d\n",
-	       total_num_edges_ignored);
-      fprintf (dump_file, "Total number of instrumented edges: %d\n",
-	       total_num_edges_instrumented);
-      fprintf (dump_file, "Total number of blocks created: %d\n",
-	       total_num_blocks_created);
-      fprintf (dump_file, "Total number of graph solution passes: %d\n",
-	       total_num_passes);
+      dump_printf (MSG_NOTE, "\n");
+      dump_printf (MSG_NOTE, "Total number of blocks: %d\n",
+                   total_num_blocks);
+      dump_printf (MSG_NOTE, "Total number of edges: %d\n", total_num_edges);
+      dump_printf (MSG_NOTE, "Total number of ignored edges: %d\n",
+                   total_num_edges_ignored);
+      dump_printf (MSG_NOTE, "Total number of instrumented edges: %d\n",
+                   total_num_edges_instrumented);
+      dump_printf (MSG_NOTE, "Total number of blocks created: %d\n",
+                   total_num_blocks_created);
+      dump_printf (MSG_NOTE, "Total number of graph solution passes: %d\n",
+                   total_num_passes);
       if (total_num_times_called != 0)
-	fprintf (dump_file, "Average number of graph solution passes: %d\n",
-		 (total_num_passes + (total_num_times_called  >> 1))
-		 / total_num_times_called);
-      fprintf (dump_file, "Total number of branches: %d\n",
-	       total_num_branches);
+	dump_printf (MSG_NOTE, "Average number of graph solution passes: %d\n",
+                     (total_num_passes + (total_num_times_called  >> 1))
+                     / total_num_times_called);
+      dump_printf (MSG_NOTE, "Total number of branches: %d\n",
+                   total_num_branches);
       if (total_num_branches)
 	{
 	  int i;

 	  for (i = 0; i < 10; i++)
-	    fprintf (dump_file, "%d%% branches in range %d-%d%%\n",
-		     (total_hist_br_prob[i] + total_hist_br_prob[19-i]) * 100
-		     / total_num_branches, 5*i, 5*i+5);
+	    dump_printf (MSG_NOTE, "%d%% branches in range %d-%d%%\n",
+                         (total_hist_br_prob[i] + total_hist_br_prob[19-i])
+                         * 100 / total_num_branches, 5*i, 5*i+5);
 	}
     }
 }
Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 191208)
+++ tree-vect-loop.c	(working copy)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -184,8 +185,9 @@ vect_determine_vectorization_factor (loop_vec_info
   gimple_stmt_iterator pattern_def_si = gsi_none ();
   bool analyze_pattern_stmt = false;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_determine_vectorization_factor ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_determine_vectorization_factor ===");

   for (i = 0; i < nbbs; i++)
     {
@@ -195,10 +197,10 @@ vect_determine_vectorization_factor (loop_vec_info
 	{
 	  phi = gsi_stmt (si);
 	  stmt_info = vinfo_for_stmt (phi);
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "==> examining phi: ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location, "==> examining phi: ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	    }

 	  gcc_assert (stmt_info);
@@ -208,34 +210,37 @@ vect_determine_vectorization_factor (loop_vec_info
 	      gcc_assert (!STMT_VINFO_VECTYPE (stmt_info));
               scalar_type = TREE_TYPE (PHI_RESULT (phi));

-	      if (vect_print_dump_info (REPORT_DETAILS))
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (vect_dump, "get vectype for scalar type:  ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  dump_printf_loc (MSG_NOTE, vect_location,
+                                   "get vectype for scalar type:  ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
 		}

 	      vectype = get_vectype_for_scalar_type (scalar_type);
 	      if (!vectype)
 		{
-		  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+		  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		    {
-		      fprintf (vect_dump,
-		               "not vectorized: unsupported data-type ");
-		      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                       "not vectorized: unsupported "
+                                       "data-type ");
+		      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                         scalar_type);
 		    }
 		  return false;
 		}
 	      STMT_VINFO_VECTYPE (stmt_info) = vectype;

-	      if (vect_print_dump_info (REPORT_DETAILS))
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (vect_dump, "vectype: ");
-		  print_generic_expr (vect_dump, vectype, TDF_SLIM);
+		  dump_printf_loc (MSG_NOTE, vect_location, "vectype: ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
 		}

 	      nunits = TYPE_VECTOR_SUBPARTS (vectype);
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "nunits = %d", nunits);
+	      if (dump_kind_p (MSG_NOTE))
+		dump_printf_loc (MSG_NOTE, vect_location, "nunits = %d", nunits);

 	      if (!vectorization_factor
 		  || (nunits > vectorization_factor))
@@ -254,10 +259,11 @@ vect_determine_vectorization_factor (loop_vec_info

           stmt_info = vinfo_for_stmt (stmt);

-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "==> examining statement: ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "==> examining statement: ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	    }

 	  gcc_assert (stmt_info);
@@ -273,16 +279,17 @@ vect_determine_vectorization_factor (loop_vec_info
                 {
                   stmt = pattern_stmt;
                   stmt_info = vinfo_for_stmt (pattern_stmt);
-                  if (vect_print_dump_info (REPORT_DETAILS))
+                  if (dump_kind_p (MSG_NOTE))
                     {
-                      fprintf (vect_dump, "==> examining pattern statement: ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf_loc (MSG_NOTE, vect_location,
+                                       "==> examining pattern statement: ");
+                      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
                     }
                 }
               else
 	        {
-	          if (vect_print_dump_info (REPORT_DETAILS))
-	            fprintf (vect_dump, "skip.");
+	          if (dump_kind_p (MSG_NOTE))
+	            dump_printf_loc (MSG_NOTE, vect_location, "skip.");
                   gsi_next (&si);
 	          continue;
                 }
@@ -321,12 +328,12 @@ vect_determine_vectorization_factor (loop_vec_info

 		  if (!gsi_end_p (pattern_def_si))
 		    {
-		      if (vect_print_dump_info (REPORT_DETAILS))
+		      if (dump_kind_p (MSG_NOTE))
 			{
-			  fprintf (vect_dump,
-				   "==> examining pattern def stmt: ");
-			  print_gimple_stmt (vect_dump, pattern_def_stmt, 0,
-					     TDF_SLIM);
+			  dump_printf_loc (MSG_NOTE, vect_location,
+                                           "==> examining pattern def stmt: ");
+			  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
+                                            pattern_def_stmt, 0);
 			}

 		      stmt = pattern_def_stmt;
@@ -344,20 +351,23 @@ vect_determine_vectorization_factor (loop_vec_info

 	  if (gimple_get_lhs (stmt) == NULL_TREE)
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-	          fprintf (vect_dump, "not vectorized: irregular stmt.");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: irregular stmt.");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,  TDF_SLIM, stmt,
+                                    0);
 		}
 	      return false;
 	    }

 	  if (VECTOR_MODE_P (TYPE_MODE (gimple_expr_type (stmt))))
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	        {
-	          fprintf (vect_dump, "not vectorized: vector stmt in loop:");
-	          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: vector stmt in loop:");
+	          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 	        }
 	      return false;
 	    }
@@ -377,19 +387,22 @@ vect_determine_vectorization_factor (loop_vec_info
 	    {
 	      gcc_assert (!STMT_VINFO_DATA_REF (stmt_info));
 	      scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
-	      if (vect_print_dump_info (REPORT_DETAILS))
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (vect_dump, "get vectype for scalar type:  ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  dump_printf_loc (MSG_NOTE, vect_location,
+                                   "get vectype for scalar type:  ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
 		}
 	      vectype = get_vectype_for_scalar_type (scalar_type);
 	      if (!vectype)
 		{
-		  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+		  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		    {
-		      fprintf (vect_dump,
-			       "not vectorized: unsupported data-type ");
-		      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                       "not vectorized: unsupported "
+                                       "data-type ");
+		      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                         scalar_type);
 		    }
 		  return false;
 		}
@@ -402,19 +415,21 @@ vect_determine_vectorization_factor (loop_vec_info
 	     support one vector size per loop).  */
 	  scalar_type = vect_get_smallest_scalar_type (stmt, &dummy,
 						       &dummy);
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "get vectype for scalar type:  ");
-	      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "get vectype for scalar type:  ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
 	    }
 	  vf_vectype = get_vectype_for_scalar_type (scalar_type);
 	  if (!vf_vectype)
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: unsupported data-type ");
-		  print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: unsupported data-type ");
+		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                     scalar_type);
 		}
 	      return false;
 	    }
@@ -422,28 +437,29 @@ vect_determine_vectorization_factor (loop_vec_info
 	  if ((GET_MODE_SIZE (TYPE_MODE (vectype))
 	       != GET_MODE_SIZE (TYPE_MODE (vf_vectype))))
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: different sized vector "
-			   "types in statement, ");
-		  print_generic_expr (vect_dump, vectype, TDF_SLIM);
-		  fprintf (vect_dump, " and ");
-		  print_generic_expr (vect_dump, vf_vectype, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: different sized vector "
+                                   "types in statement, ");
+		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                     vectype);
+		  dump_printf (MSG_MISSED_OPTIMIZATION, " and ");
+		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                     vf_vectype);
 		}
 	      return false;
 	    }

-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "vectype: ");
-	      print_generic_expr (vect_dump, vf_vectype, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location, "vectype: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, vf_vectype);
 	    }

 	  nunits = TYPE_VECTOR_SUBPARTS (vf_vectype);
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "nunits = %d", nunits);
-
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf_loc (MSG_NOTE, vect_location, "nunits = %d", nunits);
 	  if (!vectorization_factor
 	      || (nunits > vectorization_factor))
 	    vectorization_factor = nunits;
@@ -457,12 +473,14 @@ vect_determine_vectorization_factor (loop_vec_info
     }

   /* TODO: Analyze cost. Decide if worth while to vectorize.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vectorization factor = %d", vectorization_factor);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "vectorization factor = %d",
+                     vectorization_factor);
   if (vectorization_factor <= 1)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported data-type");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not vectorized: unsupported data-type");
       return false;
     }
   LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
@@ -497,12 +515,12 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tre
   step_expr = evolution_part;
   init_expr = unshare_expr (initial_condition_in_loop_num (access_fn,
loop_nb));

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "step: ");
-      print_generic_expr (vect_dump, step_expr, TDF_SLIM);
-      fprintf (vect_dump, ",  init: ");
-      print_generic_expr (vect_dump, init_expr, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location, "step: ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, step_expr);
+      dump_printf (MSG_NOTE, ",  init: ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, init_expr);
     }

   *init = init_expr;
@@ -510,8 +528,9 @@ vect_is_simple_iv_evolution (unsigned loop_nb, tre

   if (TREE_CODE (step_expr) != INTEGER_CST)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "step unknown.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "step unknown.");
       return false;
     }

@@ -534,8 +553,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
   gimple_stmt_iterator gsi;
   bool double_reduc;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_scalar_cycles ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_analyze_scalar_cycles ===");

   /* First - identify all inductions.  Reduction detection assumes that all the
      inductions have been identified, therefore, this order must not be
@@ -547,10 +567,10 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
       tree def = PHI_RESULT (phi);
       stmt_vec_info stmt_vinfo = vinfo_for_stmt (phi);

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
 	{
-	  fprintf (vect_dump, "Analyze phi: ");
-	  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	  dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
+	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	}

       /* Skip virtual phi's.  The data dependences that are associated with
@@ -565,10 +585,11 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
       if (access_fn)
 	{
 	  STRIP_NOPS (access_fn);
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "Access function of PHI: ");
-	      print_generic_expr (vect_dump, access_fn, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "Access function of PHI: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, access_fn);
 	    }
 	  STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo)
 	    = evolution_part_in_loop_num (access_fn, loop->num);
@@ -583,8 +604,8 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v

       gcc_assert (STMT_VINFO_LOOP_PHI_EVOLUTION_PART (stmt_vinfo) !=
NULL_TREE);

-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Detected induction.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location, "Detected induction.");
       STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_induction_def;
     }

@@ -598,10 +619,10 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
       gimple reduc_stmt;
       bool nested_cycle;

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "Analyze phi: ");
-          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
+          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
         }

       gcc_assert (!virtual_operand_p (def)
@@ -614,8 +635,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
         {
           if (double_reduc)
             {
-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Detected double reduction.");
+              if (dump_kind_p (MSG_NOTE))
+                dump_printf_loc (MSG_NOTE, vect_location,
+				 "Detected double reduction.");

               STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_double_reduction_def;
               STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -625,8 +647,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
             {
               if (nested_cycle)
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Detected vectorizable nested cycle.");
+                  if (dump_kind_p (MSG_NOTE))
+                    dump_printf_loc (MSG_NOTE, vect_location,
+				     "Detected vectorizable nested cycle.");

                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_nested_cycle;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -634,8 +657,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
                 }
               else
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Detected reduction.");
+                  if (dump_kind_p (MSG_NOTE))
+                    dump_printf_loc (MSG_NOTE, vect_location,
+				     "Detected reduction.");

                   STMT_VINFO_DEF_TYPE (stmt_vinfo) = vect_reduction_def;
                   STMT_VINFO_DEF_TYPE (vinfo_for_stmt (reduc_stmt)) =
@@ -649,8 +673,9 @@ vect_analyze_scalar_cycles_1 (loop_vec_info loop_v
             }
         }
       else
-        if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Unknown def-use cycle pattern.");
+        if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			   "Unknown def-use cycle pattern.");
     }

   VEC_free (gimple, heap, worklist);
@@ -710,9 +735,9 @@ vect_get_loop_niters (struct loop *loop, tree *num
 {
   tree niters;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== get_loop_niters ===");
-
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "=== get_loop_niters ===");
   niters = number_of_exit_cond_executions (loop);

   if (niters != NULL_TREE
@@ -720,10 +745,10 @@ vect_get_loop_niters (struct loop *loop, tree *num
     {
       *number_of_iterations = niters;

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "==> get_loop_niters:" );
-          print_generic_expr (vect_dump, *number_of_iterations, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "==> get_loop_niters:");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, *number_of_iterations);
         }
     }

@@ -968,16 +993,18 @@ vect_analyze_loop_1 (struct loop *loop)
 {
   loop_vec_info loop_vinfo;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===== analyze_loop_nest_1 =====");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "===== analyze_loop_nest_1 =====");

   /* Check the CFG characteristics of the loop (nesting, entry/exit, etc.  */

   loop_vinfo = vect_analyze_loop_form (loop);
   if (!loop_vinfo)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bad inner-loop form.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad inner-loop form.");
       return NULL;
     }

@@ -1001,8 +1028,9 @@ vect_analyze_loop_form (struct loop *loop)
   tree number_of_iterations = NULL;
   loop_vec_info inner_loop_vinfo = NULL;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_loop_form ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "=== vect_analyze_loop_form ===");

   /* Different restrictions apply when we are considering an inner-most loop,
      vs. an outer (nested) loop.
@@ -1024,15 +1052,17 @@ vect_analyze_loop_form (struct loop *loop)

       if (loop->num_nodes != 2)
         {
-          if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: control flow in loop.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: control flow in loop.");
           return NULL;
         }

       if (empty_block_p (loop->header))
     {
-          if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: empty loop.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: empty loop.");
       return NULL;
     }
     }
@@ -1060,8 +1090,9 @@ vect_analyze_loop_form (struct loop *loop)

       if ((loop->inner)->inner || (loop->inner)->next)
 	{
-	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: multiple nested loops.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: multiple nested loops.");
 	  return NULL;
 	}

@@ -1069,25 +1100,27 @@ vect_analyze_loop_form (struct loop *loop)
       inner_loop_vinfo = vect_analyze_loop_1 (loop->inner);
       if (!inner_loop_vinfo)
 	{
-	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-            fprintf (vect_dump, "not vectorized: Bad inner loop.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: Bad inner loop."); 	  return NULL;
 	}

       if (!expr_invariant_in_loop_p (loop,
 					LOOP_VINFO_NITERS (inner_loop_vinfo)))
 	{
-	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump,
-		     "not vectorized: inner-loop count not invariant.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: inner-loop count not invariant.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}

       if (loop->num_nodes != 5)
         {
-	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: control flow in loop.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: control flow in loop.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
         }
@@ -1101,25 +1134,29 @@ vect_analyze_loop_form (struct loop *loop)
 	  || !single_exit (innerloop)
 	  || single_exit (innerloop)->dest !=  EDGE_PRED (loop->latch, 0)->src)
 	{
-	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: unsupported outerloop form.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: unsupported outerloop form.");
 	  destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
 	}

-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Considering outer-loop vectorization.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "Considering outer-loop vectorization.");
     }

   if (!single_exit (loop)
       || EDGE_COUNT (loop->header->preds) != 2)
     {
-      if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
           if (!single_exit (loop))
-            fprintf (vect_dump, "not vectorized: multiple exits.");
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: multiple exits.");
           else if (EDGE_COUNT (loop->header->preds) != 2)
-            fprintf (vect_dump, "not vectorized: too many incoming edges.");
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: too many incoming edges.");
         }
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
@@ -1133,8 +1170,9 @@ vect_analyze_loop_form (struct loop *loop)
   if (!empty_block_p (loop->latch)
         || !gimple_seq_empty_p (phi_nodes (loop->latch)))
     {
-      if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-        fprintf (vect_dump, "not vectorized: unexpected loop form.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: unexpected loop form.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1147,13 +1185,14 @@ vect_analyze_loop_form (struct loop *loop)
       if (!(e->flags & EDGE_ABNORMAL))
 	{
 	  split_loop_exit_edge (e);
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "split exit edge.");
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf (MSG_NOTE, "split exit edge.");
 	}
       else
 	{
-	  if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	    fprintf (vect_dump, "not vectorized: abnormal loop exit edge.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: abnormal loop exit edge.");
 	  if (inner_loop_vinfo)
 	    destroy_loop_vec_info (inner_loop_vinfo, true);
 	  return NULL;
@@ -1163,8 +1202,9 @@ vect_analyze_loop_form (struct loop *loop)
   loop_cond = vect_get_loop_niters (loop, &number_of_iterations);
   if (!loop_cond)
     {
-      if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	fprintf (vect_dump, "not vectorized: complicated exit condition.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: complicated exit condition.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1172,9 +1212,10 @@ vect_analyze_loop_form (struct loop *loop)

   if (!number_of_iterations)
     {
-      if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-	fprintf (vect_dump,
-		 "not vectorized: number of iterations cannot be computed.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: number of iterations cannot be "
+			 "computed.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1182,8 +1223,9 @@ vect_analyze_loop_form (struct loop *loop)

   if (chrec_contains_undetermined (number_of_iterations))
     {
-      if (vect_print_dump_info (REPORT_BAD_FORM_LOOPS))
-        fprintf (vect_dump, "Infinite number of iterations.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "Infinite number of iterations.");
       if (inner_loop_vinfo)
 	destroy_loop_vec_info (inner_loop_vinfo, true);
       return NULL;
@@ -1191,16 +1233,18 @@ vect_analyze_loop_form (struct loop *loop)

   if (!NITERS_KNOWN_P (number_of_iterations))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "Symbolic number of iterations is ");
-          print_generic_expr (vect_dump, number_of_iterations, TDF_DETAILS);
+          dump_printf_loc (MSG_NOTE, vect_location,
+			   "Symbolic number of iterations is ");
+	  dump_generic_expr (MSG_NOTE, TDF_DETAILS, number_of_iterations);
         }
     }
   else if (TREE_INT_CST_LOW (number_of_iterations) == 0)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: number of iterations = 0.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: number of iterations = 0.");
       if (inner_loop_vinfo)
         destroy_loop_vec_info (inner_loop_vinfo, false);
       return NULL;
@@ -1244,8 +1288,9 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   bool only_slp_in_loop = true, ok;
   HOST_WIDE_INT max_niter;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_loop_operations ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "=== vect_analyze_loop_operations ===");

   gcc_assert (LOOP_VINFO_VECT_FACTOR (loop_vinfo));
   vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo);
@@ -1279,9 +1324,10 @@ vect_analyze_loop_operations (loop_vec_info loop_v
 				LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo));

       LOOP_VINFO_VECT_FACTOR (loop_vinfo) = vectorization_factor;
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Updating vectorization factor to %d ",
-	 		    vectorization_factor);
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "Updating vectorization factor to %d ",
+			 vectorization_factor);
     }

   for (i = 0; i < nbbs; i++)
@@ -1294,10 +1340,10 @@ vect_analyze_loop_operations (loop_vec_info loop_v
           ok = true;

           stmt_info = vinfo_for_stmt (phi);
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_NOTE))
             {
-              fprintf (vect_dump, "examining phi: ");
-              print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+              dump_printf_loc (MSG_NOTE, vect_location, "examining phi: ");
+              dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
             }

           /* Inner-loop loop-closed exit phi in outer-loop vectorization
@@ -1313,9 +1359,10 @@ vect_analyze_loop_operations (loop_vec_info loop_v
                   && STMT_VINFO_DEF_TYPE (stmt_info)
                      != vect_double_reduction_def)
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump,
-                             "Unsupported loop-closed phi in outer-loop.");
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				     "Unsupported loop-closed phi in "
+				     "outer-loop.");
                   return false;
                 }

@@ -1354,8 +1401,9 @@ vect_analyze_loop_operations (loop_vec_info loop_v
           if (STMT_VINFO_LIVE_P (stmt_info))
             {
               /* FORNOW: not yet supported.  */
-              if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-                fprintf (vect_dump, "not vectorized: value used after loop.");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				 "not vectorized: value used after loop.");
               return false;
             }

@@ -1363,8 +1411,9 @@ vect_analyze_loop_operations (loop_vec_info loop_v
               && STMT_VINFO_DEF_TYPE (stmt_info) != vect_induction_def)
             {
               /* A scalar-dependence cycle that we don't support.  */
-              if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-                fprintf (vect_dump, "not vectorized: scalar
dependence cycle.");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				 "not vectorized: scalar dependence cycle.");
               return false;
             }

@@ -1377,11 +1426,12 @@ vect_analyze_loop_operations (loop_vec_info loop_v

           if (!ok)
             {
-              if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                 {
-                  fprintf (vect_dump,
-                           "not vectorized: relevant phi not supported: ");
-                  print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "not vectorized: relevant phi not "
+				   "supported: ");
+                  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, phi, 0);
                 }
 	      return false;
             }
@@ -1402,31 +1452,35 @@ vect_analyze_loop_operations (loop_vec_info loop_v
      touching this loop.  */
   if (!need_to_vectorize)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump,
-                 "All the computation can be taken out of the loop.");
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump,
-                 "not vectorized: redundant loop. no profit to vectorize.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "All the computation can be taken out of the loop.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: redundant loop. no profit to "
+			 "vectorize.");
       return false;
     }

   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
-      && vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump,
-        "vectorization_factor = %d, niters = " HOST_WIDE_INT_PRINT_DEC,
-        vectorization_factor, LOOP_VINFO_INT_NITERS (loop_vinfo));
+      && dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "vectorization_factor = %d, niters = "
+		     HOST_WIDE_INT_PRINT_DEC, vectorization_factor,
+		     LOOP_VINFO_INT_NITERS (loop_vinfo));

   if ((LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
        && (LOOP_VINFO_INT_NITERS (loop_vinfo) < vectorization_factor))
       || ((max_niter = max_stmt_executions_int (loop)) != -1
 	  && (unsigned HOST_WIDE_INT) max_niter < vectorization_factor))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: iteration count too small.");
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump,"not vectorized: iteration count smaller than "
-                 "vectorization factor.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: iteration count too small.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: iteration count smaller than "
+			 "vectorization factor.");
       return false;
     }

@@ -1441,11 +1495,13 @@ vect_analyze_loop_operations (loop_vec_info loop_v

   if (min_profitable_iters < 0)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization not profitable.");
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not vectorized: vector version will never be "
-                 "profitable.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: vectorization not profitable.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: vector version will never be "
+			 "profitable.");
       return false;
     }

@@ -1464,13 +1520,14 @@ vect_analyze_loop_operations (loop_vec_info loop_v
   if (LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
       && LOOP_VINFO_INT_NITERS (loop_vinfo) <= th)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization not "
-                 "profitable.");
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not vectorized: iteration count smaller than "
-                 "user specified loop bound parameter or minimum "
-                 "profitable iterations (whichever is more conservative).");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: vectorization not profitable.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "not vectorized: iteration count smaller than user "
+			 "specified loop bound parameter or minimum profitable "
+			 "iterations (whichever is more conservative).");
       return false;
     }

@@ -1478,20 +1535,20 @@ vect_analyze_loop_operations (loop_vec_info loop_v
       || LOOP_VINFO_INT_NITERS (loop_vinfo) % vectorization_factor != 0
       || LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "epilog loop required.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location, "epilog loop required.");
       if (!vect_can_advance_ivs_p (loop_vinfo))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump,
-                     "not vectorized: can't create epilog loop 1.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: can't create epilog loop 1.");
           return false;
         }
       if (!slpeel_can_duplicate_loop_p (loop, single_exit (loop)))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump,
-                     "not vectorized: can't create epilog loop 2.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not vectorized: can't create epilog loop 2.");
           return false;
         }
     }
@@ -1522,8 +1579,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_analyze_data_refs (loop_vinfo, NULL, &min_vf);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data references.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad data references.");
       return false;
     }

@@ -1539,8 +1597,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_mark_stmts_to_be_vectorized (loop_vinfo);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "unexpected pattern.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "unexpected pattern.");
       return false;
     }

@@ -1553,22 +1612,25 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   if (!ok
       || max_vf < min_vf)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data dependence.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "bad data dependence.");
       return false;
     }

   ok = vect_determine_vectorization_factor (loop_vinfo);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "can't determine vectorization factor.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "can't determine vectorization factor.");
       return false;
     }
   if (max_vf < LOOP_VINFO_VECT_FACTOR (loop_vinfo))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data dependence.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad data dependence.");
       return false;
     }

@@ -1578,8 +1640,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_analyze_data_refs_alignment (loop_vinfo, NULL);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data alignment.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad data alignment.");
       return false;
     }

@@ -1589,8 +1652,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_analyze_data_ref_accesses (loop_vinfo, NULL);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data access.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad data access.");
       return false;
     }

@@ -1600,9 +1664,10 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_prune_runtime_alias_test_list (loop_vinfo);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "too long list of versioning for alias "
-			    "run-time tests.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "too long list of versioning for alias "
+			 "run-time tests.");
       return false;
     }

@@ -1612,8 +1677,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_enhance_data_refs_alignment (loop_vinfo);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bad data alignment.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad data alignment.");
       return false;
     }

@@ -1636,8 +1702,9 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo)
   ok = vect_analyze_loop_operations (loop_vinfo, slp);
   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad operation or unsupported loop bound.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "bad operation or unsupported loop bound.");
       return false;
     }

@@ -1659,15 +1726,17 @@ vect_analyze_loop (struct loop *loop)
   current_vector_size = 0;
   vector_sizes = targetm.vectorize.autovectorize_vector_sizes ();

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===== analyze_loop_nest =====");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "===== analyze_loop_nest =====");

   if (loop_outer (loop)
       && loop_vec_info_for_loop (loop_outer (loop))
       && LOOP_VINFO_VECTORIZABLE_P (loop_vec_info_for_loop
(loop_outer (loop))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "outer-loop already vectorized.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "outer-loop already vectorized.");
       return NULL;
     }

@@ -1677,8 +1746,9 @@ vect_analyze_loop (struct loop *loop)
       loop_vinfo = vect_analyze_loop_form (loop);
       if (!loop_vinfo)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "bad loop form.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "bad loop form.");
 	  return NULL;
 	}

@@ -1698,9 +1768,10 @@ vect_analyze_loop (struct loop *loop)

       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "***** Re-trying analysis with "
-		 "vector size %d\n", current_vector_size);
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "***** Re-trying analysis with "
+			 "vector size %d\n", current_vector_size);
     }
 }

@@ -1754,10 +1825,10 @@ reduction_code_for_scalar_code (enum tree_code cod
    STMT is printed with a message MSG. */

 static void
-report_vect_op (gimple stmt, const char *msg)
+report_vect_op (int msg_type, gimple stmt, const char *msg)
 {
-  fprintf (vect_dump, "%s", msg);
-  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+  dump_printf_loc (msg_type, vect_location, "%s", msg);
+  dump_gimple_stmt (msg_type, TDF_SLIM, stmt, 0);
 }


@@ -1929,10 +2000,10 @@ vect_is_slp_reduction (loop_vec_info loop_info, gi
                                   == vect_internal_def
                       && !is_loop_header_bb_p (gimple_bb (def_stmt)))))
   	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (vect_dump, "swapping oprnds: ");
-		  print_gimple_stmt (vect_dump, next_stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_NOTE, vect_location, "swapping oprnds: ");
+		  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, next_stmt, 0);
 		}

 	      swap_tree_operands (next_stmt,
@@ -2031,8 +2102,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf

       if (!flow_bb_inside_loop_p (loop, gimple_bb (use_stmt)))
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "intermediate value used outside loop.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "intermediate value used outside loop.");

           return NULL;
         }
@@ -2042,18 +2114,20 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
         nloop_uses++;
       if (nloop_uses > 1)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduction used in loop.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "reduction used in loop.");
           return NULL;
         }
     }

   if (TREE_CODE (loop_arg) != SSA_NAME)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	{
-	  fprintf (vect_dump, "reduction: not ssa_name: ");
-	  print_generic_expr (vect_dump, loop_arg, TDF_SLIM);
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			   "reduction: not ssa_name: ");
+	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, loop_arg);
 	}
       return NULL;
     }
@@ -2061,15 +2135,16 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
   def_stmt = SSA_NAME_DEF_STMT (loop_arg);
   if (!def_stmt)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "reduction: no def_stmt.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "reduction: no def_stmt.");
       return NULL;
     }

   if (!is_gimple_assign (def_stmt) && gimple_code (def_stmt) != GIMPLE_PHI)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        print_gimple_stmt (vect_dump, def_stmt, 0, TDF_SLIM);
+      if (dump_kind_p (MSG_NOTE))
+        dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
       return NULL;
     }

@@ -2096,8 +2171,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
 	nloop_uses++;
       if (nloop_uses > 1)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "reduction used in loop.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "reduction used in loop.");
 	  return NULL;
 	}
     }
@@ -2111,8 +2187,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       if (gimple_phi_num_args (def_stmt) != 1
           || TREE_CODE (op1) != SSA_NAME)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "unsupported phi node definition.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "unsupported phi node definition.");

           return NULL;
         }
@@ -2123,8 +2200,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
           && flow_bb_inside_loop_p (loop->inner, gimple_bb (def1))
           && is_gimple_assign (def1))
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            report_vect_op (def_stmt, "detected double reduction: ");
+          if (dump_kind_p (MSG_NOTE))
+            report_vect_op (MSG_NOTE, def_stmt,
+			    "detected double reduction: ");

           *double_reduc = true;
           return def_stmt;
@@ -2149,8 +2227,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
   if (check_reduction
       && (!commutative_tree_code (code) || !associative_tree_code (code)))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        report_vect_op (def_stmt, "reduction: not commutative/associative: ");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+			"reduction: not commutative/associative: ");
       return NULL;
     }

@@ -2158,8 +2237,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
     {
       if (code != COND_EXPR)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-	    report_vect_op (def_stmt, "reduction: not binary operation: ");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+			    "reduction: not binary operation: ");

           return NULL;
         }
@@ -2176,8 +2256,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf

       if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            report_vect_op (def_stmt, "reduction: uses not ssa_names: ");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+			    "reduction: uses not ssa_names: ");

           return NULL;
         }
@@ -2189,8 +2270,9 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf

       if (TREE_CODE (op1) != SSA_NAME && TREE_CODE (op2) != SSA_NAME)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-	    report_vect_op (def_stmt, "reduction: uses not ssa_names: ");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+			    "reduction: uses not ssa_names: ");

           return NULL;
         }
@@ -2206,24 +2288,29 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       || (op4 && TREE_CODE (op4) == SSA_NAME
           && !types_compatible_p (type, TREE_TYPE (op4))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "reduction: multiple types: operation type: ");
-          print_generic_expr (vect_dump, type, TDF_SLIM);
-          fprintf (vect_dump, ", operands types: ");
-          print_generic_expr (vect_dump, TREE_TYPE (op1), TDF_SLIM);
-          fprintf (vect_dump, ",");
-          print_generic_expr (vect_dump, TREE_TYPE (op2), TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location,
+			   "reduction: multiple types: operation type: ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, type);
+          dump_printf (MSG_NOTE, ", operands types: ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM,
+			     TREE_TYPE (op1));
+          dump_printf (MSG_NOTE, ",");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM,
+			     TREE_TYPE (op2));
           if (op3)
             {
-              fprintf (vect_dump, ",");
-              print_generic_expr (vect_dump, TREE_TYPE (op3), TDF_SLIM);
+              dump_printf (MSG_NOTE, ",");
+              dump_generic_expr (MSG_NOTE, TDF_SLIM,
+				 TREE_TYPE (op3));
             }

           if (op4)
             {
-              fprintf (vect_dump, ",");
-              print_generic_expr (vect_dump, TREE_TYPE (op4), TDF_SLIM);
+              dump_printf (MSG_NOTE, ",");
+              dump_generic_expr (MSG_NOTE, TDF_SLIM,
+				 TREE_TYPE (op4));
             }
         }

@@ -2243,23 +2330,25 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
       && check_reduction)
     {
       /* Changing the order of operations changes the semantics.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-	report_vect_op (def_stmt, "reduction: unsafe fp math optimization: ");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+			"reduction: unsafe fp math optimization: ");
       return NULL;
     }
   else if (INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type)
 	   && check_reduction)
     {
       /* Changing the order of operations changes the semantics.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-	report_vect_op (def_stmt, "reduction: unsafe int math optimization: ");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+			"reduction: unsafe int math optimization: ");
       return NULL;
     }
   else if (SAT_FIXED_POINT_TYPE_P (type) && check_reduction)
     {
       /* Changing the order of operations changes the semantics.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-	report_vect_op (def_stmt,
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
 			"reduction: unsafe fixed-point math optimization: ");
       return NULL;
     }
@@ -2295,8 +2384,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
   if (code != COND_EXPR
       && ((!def1 || gimple_nop_p (def1)) && (!def2 || gimple_nop_p (def2))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	report_vect_op (def_stmt, "reduction: no defs for operands: ");
+      if (dump_kind_p (MSG_NOTE))
+	report_vect_op (MSG_NOTE, def_stmt, "reduction: no defs for operands: ");
       return NULL;
     }

@@ -2317,8 +2406,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
                           == vect_internal_def
  	              && !is_loop_header_bb_p (gimple_bb (def1)))))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	report_vect_op (def_stmt, "detected reduction: ");
+      if (dump_kind_p (MSG_NOTE))
+	report_vect_op (MSG_NOTE, def_stmt, "detected reduction: ");
       return def_stmt;
     }

@@ -2340,8 +2429,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
           /* Swap operands (just for simplicity - so that the rest of the code
 	     can assume that the reduction variable is always the last (second)
 	     argument).  */
-          if (vect_print_dump_info (REPORT_DETAILS))
-	    report_vect_op (def_stmt,
+          if (dump_kind_p (MSG_NOTE))
+	    report_vect_op (MSG_NOTE, def_stmt,
 	  	            "detected reduction: need to swap operands: ");

           swap_tree_operands (def_stmt, gimple_assign_rhs1_ptr (def_stmt),
@@ -2352,8 +2441,8 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
         }
       else
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            report_vect_op (def_stmt, "detected reduction: ");
+          if (dump_kind_p (MSG_NOTE))
+            report_vect_op (MSG_NOTE, def_stmt, "detected reduction: ");
         }

       return def_stmt;
@@ -2362,14 +2451,16 @@ vect_is_simple_reduction_1 (loop_vec_info loop_inf
   /* Try to find SLP reduction chain.  */
   if (check_reduction && vect_is_slp_reduction (loop_info, phi, def_stmt))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        report_vect_op (def_stmt, "reduction: detected reduction chain: ");
+      if (dump_kind_p (MSG_NOTE))
+        report_vect_op (MSG_NOTE, def_stmt,
+			"reduction: detected reduction chain: ");

       return def_stmt;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    report_vect_op (def_stmt, "reduction: unknown pattern: ");
+  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+    report_vect_op (MSG_MISSED_OPTIMIZATION, def_stmt,
+		    "reduction: unknown pattern: ");

   return NULL;
 }
@@ -2475,10 +2566,10 @@ vect_get_known_peeling_cost (loop_vec_info loop_vi
   if (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
       *peel_iters_epilogue = vf/2;
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                            "epilogue peel iters set to vf/2 because "
-                            "loop iterations are unknown .");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "cost model: epilogue peel iters set to vf/2 "
+			 "because loop iterations are unknown .");

       /* If peeled iterations are known but number of scalar loop
          iterations are unknown, count a taken branch per peeled loop.  */
@@ -2536,8 +2627,7 @@ vect_estimate_min_profitable_iters (loop_vec_info
   /* Cost model disabled.  */
   if (!flag_vect_cost_model)
     {
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model disabled.");
+      dump_printf_loc (MSG_NOTE, vect_location, "cost model disabled.");
       return 0;
     }

@@ -2549,9 +2639,9 @@ vect_estimate_min_profitable_iters (loop_vec_info
 				 LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo));
       (void) add_stmt_cost (target_cost_data, len, vector_stmt, NULL, 0,
 			    vect_prologue);
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: Adding cost of checks for loop "
-                 "versioning to treat misalignment.\n");
+      dump_printf (MSG_NOTE,
+                   "cost model: Adding cost of checks for loop "
+                   "versioning to treat misalignment.\n");
     }

   /* Requires loop versioning with alias checks.  */
@@ -2561,9 +2651,9 @@ vect_estimate_min_profitable_iters (loop_vec_info
       unsigned len = VEC_length (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS
(loop_vinfo));
       (void) add_stmt_cost (target_cost_data, len, vector_stmt, NULL, 0,
 			    vect_prologue);
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: Adding cost of checks for loop "
-                 "versioning aliasing.\n");
+      dump_printf (MSG_NOTE,
+                   "cost model: Adding cost of checks for loop "
+                   "versioning aliasing.\n");
     }

   if (LOOP_REQUIRES_VERSIONING_FOR_ALIGNMENT (loop_vinfo)
@@ -2593,17 +2683,15 @@ vect_estimate_min_profitable_iters (loop_vec_info
   if (npeel  < 0)
     {
       peel_iters_prologue = vf/2;
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                 "prologue peel iters set to vf/2.");
+      dump_printf (MSG_NOTE, "cost model: "
+                   "prologue peel iters set to vf/2.");

       /* If peeling for alignment is unknown, loop bound of main loop becomes
          unknown.  */
       peel_iters_epilogue = vf/2;
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: "
-                 "epilogue peel iters set to vf/2 because "
-                 "peeling for alignment is unknown .");
+      dump_printf (MSG_NOTE, "cost model: "
+                   "epilogue peel iters set to vf/2 because "
+                   "peeling for alignment is unknown.");

       /* If peeled iterations are unknown, count a taken branch and a not taken
          branch per peeled loop. Even if scalar loop iterations are known,
@@ -2769,32 +2857,35 @@ vect_estimate_min_profitable_iters (loop_vec_info
   /* vector version will never be profitable.  */
   else
     {
-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "cost model: the vector iteration cost = %d "
-		 "divided by the scalar iteration cost = %d "
-		 "is greater or equal to the vectorization factor = %d.",
-                 vec_inside_cost, scalar_single_iter_cost, vf);
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "cost model: the vector iteration cost = %d "
+			 "divided by the scalar iteration cost = %d "
+			 "is greater or equal to the vectorization factor = %d.",
+			 vec_inside_cost, scalar_single_iter_cost, vf);
       return -1;
     }

-  if (vect_print_dump_info (REPORT_COST))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "Cost model analysis: \n");
-      fprintf (vect_dump, "  Vector inside of loop cost: %d\n",
-	       vec_inside_cost);
-      fprintf (vect_dump, "  Vector prologue cost: %d\n",
-	       vec_prologue_cost);
-      fprintf (vect_dump, "  Vector epilogue cost: %d\n",
-	       vec_epilogue_cost);
-      fprintf (vect_dump, "  Scalar iteration cost: %d\n",
-	       scalar_single_iter_cost);
-      fprintf (vect_dump, "  Scalar outside cost: %d\n", scalar_outside_cost);
-      fprintf (vect_dump, "  prologue iterations: %d\n",
-               peel_iters_prologue);
-      fprintf (vect_dump, "  epilogue iterations: %d\n",
-               peel_iters_epilogue);
-      fprintf (vect_dump, "  Calculated minimum iters for profitability: %d\n",
-	       min_profitable_iters);
+      dump_printf (MSG_NOTE, "Cost model analysis: \n");
+      dump_printf (MSG_NOTE, "  Vector inside of loop cost: %d\n",
+                   vec_inside_cost);
+      dump_printf (MSG_NOTE, "  Vector prologue cost: %d\n",
+                   vec_prologue_cost);
+      dump_printf (MSG_NOTE, "  Vector epilogue cost: %d\n",
+                   vec_epilogue_cost);
+      dump_printf (MSG_NOTE, "  Scalar iteration cost: %d\n",
+                   scalar_single_iter_cost);
+      dump_printf (MSG_NOTE, "  Scalar outside cost: %d\n",
+                   scalar_outside_cost);
+      dump_printf (MSG_NOTE, "  prologue iterations: %d\n",
+                   peel_iters_prologue);
+      dump_printf (MSG_NOTE, "  epilogue iterations: %d\n",
+                   peel_iters_epilogue);
+      dump_printf (MSG_NOTE,
+                   "  Calculated minimum iters for profitability: %d\n",
+                   min_profitable_iters);
     }

   min_profitable_iters =
@@ -2805,9 +2896,9 @@ vect_estimate_min_profitable_iters (loop_vec_info
        then skip the vectorized loop.  */
   min_profitable_iters--;

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "  Profitability threshold = %d\n",
-	     min_profitable_iters);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE, "  Profitability threshold = %d\n",
+                 min_profitable_iters);

   return min_profitable_iters;
 }
@@ -2864,10 +2955,12 @@ vect_model_reduction_cost (stmt_vec_info stmt_info
   vectype = get_vectype_for_scalar_type (TREE_TYPE (reduction_op));
   if (!vectype)
     {
-      if (vect_print_dump_info (REPORT_COST))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "unsupported data-type ");
-          print_generic_expr (vect_dump, TREE_TYPE (reduction_op), TDF_SLIM);
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			   "unsupported data-type ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+			     TREE_TYPE (reduction_op));
         }
       return false;
    }
@@ -2933,10 +3026,11 @@ vect_model_reduction_cost (stmt_vec_info stmt_info
 	}
     }

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_reduction_cost: inside_cost = %d, "
-             "prologue_cost = %d, epilogue_cost = %d .", inside_cost,
-	     prologue_cost, epilogue_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf (MSG_NOTE,
+                 "vect_model_reduction_cost: inside_cost = %d, "
+                 "prologue_cost = %d, epilogue_cost = %d .", inside_cost,
+                 prologue_cost, epilogue_cost);

   return true;
 }
@@ -2961,9 +3055,10 @@ vect_model_induction_cost (stmt_vec_info stmt_info
   prologue_cost = add_stmt_cost (target_cost_data, 2, scalar_to_vec,
 				 stmt_info, 0, vect_prologue);

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_induction_cost: inside_cost = %d, "
-             "prologue_cost = %d .", inside_cost, prologue_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_model_induction_cost: inside_cost = %d, "
+                     "prologue_cost = %d .", inside_cost, prologue_cost);
 }


@@ -3089,10 +3184,11 @@ get_initial_def_for_induction (gimple iv_phi)
 	  new_bb = gsi_insert_on_edge_immediate (pe, init_stmt);
 	  gcc_assert (!new_bb);

-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "created new init_stmt: ");
-	      print_gimple_stmt (vect_dump, init_stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+			       "created new init_stmt: ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, init_stmt, 0);
 	    }
 	  CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_name);
 	}
@@ -3231,21 +3327,24 @@ get_initial_def_for_induction (gimple iv_phi)
 		      && !STMT_VINFO_LIVE_P (stmt_vinfo));

 	  STMT_VINFO_VEC_STMT (stmt_vinfo) = new_stmt;
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "vector of inductions after inner-loop:");
-	      print_gimple_stmt (vect_dump, new_stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+			       "vector of inductions after inner-loop:");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, new_stmt, 0);
 	    }
 	}
     }


-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "transform induction: created def-use cycle: ");
-      print_gimple_stmt (vect_dump, induction_phi, 0, TDF_SLIM);
-      fprintf (vect_dump, "\n");
-      print_gimple_stmt (vect_dump, SSA_NAME_DEF_STMT (vec_def), 0, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+		       "transform induction: created def-use cycle: ");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, induction_phi, 0);
+      dump_printf (MSG_NOTE, "\n");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
+			SSA_NAME_DEF_STMT (vec_def), 0);
     }

   STMT_VINFO_VEC_STMT (phi_info) = induction_phi;
@@ -3646,14 +3745,13 @@ vect_create_epilog_for_reduction (VEC (tree, heap)

           add_phi_arg (phi, def, loop_latch_edge (loop), UNKNOWN_LOCATION);

-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_NOTE))
             {
-              fprintf (vect_dump, "transform reduction: created def-use"
-                                  " cycle: ");
-              print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
-              fprintf (vect_dump, "\n");
-              print_gimple_stmt (vect_dump, SSA_NAME_DEF_STMT (def), 0,
-                                 TDF_SLIM);
+              dump_printf_loc (MSG_NOTE, vect_location,
+			       "transform reduction: created def-use cycle: ");
+              dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
+              dump_printf (MSG_NOTE, "\n");
+              dump_gimple_stmt (MSG_NOTE, TDF_SLIM, SSA_NAME_DEF_STMT
(def), 0);
             }

           phi = STMT_VINFO_RELATED_STMT (vinfo_for_stmt (phi));
@@ -3848,8 +3946,9 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
       /*** Case 1:  Create:
            v_out2 = reduc_expr <v_out1>  */

-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Reduce using direct vector reduction.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "Reduce using direct vector reduction.");

       vec_dest = vect_create_destination_var (scalar_dest, vectype);
       tmp = build1 (reduc_code, vectype, new_phi_result);
@@ -3898,8 +3997,9 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
                   Create:  va = vop <va, va'>
                 }  */

-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Reduce using vector shifts");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+			     "Reduce using vector shifts");

           vec_dest = vect_create_destination_var (scalar_dest, vectype);
           new_temp = new_phi_result;
@@ -3938,8 +4038,9 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
                  Create:  s = op <s, s'>  // For non SLP cases
                }  */

-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Reduce using scalar code. ");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+			     "Reduce using scalar code. ");

           vec_size_in_bits = tree_low_cst (TYPE_SIZE (vectype), 1);
           FOR_EACH_VEC_ELT (gimple, new_phis, i, new_phi)
@@ -4028,8 +4129,9 @@ vect_create_epilog_for_reduction (VEC (tree, heap)
     {
       tree rhs;

-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "extract scalar result");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "extract scalar result");

       if (BYTES_BIG_ENDIAN)
         bitpos = size_binop (MULT_EXPR,
@@ -4266,11 +4368,11 @@ vect_finalize_reduction:
                                UNKNOWN_LOCATION);
                   add_phi_arg (vect_phi, PHI_RESULT (inner_phi),
                                loop_latch_edge (outer_loop), UNKNOWN_LOCATION);
-                  if (vect_print_dump_info (REPORT_DETAILS))
+                  if (dump_kind_p (MSG_NOTE))
                     {
-                      fprintf (vect_dump, "created double reduction phi "
-                                          "node: ");
-                      print_gimple_stmt (vect_dump, vect_phi, 0, TDF_SLIM);
+                      dump_printf_loc (MSG_NOTE, vect_location,
+				       "created double reduction phi node: ");
+                      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, vect_phi, 0);
                     }

                   vect_phi_res = PHI_RESULT (vect_phi);
@@ -4616,8 +4718,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
     {
       if (!vectorizable_condition (stmt, gsi, NULL, ops[reduc_index], 0, NULL))
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "unsupported condition in reduction");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "unsupported condition in reduction");

             return false;
         }
@@ -4630,24 +4733,25 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       optab = optab_for_tree_code (code, vectype_in, optab_default);
       if (!optab)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no optab.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "no optab.");

           return false;
         }

       if (optab_handler (optab, vec_mode) == CODE_FOR_nothing)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "op not supported by target.");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf (MSG_NOTE, "op not supported by target.");

           if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
               || LOOP_VINFO_VECT_FACTOR (loop_vinfo)
 	          < vect_min_worthwhile_factor (code))
             return false;

-          if (vect_print_dump_info (REPORT_DETAILS))
-  	    fprintf (vect_dump, "proceeding using word mode.");
+          if (dump_kind_p (MSG_NOTE))
+  	    dump_printf (MSG_NOTE, "proceeding using word mode.");
         }

       /* Worthwhile without SIMD support?  */
@@ -4655,8 +4759,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
           && LOOP_VINFO_VECT_FACTOR (loop_vinfo)
    	     < vect_min_worthwhile_factor (code))
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "not worthwhile without SIMD support.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "not worthwhile without SIMD support.");

           return false;
         }
@@ -4735,8 +4840,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
                                          optab_default);
       if (!reduc_optab)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no optab for reduction.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "no optab for reduction.");

           epilog_reduc_code = ERROR_MARK;
         }
@@ -4744,8 +4850,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
       if (reduc_optab
           && optab_handler (reduc_optab, vec_mode) == CODE_FOR_nothing)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "reduc op not supported by target.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "reduc op not supported by target.");

           epilog_reduc_code = ERROR_MARK;
         }
@@ -4754,8 +4861,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
     {
       if (!nested_cycle || double_reduc)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "no reduc code for scalar code.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "no reduc code for scalar code.");

           return false;
         }
@@ -4763,8 +4871,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i

   if (double_reduc && ncopies > 1)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in double reduction");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "multiple types in double reduction");

       return false;
     }
@@ -4781,8 +4890,9 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i
         ops[1] = fold_convert (TREE_TYPE (ops[0]), ops[1]);
       else
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "invalid types in dot-prod");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "invalid types in dot-prod");

           return false;
         }
@@ -4798,8 +4908,8 @@ vectorizable_reduction (gimple stmt, gimple_stmt_i

   /** Transform.  **/

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform reduction.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "transform reduction.");

   /* FORNOW: Multiple types are not supported for condition.  */
   if (code == COND_EXPR)
@@ -5084,8 +5194,9 @@ vectorizable_induction (gimple phi, gimple_stmt_it

       if (ncopies > 1)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple types in nested loop.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "multiple types in nested loop.");
 	  return false;
 	}

@@ -5107,9 +5218,10 @@ vectorizable_induction (gimple phi, gimple_stmt_it
 	  if (!(STMT_VINFO_RELEVANT_P (exit_phi_vinfo)
 		&& !STMT_VINFO_LIVE_P (exit_phi_vinfo)))
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "inner-loop induction only used outside "
-			 "of the outer vectorized loop.");
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				 "inner-loop induction only used outside "
+				 "of the outer vectorized loop.");
 	      return false;
 	    }
 	}
@@ -5130,16 +5242,17 @@ vectorizable_induction (gimple phi, gimple_stmt_it
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = induc_vec_info_type;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_induction ===");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "=== vectorizable_induction ===");
       vect_model_induction_cost (stmt_info, ncopies);
       return true;
     }

   /** Transform.  **/

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform induction phi.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "transform induction phi.");

   vec_def = get_initial_def_for_induction (phi);
   *vec_stmt = SSA_NAME_DEF_STMT (vec_def);
@@ -5203,8 +5316,9 @@ vectorizable_live_operation (gimple stmt,
           && !vect_is_simple_use (op, stmt, loop_vinfo, NULL, &def_stmt, &def,
 				  &dt))
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "use not simple.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "use not simple.");
           return false;
         }

@@ -5241,8 +5355,9 @@ vect_loop_kill_debug_uses (struct loop *loop, gimp
 	    {
 	      if (gimple_debug_bind_p (ustmt))
 		{
-		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "killing debug use");
+		  if (dump_kind_p (MSG_NOTE))
+		    dump_printf_loc (MSG_NOTE, vect_location,
+                                     "killing debug use");

 		  gimple_debug_bind_reset_value (ustmt);
 		  update_stmt (ustmt);
@@ -5280,8 +5395,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   bool check_profitability = false;
   int th;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vec_transform_loop ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "=== vec_transform_loop ===");

   /* Use the more conservative vectorization threshold.  If the number
      of iterations is constant assume the cost check has been performed
@@ -5294,9 +5409,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   if (th >= LOOP_VINFO_VECT_FACTOR (loop_vinfo) - 1
       && !LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo))
     {
-      if (vect_print_dump_info (REPORT_COST))
-	fprintf (vect_dump,
-		 "Profitability threshold is %d loop iterations.", th);
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "Profitability threshold is %d loop iterations.", th);
       check_profitability = true;
     }

@@ -5355,10 +5470,11 @@ vect_transform_loop (loop_vec_info loop_vinfo)
       for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
         {
 	  phi = gsi_stmt (si);
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "------>vectorizing phi: ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "------>vectorizing phi: ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	    }
 	  stmt_info = vinfo_for_stmt (phi);
 	  if (!stmt_info)
@@ -5373,13 +5489,13 @@ vect_transform_loop (loop_vec_info loop_vinfo)

 	  if ((TYPE_VECTOR_SUBPARTS (STMT_VINFO_VECTYPE (stmt_info))
 	        != (unsigned HOST_WIDE_INT) vectorization_factor)
-	      && vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple-types.");
+	      && dump_kind_p (MSG_NOTE))
+	    dump_printf_loc (MSG_NOTE, vect_location, "multiple-types.");

 	  if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def)
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "transform phi.");
+	      if (dump_kind_p (MSG_NOTE))
+		dump_printf_loc (MSG_NOTE, vect_location, "transform phi.");
 	      vect_transform_stmt (phi, NULL, NULL, NULL, NULL);
 	    }
 	}
@@ -5394,10 +5510,11 @@ vect_transform_loop (loop_vec_info loop_vinfo)
           else
             stmt = gsi_stmt (si);

-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "------>vectorizing statement: ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+			       "------>vectorizing statement: ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	    }

 	  stmt_info = vinfo_for_stmt (stmt);
@@ -5465,12 +5582,13 @@ vect_transform_loop (loop_vec_info loop_vinfo)

 		  if (!gsi_end_p (pattern_def_si))
 		    {
-		      if (vect_print_dump_info (REPORT_DETAILS))
+		      if (dump_kind_p (MSG_NOTE))
 			{
-			  fprintf (vect_dump, "==> vectorizing pattern def"
-					      " stmt: ");
-			  print_gimple_stmt (vect_dump, pattern_def_stmt, 0,
-					     TDF_SLIM);
+			  dump_printf_loc (MSG_NOTE, vect_location,
+					   "==> vectorizing pattern def "
+					   "stmt: ");
+			  dump_gimple_stmt (MSG_NOTE, TDF_SLIM,
+					    pattern_def_stmt, 0);
 			}

 		      stmt = pattern_def_stmt;
@@ -5491,10 +5609,11 @@ vect_transform_loop (loop_vec_info loop_vinfo)
                                                STMT_VINFO_VECTYPE (stmt_info));
 	  if (!STMT_SLP_TYPE (stmt_info)
 	      && nunits != (unsigned int) vectorization_factor
-              && vect_print_dump_info (REPORT_DETAILS))
+              && dump_kind_p (MSG_NOTE))
 	    /* For SLP VF is set according to unrolling factor, and not to
 	       vector size, hence for SLP this print is not valid.  */
-            fprintf (vect_dump, "multiple-types.");
+            dump_printf_loc (MSG_NOTE, vect_location,
+			     "multiple-types.");

 	  /* SLP. Schedule all the SLP instances when the first SLP stmt is
 	     reached.  */
@@ -5504,8 +5623,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 		{
 		  slp_scheduled = true;

-		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "=== scheduling SLP instances ===");
+		  if (dump_kind_p (MSG_NOTE))
+		    dump_printf_loc (MSG_NOTE, vect_location,
+				     "=== scheduling SLP instances ===");

 		  vect_schedule_slp (loop_vinfo, NULL);
 		}
@@ -5523,8 +5643,8 @@ vect_transform_loop (loop_vec_info loop_vinfo)
 	    }

 	  /* -------- vectorize statement ------------ */
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "transform statement.");
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf_loc (MSG_NOTE, vect_location, "transform statement.");

 	  grouped_store = false;
 	  is_store = vect_transform_stmt (stmt, &si, &grouped_store, NULL, NULL);
@@ -5566,8 +5686,9 @@ vect_transform_loop (loop_vec_info loop_vinfo)
      until all the loops have been transformed?  */
   update_ssa (TODO_update_ssa);

-  if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "LOOP VECTORIZED.");
-  if (loop->inner && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
-    fprintf (vect_dump, "OUTER LOOP VECTORIZED.");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, "LOOP
VECTORIZED.");
+  if (loop->inner && dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+		     "OUTER LOOP VECTORIZED.");
 }
Index: flag-types.h
===================================================================
--- flag-types.h	(revision 191208)
+++ flag-types.h	(working copy)
@@ -200,20 +200,4 @@ enum fp_contract_mode {
   FP_CONTRACT_FAST = 2
 };

-/* Vectorizer verbosity levels.  */
-enum vect_verbosity_levels {
-  REPORT_NONE,
-  REPORT_VECTORIZED_LOCATIONS,
-  REPORT_UNVECTORIZED_LOCATIONS,
-  REPORT_COST,
-  REPORT_ALIGNMENT,
-  REPORT_DR_DETAILS,
-  REPORT_BAD_FORM_LOOPS,
-  REPORT_OUTER_LOOPS,
-  REPORT_SLP,
-  REPORT_DETAILS,
-  /* New verbosity levels should be added before this one.  */
-  MAX_VERBOSITY_LEVEL
-};
-
 #endif /* ! GCC_FLAG_TYPES_H */
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c	(revision 191208)
+++ tree-vect-data-refs.c	(working copy)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -59,23 +60,26 @@ vect_lanes_optab_supported_p (const char *name, co

   if (array_mode == BLKmode)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "no array mode for %s[" HOST_WIDE_INT_PRINT_DEC "]",
-		 GET_MODE_NAME (mode), count);
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "no array mode for %s[" HOST_WIDE_INT_PRINT_DEC "]",
+                         GET_MODE_NAME (mode), count);
       return false;
     }

   if (convert_optab_handler (optab, array_mode, mode) == CODE_FOR_nothing)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "cannot use %s<%s><%s>",
-		 name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "cannot use %s<%s><%s>", name,
+                         GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
       return false;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "can use %s<%s><%s>",
-	     name, GET_MODE_NAME (array_mode), GET_MODE_NAME (mode));
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "can use %s<%s><%s>", name, GET_MODE_NAME (array_mode),
+                     GET_MODE_NAME (mode));

   return true;
 }
@@ -435,12 +439,13 @@ vect_check_interleaving (struct data_reference *dr
       if (diff_mod_size == 0)
 	{
 	  vect_update_interleaving_chain (drb, dra);
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "Detected interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "Detected interleaving ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
+	      dump_printf (MSG_NOTE,  " and ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
 	    }
 	  return true;
 	}
@@ -457,12 +462,13 @@ vect_check_interleaving (struct data_reference *dr
       if (diff_mod_size == 0)
 	{
 	  vect_update_interleaving_chain (dra, drb);
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "Detected interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "Detected interleaving ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
+	      dump_printf (MSG_NOTE,  " and ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
 	    }
 	  return true;
 	}
@@ -518,26 +524,29 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
   if ((unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS) == 0)
     return false;

-  if (vect_print_dump_info (REPORT_DR_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "mark for run-time aliasing test between ");
-      print_generic_expr (vect_dump, DR_REF (DDR_A (ddr)), TDF_SLIM);
-      fprintf (vect_dump, " and ");
-      print_generic_expr (vect_dump, DR_REF (DDR_B (ddr)), TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+                       "mark for run-time aliasing test between ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr)));
+      dump_printf (MSG_NOTE,  " and ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_B (ddr)));
     }

   if (optimize_loop_nest_for_size_p (loop))
     {
-      if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not supported when optimizing for size.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "versioning not supported when optimizing for size.");
       return false;
     }

   /* FORNOW: We don't support versioning with outer-loop vectorization.  */
   if (loop->inner)
     {
-      if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not yet supported for outer-loops.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "versioning not yet supported for outer-loops.");
       return false;
     }

@@ -546,9 +555,10 @@ vect_mark_for_runtime_alias_test (ddr_p ddr, loop_
   if (TREE_CODE (DR_STEP (DDR_A (ddr))) != INTEGER_CST
       || TREE_CODE (DR_STEP (DDR_B (ddr))) != INTEGER_CST)
     {
-      if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "versioning not yet supported for non-constant "
-		 "step");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "versioning not yet supported for non-constant "
+                         "step");
       return false;
     }

@@ -601,13 +611,16 @@ vect_analyze_data_ref_dependence (struct data_depe

       if (loop_vinfo)
         {
-          if (vect_print_dump_info (REPORT_DR_DETAILS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "versioning for alias required: "
-                                  "can't determine dependence between ");
-              print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-              fprintf (vect_dump, " and ");
-              print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "versioning for alias required: "
+                               "can't determine dependence between ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                 DR_REF (dra));
+              dump_printf (MSG_MISSED_OPTIMIZATION, " and ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                 DR_REF (drb));
             }

           /* Add to list of ddrs that need to be tested at run-time.  */
@@ -624,12 +637,13 @@ vect_analyze_data_ref_dependence (struct data_depe
       if (DR_IS_READ (dra) && DR_IS_READ (drb))
         return false;

-      if (vect_print_dump_info (REPORT_DR_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "can't determine dependence between ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "can't determine dependence between ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, DR_REF (dra));
+          dump_printf (MSG_MISSED_OPTIMIZATION,  " and ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, DR_REF (drb));
         }

       /* We do not vectorize basic blocks with write-write dependencies.  */
@@ -652,31 +666,34 @@ vect_analyze_data_ref_dependence (struct data_depe
       if (dra != drb && vect_check_interleaving (dra, drb))
         return false;

-      if (vect_print_dump_info (REPORT_DR_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "determined dependence between ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "determined dependence between ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
+          dump_printf (MSG_NOTE, " and ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
         }

       /* Do not vectorize basic blcoks with write-write dependences.  */
       if (DR_IS_WRITE (dra) && DR_IS_WRITE (drb))
         return true;

-      /* Check if this dependence is allowed in basic block vectorization.  */
+      /* Check if this dependence is allowed in basic block vectorization.  */
       return vect_drs_dependent_in_basic_block (dra, drb);
     }

   /* Loop-based vectorization and known data dependence.  */
   if (DDR_NUM_DIST_VECTS (ddr) == 0)
     {
-      if (vect_print_dump_info (REPORT_DR_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "versioning for alias required: bad
dist vector for ");
-          print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-          fprintf (vect_dump, " and ");
-          print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "versioning for alias required: "
+                           "bad dist vector for ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, DR_REF (dra));
+          dump_printf (MSG_MISSED_OPTIMIZATION,  " and ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, DR_REF (drb));
         }
       /* Add to list of ddrs that need to be tested at run-time.  */
       return !vect_mark_for_runtime_alias_test (ddr, loop_vinfo);
@@ -687,17 +704,19 @@ vect_analyze_data_ref_dependence (struct data_depe
     {
       int dist = dist_v[loop_depth];

-      if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "dependence distance  = %d.", dist);
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "dependence distance  = %d.", dist);

       if (dist == 0)
 	{
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "dependence distance == 0 between ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "dependence distance == 0 between ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
+	      dump_printf (MSG_NOTE, " and ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
 	    }

           /* For interleaving, mark that there is a read-write dependency if
@@ -718,8 +737,9 @@ vect_analyze_data_ref_dependence (struct data_depe
 	  /* If DDR_REVERSED_P the order of the data-refs in DDR was
 	     reversed (to make distance vector positive), and the actual
 	     distance is negative.  */
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "dependence distance negative.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "dependence distance negative.");
 	  continue;
 	}

@@ -729,27 +749,30 @@ vect_analyze_data_ref_dependence (struct data_depe
 	  /* The dependence distance requires reduction of the maximal
 	     vectorization factor.  */
 	  *max_vf = abs (dist);
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "adjusting maximal vectorization factor to %i",
-		     *max_vf);
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf_loc (MSG_NOTE, vect_location,
+                             "adjusting maximal vectorization factor to %i",
+                             *max_vf);
 	}

       if (abs (dist) >= *max_vf)
 	{
 	  /* Dependence distance does not create dependence, as far as
 	     vectorization is concerned, in this case.  */
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
-	    fprintf (vect_dump, "dependence distance >= VF.");
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf_loc (MSG_NOTE, vect_location,
+                             "dependence distance >= VF.");
 	  continue;
 	}

-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	{
-	  fprintf (vect_dump, "not vectorized, possible dependence "
-    		              "between data-refs ");
-	  print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	  fprintf (vect_dump, " and ");
-	  print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                       "not vectorized, possible dependence "
+                       "between data-refs ");
+	  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
+	  dump_printf (MSG_NOTE,  " and ");
+	  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
 	}

       return true;
@@ -772,9 +795,9 @@ vect_analyze_data_ref_dependences (loop_vec_info l
   VEC (ddr_p, heap) *ddrs = NULL;
   struct data_dependence_relation *ddr;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_dependences ===");
-
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_analyze_dependences ===");
   if (loop_vinfo)
     ddrs = LOOP_VINFO_DDRS (loop_vinfo);
   else
@@ -814,8 +837,9 @@ vect_compute_data_ref_alignment (struct data_refer
   tree misalign;
   tree aligned_to, alignment;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_compute_data_ref_alignment:");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_compute_data_ref_alignment:");

   if (loop_vinfo)
     loop = LOOP_VINFO_LOOP (loop_vinfo);
@@ -846,16 +870,18 @@ vect_compute_data_ref_alignment (struct data_refer

       if (dr_step % GET_MODE_SIZE (TYPE_MODE (vectype)) == 0)
         {
-          if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "inner step divides the vector-size.");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+                             "inner step divides the vector-size.");
 	  misalign = STMT_VINFO_DR_INIT (stmt_info);
 	  aligned_to = STMT_VINFO_DR_ALIGNED_TO (stmt_info);
 	  base_addr = STMT_VINFO_DR_BASE_ADDRESS (stmt_info);
         }
       else
 	{
-	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "inner step doesn't divide the vector-size.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "inner step doesn't divide the vector-size.");
 	  misalign = NULL_TREE;
 	}
     }
@@ -872,8 +898,9 @@ vect_compute_data_ref_alignment (struct data_refer

       if (dr_step % GET_MODE_SIZE (TYPE_MODE (vectype)) != 0)
 	{
-	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "SLP: step doesn't divide the vector-size.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "SLP: step doesn't divide the vector-size.");
 	  misalign = NULL_TREE;
 	}
     }
@@ -884,10 +911,11 @@ vect_compute_data_ref_alignment (struct data_refer
   if ((aligned_to && tree_int_cst_compare (aligned_to, alignment) < 0)
       || !misalign)
     {
-      if (vect_print_dump_info (REPORT_ALIGNMENT))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	{
-	  fprintf (vect_dump, "Unknown alignment for access: ");
-	  print_generic_expr (vect_dump, base, TDF_SLIM);
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "Unknown alignment for access: ");
+	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, base);
 	}
       return true;
     }
@@ -913,10 +941,11 @@ vect_compute_data_ref_alignment (struct data_refer
       if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype))
 	  || (TREE_STATIC (base) && flag_section_anchors))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "can't force alignment of ref: ");
-	      print_generic_expr (vect_dump, ref, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "can't force alignment of ref: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
 	    }
 	  return true;
 	}
@@ -924,10 +953,10 @@ vect_compute_data_ref_alignment (struct data_refer
       /* Force the alignment of the decl.
 	 NOTE: This is the only change to the code we make during
 	 the analysis phase, before deciding to vectorize the loop.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "force alignment of ");
-          print_generic_expr (vect_dump, ref, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "force alignment of ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
         }

       DECL_ALIGN (base) = TYPE_ALIGN (vectype);
@@ -958,17 +987,19 @@ vect_compute_data_ref_alignment (struct data_refer
   if (!host_integerp (misalign, 1))
     {
       /* Negative or overflowed misalignment value.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "unexpected misalign value");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "unexpected misalign value");
       return false;
     }

   SET_DR_MISALIGNMENT (dr, TREE_INT_CST_LOW (misalign));

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
     {
-      fprintf (vect_dump, "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
-      print_generic_expr (vect_dump, ref, TDF_SLIM);
+      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                       "misalign = %d bytes of ref ", DR_MISALIGNMENT (dr));
+      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, ref);
     }

   return true;
@@ -1064,8 +1095,8 @@ vect_update_misalignment_for_peel (struct data_ref
       return;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "Setting misalignment to -1.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "Setting misalignment to -1.");
   SET_DR_MISALIGNMENT (dr, -1);
 }

@@ -1111,22 +1142,25 @@ vect_verify_datarefs_alignment (loop_vec_info loop
       supportable_dr_alignment = vect_supportable_dr_alignment (dr, false);
       if (!supportable_dr_alignment)
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
               if (DR_IS_READ (dr))
-                fprintf (vect_dump,
-                         "not vectorized: unsupported unaligned load.");
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "not vectorized: unsupported
unaligned load.");
               else
-                fprintf (vect_dump,
-                         "not vectorized: unsupported unaligned store.");
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "not vectorized: unsupported unaligned "
+                                 "store.");

-              print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                 DR_REF (dr));
             }
           return false;
         }
       if (supportable_dr_alignment != dr_aligned
-          && vect_print_dump_info (REPORT_ALIGNMENT))
-        fprintf (vect_dump, "Vectorizing an unaligned access.");
+          && dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "Vectorizing an unaligned access.");
     }
   return true;
 }
@@ -1181,15 +1215,18 @@ vector_alignment_reachable_p (struct data_referenc
     {
       HOST_WIDE_INT elmsize =
 		int_cst_value (TYPE_SIZE_UNIT (TREE_TYPE (vectype)));
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
 	{
-	  fprintf (vect_dump, "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
-	  fprintf (vect_dump, ". misalignment = %d. ", DR_MISALIGNMENT (dr));
+	  dump_printf_loc (MSG_NOTE, vect_location,
+                           "data size =" HOST_WIDE_INT_PRINT_DEC, elmsize);
+	  dump_printf (MSG_NOTE,
+                       ". misalignment = %d. ", DR_MISALIGNMENT (dr));
 	}
       if (DR_MISALIGNMENT (dr) % elmsize)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "data size does not divide the misalignment.\n");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "data size does not divide the misalignment.\n");
 	  return false;
 	}
     }
@@ -1198,8 +1235,9 @@ vector_alignment_reachable_p (struct data_referenc
     {
       tree type = TREE_TYPE (DR_REF (dr));
       bool is_packed = not_size_aligned (DR_REF (dr));
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Unknown misalignment, is_packed = %d",is_packed);
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "Unknown misalignment, is_packed = %d",is_packed);
       if (targetm.vectorize.vector_alignment_reachable (type, is_packed))
 	return true;
       else
@@ -1231,9 +1269,10 @@ vect_get_data_access_cost (struct data_reference *
   else
     vect_get_store_cost (dr, ncopies, inside_cost, body_cost_vec);

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_get_data_access_cost: inside_cost = %d, "
-             "outside_cost = %d.", *inside_cost, *outside_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_get_data_access_cost: inside_cost = %d, "
+                     "outside_cost = %d.", *inside_cost, *outside_cost);
 }


@@ -1528,8 +1567,9 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
   unsigned int nelements, mis, same_align_drs_max = 0;
   stmt_vector_for_cost body_cost_vec = NULL;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_enhance_data_refs_alignment ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_enhance_data_refs_alignment ===");

   /* While cost model enhancements are expected in the future, the high level
      view of the code at this time is as follows:
@@ -1582,8 +1622,9 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
 	 and so we can't generate the new base for the pointer.  */
       if (STMT_VINFO_STRIDE_LOAD_P (stmt_info))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "strided load prevents peeling");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "strided load prevents peeling");
 	  do_peeling = false;
 	  break;
 	}
@@ -1697,9 +1738,9 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
         {
           if (!aligned_access_p (dr))
             {
-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "vector alignment may not be reachable");
-
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "vector alignment may not be reachable");
               break;
             }
         }
@@ -1838,8 +1879,9 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
 	  if (STMT_VINFO_GROUPED_ACCESS (stmt_info))
 	    npeel /= GROUP_SIZE (stmt_info);

-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Try peeling by %d", npeel);
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+                             "Try peeling by %d", npeel);
         }

       /* Ensure that all data refs can be vectorized after the peel.  */
@@ -1909,12 +1951,13 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
           else
             LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo) = DR_MISALIGNMENT (dr0);
 	  SET_DR_MISALIGNMENT (dr0, 0);
-	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "Alignment of access forced using peeling.");
-
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "Peeling for alignment will be applied.");
-
+	  if (dump_kind_p (MSG_NOTE))
+            {
+              dump_printf_loc (MSG_NOTE, vect_location,
+                               "Alignment of access forced using peeling.");
+              dump_printf_loc (MSG_NOTE, vect_location,
+                               "Peeling for alignment will be applied.");
+            }
 	  /* We've delayed passing the inside-loop peeling costs to the
 	     target cost model until we were sure peeling would happen.
 	     Do so now.  */
@@ -2034,12 +2077,14 @@ vect_enhance_data_refs_alignment (loop_vec_info lo
           stmt_vec_info stmt_info = vinfo_for_stmt (stmt);
           dr = STMT_VINFO_DATA_REF (stmt_info);
 	  SET_DR_MISALIGNMENT (dr, 0);
-	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-            fprintf (vect_dump, "Alignment of access forced using
versioning.");
+	  if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+                             "Alignment of access forced using versioning.");
         }

-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Versioning for alignment will be applied.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "Versioning for alignment will be applied.");

       /* Peeling and versioning can't be done together at this time.  */
       gcc_assert (! (do_peeling && do_versioning));
@@ -2103,8 +2148,9 @@ vect_find_same_alignment_drs (struct data_dependen
     {
       int dist = dist_v[loop_depth];

-      if (vect_print_dump_info (REPORT_DR_DETAILS))
-	fprintf (vect_dump, "dependence distance  = %d.", dist);
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "dependence distance  = %d.", dist);

       /* Same loop iteration.  */
       if (dist == 0
@@ -2113,14 +2159,15 @@ vect_find_same_alignment_drs (struct data_dependen
 	  /* Two references with distance zero have the same alignment.  */
 	  VEC_safe_push (dr_p, heap, STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_a), drb);
 	  VEC_safe_push (dr_p, heap, STMT_VINFO_SAME_ALIGN_REFS (stmtinfo_b), dra);
-	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "accesses have the same alignment.");
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "dependence distance modulo vf == 0 between ");
-	      print_generic_expr (vect_dump, DR_REF (dra), TDF_SLIM);
-	      fprintf (vect_dump, " and ");
-	      print_generic_expr (vect_dump, DR_REF (drb), TDF_SLIM);
+              dump_printf_loc (MSG_NOTE, vect_location,
+                               "accesses have the same alignment.");
+	      dump_printf (MSG_NOTE,
+                           "dependence distance modulo vf == 0 between ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dra));
+	      dump_printf (MSG_NOTE,  " and ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (drb));
 	    }
 	}
     }
@@ -2136,8 +2183,9 @@ bool
 vect_analyze_data_refs_alignment (loop_vec_info loop_vinfo,
                                   bb_vec_info bb_vinfo)
 {
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_refs_alignment ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_analyze_data_refs_alignment ===");

   /* Mark groups of data references with same alignment using
      data dependence information.  */
@@ -2153,9 +2201,10 @@ vect_analyze_data_refs_alignment (loop_vec_info lo

   if (!vect_compute_data_refs_alignment (loop_vinfo, bb_vinfo))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	fprintf (vect_dump,
-		 "not vectorized: can't calculate alignment for data ref.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not vectorized: can't calculate alignment "
+                         "for data ref.");
       return false;
     }

@@ -2205,24 +2254,27 @@ vect_analyze_group_access (struct data_reference *
 	{
 	  GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = stmt;
 	  GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
-	  if (vect_print_dump_info (REPORT_DR_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "Detected single element interleaving ");
-	      print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
-	      fprintf (vect_dump, " step ");
-	      print_generic_expr (vect_dump, step, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "Detected single element interleaving ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (dr));
+	      dump_printf (MSG_NOTE, " step ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, step);
 	    }

 	  if (loop_vinfo)
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "Data access with gaps requires scalar "
-				    "epilogue loop");
+	      if (dump_kind_p (MSG_NOTE))
+		dump_printf_loc (MSG_NOTE, vect_location,
+                                 "Data access with gaps requires scalar "
+                                 "epilogue loop");
               if (loop->inner)
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Peeling for outer loop is not"
-                                        " supported");
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                     "Peeling for outer loop is not"
+                                     " supported");
                   return false;
                 }

@@ -2232,10 +2284,11 @@ vect_analyze_group_access (struct data_reference *
 	  return true;
 	}

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
- 	  fprintf (vect_dump, "not consecutive access ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+ 	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "not consecutive access ");
+          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }

       if (bb_vinfo)
@@ -2244,7 +2297,7 @@ vect_analyze_group_access (struct data_reference *
           STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) = false;
           return true;
         }
-
+
       return false;
     }

@@ -2271,8 +2324,9 @@ vect_analyze_group_access (struct data_reference *
             {
               if (DR_IS_WRITE (data_ref))
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "Two store stmts share the same dr.");
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                     "Two store stmts share the same dr.");
                   return false;
                 }

@@ -2281,9 +2335,9 @@ vect_analyze_group_access (struct data_reference *
               if (GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (next))
                   || GROUP_READ_WRITE_DEPENDENCE (vinfo_for_stmt (prev)))
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump,
-                             "READ_WRITE dependence in interleaving.");
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                     "READ_WRITE dependence in interleaving.");
                   return false;
                 }

@@ -2301,8 +2355,9 @@ vect_analyze_group_access (struct data_reference *
           next_step = DR_STEP (STMT_VINFO_DATA_REF (vinfo_for_stmt (next)));
           if (tree_int_cst_compare (step, next_step))
             {
-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "not consecutive access in interleaving");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "not consecutive access in interleaving");
               return false;
             }

@@ -2317,8 +2372,9 @@ vect_analyze_group_access (struct data_reference *
 	      slp_impossible = true;
 	      if (DR_IS_WRITE (data_ref))
 		{
-		  if (vect_print_dump_info (REPORT_DETAILS))
-		    fprintf (vect_dump, "interleaved store with gaps");
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                     "interleaved store with gaps");
 		  return false;
 		}

@@ -2345,10 +2401,11 @@ vect_analyze_group_access (struct data_reference *
          greater than STEP.  */
       if (dr_step && dr_step < count_in_bytes + gaps * type_size)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "interleaving size is greater than
step for ");
-              print_generic_expr (vect_dump, DR_REF (dr), TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "interleaving size is greater than step for ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
DR_REF (dr));
             }
           return false;
         }
@@ -2367,8 +2424,9 @@ vect_analyze_group_access (struct data_reference *
             }
           else
             {
-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "interleaved store with gaps");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "interleaved store with gaps");
               return false;
             }
         }
@@ -2376,13 +2434,14 @@ vect_analyze_group_access (struct data_reference *
       /* Check that STEP is a multiple of type size.  */
       if (dr_step && (dr_step % type_size) != 0)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "step is not a multiple of type
size: step ");
-              print_generic_expr (vect_dump, step, TDF_SLIM);
-              fprintf (vect_dump, " size ");
-              print_generic_expr (vect_dump, TYPE_SIZE_UNIT (scalar_type),
-                                  TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "step is not a multiple of type size: step ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, step);
+              dump_printf (MSG_MISSED_OPTIMIZATION, " size ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                 TYPE_SIZE_UNIT (scalar_type));
             }
           return false;
         }
@@ -2391,8 +2450,9 @@ vect_analyze_group_access (struct data_reference *
         groupsize = count;

       GROUP_SIZE (vinfo_for_stmt (stmt)) = groupsize;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Detected interleaving of size %d",
(int)groupsize);
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "Detected interleaving of size %d", (int)groupsize);

       /* SLP: create an SLP data structure for every interleaving group of
 	 stores for further analysis in vect_analyse_slp.  */
@@ -2409,13 +2469,15 @@ vect_analyze_group_access (struct data_reference *
       /* There is a gap in the end of the group.  */
       if (groupsize - last_accessed_element > 0 && loop_vinfo)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "Data access with gaps requires scalar "
-				"epilogue loop");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "Data access with gaps requires scalar "
+                             "epilogue loop");
           if (loop->inner)
             {
-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Peeling for outer loop is not supported");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "Peeling for outer loop is not supported");
               return false;
             }

@@ -2446,8 +2508,9 @@ vect_analyze_data_ref_access (struct data_referenc

   if (loop_vinfo && !step)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "bad data-ref access in loop");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "bad data-ref access in loop");
       return false;
     }

@@ -2468,8 +2531,9 @@ vect_analyze_data_ref_access (struct data_referenc
       step = STMT_VINFO_DR_STEP (stmt_info);
       if (integer_zerop (step))
 	{
-	  if (vect_print_dump_info (REPORT_ALIGNMENT))
-	    fprintf (vect_dump, "zero step in outer loop.");
+	  if (dump_kind_p (MSG_NOTE))
+	    dump_printf_loc (MSG_NOTE, vect_location,
+                             "zero step in outer loop.");
 	  if (DR_IS_READ (dr))
   	    return true;
 	  else
@@ -2493,8 +2557,9 @@ vect_analyze_data_ref_access (struct data_referenc

   if (loop && nested_in_vect_loop_p (loop, stmt))
     {
-      if (vect_print_dump_info (REPORT_ALIGNMENT))
-	fprintf (vect_dump, "grouped access in outer loop.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "grouped access in outer loop.");
       return false;
     }

@@ -2523,8 +2588,9 @@ vect_analyze_data_ref_accesses (loop_vec_info loop
   VEC (data_reference_p, heap) *datarefs;
   struct data_reference *dr;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_ref_accesses ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_analyze_data_ref_accesses ===");

   if (loop_vinfo)
     datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
@@ -2535,8 +2601,9 @@ vect_analyze_data_ref_accesses (loop_vec_info loop
     if (STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr)))
         && !vect_analyze_data_ref_access (dr))
       {
-	if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	  fprintf (vect_dump, "not vectorized: complicated access pattern.");
+	if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "not vectorized: complicated access pattern.");

         if (bb_vinfo)
           {
@@ -2564,8 +2631,9 @@ vect_prune_runtime_alias_test_list (loop_vec_info
     LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo);
   unsigned i, j;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_prune_runtime_alias_test_list ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_prune_runtime_alias_test_list ===");

   for (i = 0; i < VEC_length (ddr_p, ddrs); )
     {
@@ -2581,16 +2649,17 @@ vect_prune_runtime_alias_test_list (loop_vec_info

 	  if (vect_vfa_range_equal (ddr_i, ddr_j))
 	    {
-	      if (vect_print_dump_info (REPORT_DR_DETAILS))
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (vect_dump, "found equal ranges ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr_i)), TDF_SLIM);
-		  fprintf (vect_dump, ", ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr_i)), TDF_SLIM);
-		  fprintf (vect_dump, " and ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_A (ddr_j)), TDF_SLIM);
-		  fprintf (vect_dump, ", ");
-		  print_generic_expr (vect_dump, DR_REF (DDR_B (ddr_j)), TDF_SLIM);
+		  dump_printf_loc (MSG_NOTE, vect_location,
+                                   "found equal ranges ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr_i)));
+		  dump_printf (MSG_NOTE,  ", ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_B (ddr_i)));
+		  dump_printf (MSG_NOTE,  " and ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_A (ddr_j)));
+		  dump_printf (MSG_NOTE,  ", ");
+		  dump_generic_expr (MSG_NOTE, TDF_SLIM, DR_REF (DDR_B (ddr_j)));
 		}
 	      found = true;
 	      break;
@@ -2608,11 +2677,11 @@ vect_prune_runtime_alias_test_list (loop_vec_info
   if (VEC_length (ddr_p, ddrs) >
        (unsigned) PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS))
     {
-      if (vect_print_dump_info (REPORT_DR_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	{
-	  fprintf (vect_dump,
-		   "disable versioning for alias - max number of generated "
-		   "checks exceeded.");
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION,  vect_location,
+                           "disable versioning for alias - max number of "
+                           "generated checks exceeded.");
 	}

       VEC_truncate (ddr_p, LOOP_VINFO_MAY_ALIAS_DDRS (loop_vinfo), 0);
@@ -2895,8 +2964,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
   tree scalar_type;
   bool res, stop_bb_analysis = false;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_analyze_data_refs ===\n");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_analyze_data_refs ===\n");

   if (loop_vinfo)
     {
@@ -2909,9 +2979,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

       if (!res)
 	{
-	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: loop contains function calls"
-		     " or data references that cannot be analyzed");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "not vectorized: loop contains function calls"
+                             " or data references that cannot be analyzed");
 	  return false;
 	}

@@ -2940,9 +3011,11 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (!compute_all_dependences (BB_VINFO_DATAREFS (bb_vinfo),
 				    &BB_VINFO_DDRS (bb_vinfo), NULL, true))
 	{
-	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: basic block contains function"
-		     " calls or data references that cannot be analyzed");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "not vectorized: basic block contains function"
+                             " calls or data references that cannot be"
+                             " analyzed");
 	  return false;
 	}

@@ -2962,9 +3035,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

       if (!dr || !DR_REF (dr))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	    fprintf (vect_dump, "not vectorized: unhandled data-ref ");
-
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "not vectorized: unhandled data-ref ");
           return false;
         }

@@ -3008,11 +3081,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

 	  if (!gather)
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump, "not vectorized: data ref analysis "
-				      "failed ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: data ref analysis "
+                                   "failed ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}

 	      if (bb_vinfo)
@@ -3028,9 +3102,10 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

       if (TREE_CODE (DR_BASE_ADDRESS (dr)) == INTEGER_CST)
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-            fprintf (vect_dump, "not vectorized: base addr of dr is a "
-                     "constant");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "not vectorized: base addr of dr is a "
+                             "constant");

           if (bb_vinfo)
             {
@@ -3046,10 +3121,11 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

       if (TREE_THIS_VOLATILE (DR_REF (dr)))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "not vectorized: volatile type ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "not vectorized: volatile type ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

           if (bb_vinfo)
@@ -3064,11 +3140,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

       if (stmt_can_throw_internal (stmt))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "not vectorized: statement can throw an "
-                       "exception ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "not vectorized: statement can throw an "
+                               "exception ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

           if (bb_vinfo)
@@ -3086,11 +3163,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
       if (TREE_CODE (DR_REF (dr)) == COMPONENT_REF
 	  && DECL_BIT_FIELD (TREE_OPERAND (DR_REF (dr), 1)))
 	{
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "not vectorized: statement is bitfield "
-                       "access ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "not vectorized: statement is bitfield "
+                               "access ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

           if (bb_vinfo)
@@ -3111,10 +3189,11 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

       if (is_gimple_call (stmt))
 	{
-	  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	    {
-	      fprintf (vect_dump, "not vectorized: dr in a call ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION,  vect_location,
+                               "not vectorized: dr in a call ");
+	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 	    }

 	  if (bb_vinfo)
@@ -3153,10 +3232,11 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
           tree inner_base = build_fold_indirect_ref
                                 (fold_build_pointer_plus (base, init));

-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "analyze in outer-loop: ");
-	      print_generic_expr (vect_dump, inner_base, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "analyze in outer-loop: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM, inner_base);
 	    }

 	  outer_base = get_inner_reference (inner_base, &pbitsize, &pbitpos,
@@ -3165,8 +3245,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

 	  if (pbitpos % BITS_PER_UNIT != 0)
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "failed: bit offset alignment.\n");
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "failed: bit offset alignment.\n");
 	      return false;
 	    }

@@ -3174,8 +3255,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	  if (!simple_iv (loop, loop_containing_stmt (stmt), outer_base,
                           &base_iv, false))
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "failed: evolution of base is not affine.\n");
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "failed: evolution of base is not affine.\n");
 	      return false;
 	    }

@@ -3196,8 +3278,9 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	  else if (!simple_iv (loop, loop_containing_stmt (stmt), poffset,
                                &offset_iv, false))
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-	        fprintf (vect_dump, "evolution of offset is not affine.\n");
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "evolution of offset is not affine.\n");
 	      return false;
 	    }

@@ -3220,28 +3303,36 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	  STMT_VINFO_DR_ALIGNED_TO (stmt_info) =
 				size_int (highest_pow2_factor (offset_iv.base));

-	  if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "\touter base_address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_BASE_ADDRESS
(stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter offset from base address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_OFFSET
(stmt_info), TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter constant offset from base address: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_INIT (stmt_info),
TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter step: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_STEP (stmt_info),
TDF_SLIM);
-	      fprintf (vect_dump, "\n\touter aligned to: ");
-	      print_generic_expr (vect_dump, STMT_VINFO_DR_ALIGNED_TO
(stmt_info), TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location,
+                               "\touter base_address: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
+                                 STMT_VINFO_DR_BASE_ADDRESS (stmt_info));
+	      dump_printf (MSG_NOTE, "\n\touter offset from base address: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
+                                 STMT_VINFO_DR_OFFSET (stmt_info));
+	      dump_printf (MSG_NOTE,
+                           "\n\touter constant offset from base address: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
+                                 STMT_VINFO_DR_INIT (stmt_info));
+	      dump_printf (MSG_NOTE, "\n\touter step: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
+                                 STMT_VINFO_DR_STEP (stmt_info));
+	      dump_printf (MSG_NOTE, "\n\touter aligned to: ");
+	      dump_generic_expr (MSG_NOTE, TDF_SLIM,
+                                 STMT_VINFO_DR_ALIGNED_TO (stmt_info));
 	    }
 	}

       if (STMT_VINFO_DATA_REF (stmt_info))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump,
-                       "not vectorized: more than one data ref in stmt: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "not vectorized: more than one data ref "
+                               "in stmt: ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

           if (bb_vinfo)
@@ -3264,13 +3355,14 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
                 get_vectype_for_scalar_type (scalar_type);
       if (!STMT_VINFO_VECTYPE (stmt_info))
         {
-          if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump,
-                       "not vectorized: no vectype for stmt: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
-              fprintf (vect_dump, " scalar_type: ");
-              print_generic_expr (vect_dump, scalar_type, TDF_DETAILS);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                               "not vectorized: no vectype for stmt: ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
+              dump_printf (MSG_MISSED_OPTIMIZATION, " scalar_type: ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_DETAILS,
+                                 scalar_type);
             }

           if (bb_vinfo)
@@ -3314,11 +3406,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	    {
 	      STMT_VINFO_DATA_REF (stmt_info) = NULL;
 	      free_data_ref (dr);
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: not suitable for gather load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: not suitable for gather "
+                                   "load ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3366,12 +3459,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,

 	  if (bad)
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: data dependence conflict"
-			   " prevents gather load");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: data dependence conflict"
+                                   " prevents gather load");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3387,11 +3480,12 @@ vect_analyze_data_refs (loop_vec_info loop_vinfo,
 	      = vect_check_strided_load (stmt, loop_vinfo, NULL, NULL);
 	  if (!strided_load)
 	    {
-	      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "not vectorized: not suitable for strided load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "not vectorized: not suitable for strided "
+                                   "load ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}
 	      return false;
 	    }
@@ -3574,10 +3668,10 @@ vect_create_addr_base_for_vector_ref (gimple stmt,
 	mark_ptr_info_alignment_unknown (SSA_NAME_PTR_INFO (vec_stmt));
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "created ");
-      print_generic_expr (vect_dump, vec_stmt, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location, "created ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, vec_stmt);
     }

   return vec_stmt;
@@ -3696,20 +3790,21 @@ vect_create_data_ref_ptr (gimple stmt, tree aggr_t
      in LOOP.  */
   base_name = build_fold_indirect_ref (unshare_expr (DR_BASE_ADDRESS (dr)));

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
       tree data_ref_base = base_name;
-      fprintf (vect_dump, "create %s-pointer variable to type: ",
-	       tree_code_name[(int) TREE_CODE (aggr_type)]);
-      print_generic_expr (vect_dump, aggr_type, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+                       "create %s-pointer variable to type: ",
+                       tree_code_name[(int) TREE_CODE (aggr_type)]);
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, aggr_type);
       if (TREE_CODE (data_ref_base) == VAR_DECL
           || TREE_CODE (data_ref_base) == ARRAY_REF)
-        fprintf (vect_dump, "  vectorizing an array ref: ");
+        dump_printf (MSG_NOTE, "  vectorizing an array ref: ");
       else if (TREE_CODE (data_ref_base) == COMPONENT_REF)
-        fprintf (vect_dump, "  vectorizing a record based array ref: ");
+        dump_printf (MSG_NOTE, "  vectorizing a record based array ref: ");
       else if (TREE_CODE (data_ref_base) == SSA_NAME)
-        fprintf (vect_dump, "  vectorizing a pointer ref: ");
-      print_generic_expr (vect_dump, base_name, TDF_SLIM);
+        dump_printf (MSG_NOTE, "  vectorizing a pointer ref: ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, base_name);
     }

   /* (1) Create the new aggregate-pointer variable.  */
@@ -4025,9 +4120,10 @@ vect_grouped_store_supported (tree vectype, unsign
   /* vect_permute_store_chain requires the group size to be a power of two.  */
   if (exact_log2 (count) == -1)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "the size of the group of accesses"
-		 " is not a power of 2");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "the size of the group of accesses"
+                         " is not a power of 2");
       return false;
     }

@@ -4050,8 +4146,9 @@ vect_grouped_store_supported (tree vectype, unsign
 	}
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "interleave op not supported by target.");
+  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+    dump_printf (MSG_MISSED_OPTIMIZATION,
+                 "interleave op not supported by target.");
   return false;
 }

@@ -4467,9 +4564,10 @@ vect_grouped_load_supported (tree vectype, unsigne
   /* vect_permute_load_chain requires the group size to be a power of two.  */
   if (exact_log2 (count) == -1)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "the size of the group of accesses"
-		 " is not a power of 2");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "the size of the group of accesses"
+                         " is not a power of 2");
       return false;
     }

@@ -4490,8 +4588,9 @@ vect_grouped_load_supported (tree vectype, unsigne
 	}
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "extract even/odd not supported by target");
+  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                     "extract even/odd not supported by target");
   return false;
 }

Index: common.opt
===================================================================
--- common.opt	(revision 191208)
+++ common.opt	(working copy)
@@ -138,9 +138,6 @@ bool use_gnu_debug_info_extensions
 Variable
 unsigned int initial_max_fld_align = TARGET_DEFAULT_PACK_STRUCT

-Variable
-enum vect_verbosity_levels user_vect_verbosity_level = MAX_VERBOSITY_LEVEL
-
 ; Type of stack check.
 Variable
 enum stack_check_type flag_stack_check = NO_STACK_CHECK
@@ -1525,6 +1522,10 @@ fomit-frame-pointer
 Common Report Var(flag_omit_frame_pointer) Optimization
 When possible do not generate stack frames

+fopt-info-
+Common Joined RejectNegative Var(common_deferred_options) Defer
+-fopt-info-<type>	Dump various compiler optimization details to stderr
+
 foptimize-register-move
 Common Report Var(flag_regmove) Optimization
 Do the full register move optimization pass
@@ -2184,6 +2185,10 @@ ftree-vectorize
 Common Report Var(flag_tree_vectorize) Optimization
 Enable loop vectorization on trees

+ftree-vectorizer-verbose=
+Common RejectNegative Joined UInteger Var(common_deferred_options) Defer
+-ftree-vectorizer-verbose=<number>	This switch is deprecated. Use
-fopt_info instead.
+
 ftree-slp-vectorize
 Common Report Var(flag_tree_slp_vectorize) Init(2) Optimization
 Enable basic block vectorization (SLP) on trees
@@ -2196,10 +2201,6 @@ ftree-vect-loop-version
 Common Report Var(flag_tree_vect_loop_version) Init(1) Optimization
 Enable loop versioning when doing loop vectorization on trees

-ftree-vectorizer-verbose=
-Common RejectNegative Joined UInteger
--ftree-vectorizer-verbose=<number>	Set the verbosity level of the vectorizer
-
 ftree-scev-cprop
 Common Report Var(flag_tree_scev_cprop) Init(1) Optimization
 Enable copy propagation of scalar-evolution information.
Index: tree-vect-patterns.c
===================================================================
--- tree-vect-patterns.c	(revision 191208)
+++ tree-vect-patterns.c	(working copy)
@@ -416,10 +416,11 @@ vect_recog_dot_prod_pattern (VEC (gimple, heap) **
   pattern_stmt = gimple_build_assign_with_ops3 (DOT_PROD_EXPR, var,
 						oprnd00, oprnd01, oprnd1);

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
     {
-      fprintf (vect_dump, "vect_recog_dot_prod_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                       "vect_recog_dot_prod_pattern: detected: ");
+      dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, pattern_stmt, 0);
     }

   /* We don't allow changing the order of the computation in the inner-loop
@@ -675,8 +676,9 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap)
     return NULL;

   /* Pattern detected.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_widen_mult_pattern: detected: ");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "vect_recog_widen_mult_pattern: detected: ");

   /* Check target support  */
   vectype = get_vectype_for_scalar_type (half_type0);
@@ -697,8 +699,8 @@ vect_recog_widen_mult_pattern (VEC (gimple, heap)
   pattern_stmt = gimple_build_assign_with_ops (WIDEN_MULT_EXPR, var, oprnd0,
 					       oprnd1);

-  if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+  if (dump_kind_p (MSG_NOTE))
+    dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);

   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -910,10 +912,11 @@ vect_recog_widen_sum_pattern (VEC (gimple, heap) *
   pattern_stmt = gimple_build_assign_with_ops (WIDEN_SUM_EXPR, var,
 					       oprnd0, oprnd1);

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
     {
-      fprintf (vect_dump, "vect_recog_widen_sum_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                       "vect_recog_widen_sum_pattern: detected: ");
+      dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, pattern_stmt, 0);
     }

   /* We don't allow changing the order of the computation in the inner-loop
@@ -1214,10 +1217,11 @@ vect_recog_over_widening_pattern (VEC (gimple, hea
       STMT_VINFO_RELATED_STMT (vinfo_for_stmt (stmt)) = pattern_stmt;
       new_pattern_def_seq (vinfo_for_stmt (stmt), new_def_stmt);

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
         {
-          fprintf (vect_dump, "created pattern stmt: ");
-          print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                           "created pattern stmt: ");
+          dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM,
pattern_stmt, 0);
         }

       type = gimple_expr_type (stmt);
@@ -1281,10 +1285,11 @@ vect_recog_over_widening_pattern (VEC (gimple, hea
     return NULL;

   /* Pattern detected.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
     {
-      fprintf (vect_dump, "vect_recog_over_widening_pattern: detected: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                       "vect_recog_over_widening_pattern: detected: ");
+      dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, pattern_stmt, 0);
     }

   return pattern_stmt;
@@ -1416,8 +1421,9 @@ vect_recog_widen_shift_pattern (VEC (gimple, heap)
     return NULL;

   /* Pattern detected.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_widen_shift_pattern: detected: ");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "vect_recog_widen_shift_pattern: detected: ");

   /* Check target support.  */
   vectype = get_vectype_for_scalar_type (half_type0);
@@ -1439,8 +1445,8 @@ vect_recog_widen_shift_pattern (VEC (gimple, heap)
   pattern_stmt =
     gimple_build_assign_with_ops (WIDEN_LSHIFT_EXPR, var, oprnd0, oprnd1);

-  if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+  if (dump_kind_p (MSG_NOTE))
+    dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);

   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -1561,15 +1567,16 @@ vect_recog_vector_vector_shift_pattern (VEC (gimpl
     }

   /* Pattern detected.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_vector_vector_shift_pattern: detected: ");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "vect_recog_vector_vector_shift_pattern: detected: ");

   /* Pattern supported.  Create a stmt to be used to replace the pattern.  */
   var = vect_recog_temp_ssa_var (TREE_TYPE (oprnd0), NULL);
   pattern_stmt = gimple_build_assign_with_ops (rhs_code, var, oprnd0, def);

-  if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+  if (dump_kind_p (MSG_NOTE))
+    dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt, 0);

   VEC_safe_push (gimple, heap, *stmts, last_stmt);
   return pattern_stmt;
@@ -1678,8 +1685,9 @@ vect_recog_divmod_pattern (VEC (gimple, heap) **st
 	return NULL;

       /* Pattern detected.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_divmod_pattern: detected: ");
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+        dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                         "vect_recog_divmod_pattern: detected: ");

       cond = build2 (LT_EXPR, boolean_type_node, oprnd0,
 		     build_int_cst (itype, 0));
@@ -1781,8 +1789,9 @@ vect_recog_divmod_pattern (VEC (gimple, heap) **st
 					    signmask);
 	}

-      if (vect_print_dump_info (REPORT_DETAILS))
-	print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      if (dump_kind_p (MSG_NOTE))
+	dump_gimple_stmt_loc (MSG_NOTE, vect_location, TDF_SLIM, pattern_stmt,
+                              0);

       VEC_safe_push (gimple, heap, *stmts, last_stmt);

@@ -2022,12 +2031,13 @@ vect_recog_divmod_pattern (VEC (gimple, heap) **st
     }

   /* Pattern detected.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_divmod_pattern: detected: ");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    {
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                       "vect_recog_divmod_pattern: detected: ");
+      dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, pattern_stmt, 0);
+    }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
-
   VEC_safe_push (gimple, heap, *stmts, last_stmt);

   *type_in = vectype;
@@ -2189,8 +2199,9 @@ vect_recog_mixed_size_cond_pattern (VEC (gimple, h
   *type_in = vecitype;
   *type_out = vectype;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "vect_recog_mixed_size_cond_pattern: detected: ");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                     "vect_recog_mixed_size_cond_pattern: detected: ");

   return pattern_stmt;
 }
@@ -2581,8 +2592,9 @@ vect_recog_bool_pattern (VEC (gimple, heap) **stmt
       *type_out = vectype;
       *type_in = vectype;
       VEC_safe_push (gimple, heap, *stmts, last_stmt);
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_bool_pattern: detected: ");
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+	dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                         "vect_recog_bool_pattern: detected: ");

       return pattern_stmt;
     }
@@ -2626,8 +2638,9 @@ vect_recog_bool_pattern (VEC (gimple, heap) **stmt
       *type_out = vectype;
       *type_in = vectype;
       VEC_safe_push (gimple, heap, *stmts, last_stmt);
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "vect_recog_bool_pattern: detected: ");
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+	dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                         "vect_recog_bool_pattern: detected: ");
       return pattern_stmt;
     }
   else
@@ -2775,10 +2788,11 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
     }

   /* Found a vectorizable pattern.  */
-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
     {
-      fprintf (vect_dump, "pattern recognized: ");
-      print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                       "pattern recognized: ");
+      dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, pattern_stmt, 0);
     }

   /* Mark the stmts that are involved in the pattern. */
@@ -2800,10 +2814,11 @@ vect_pattern_recog_1 (vect_recog_func_ptr vect_rec
     {
       stmt_info = vinfo_for_stmt (stmt);
       pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
         {
-          fprintf (vect_dump, "additional pattern stmt: ");
-          print_gimple_stmt (vect_dump, pattern_stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                           "additional pattern stmt: ");
+          dump_gimple_stmt (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM,
pattern_stmt, 0);
         }

       vect_mark_pattern_stmts (stmt, pattern_stmt, NULL_TREE);
@@ -2900,8 +2915,9 @@ vect_pattern_recog (loop_vec_info loop_vinfo, bb_v
   VEC (gimple, heap) *stmts_to_replace = VEC_alloc (gimple, heap, 1);
   gimple stmt;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_pattern_recog ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_pattern_recog ===");

   if (loop_vinfo)
     {
Index: rtl.h
===================================================================
--- rtl.h	(revision 191208)
+++ rtl.h	(working copy)
@@ -2484,8 +2484,8 @@ extern bool validate_subreg (enum machine_mode, en
 /* In combine.c  */
 extern unsigned int extended_count (const_rtx, enum machine_mode, int);
 extern rtx remove_death (unsigned int, rtx);
-extern void dump_combine_stats (FILE *);
-extern void dump_combine_total_stats (FILE *);
+extern void debug_combine_stats (FILE *);
+extern void print_combine_total_stats (FILE *);
 extern rtx make_compound_operation (rtx, enum rtx_code);

 /* In cfgcleanup.c  */
Index: tree-vect-stmts.c
===================================================================
--- tree-vect-stmts.c	(revision 191208)
+++ tree-vect-stmts.c	(working copy)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -189,8 +190,9 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
   bool save_live_p = STMT_VINFO_LIVE_P (stmt_info);
   gimple pattern_stmt;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "mark relevant %d, live %d.", relevant, live_p);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "mark relevant %d, live %d.", relevant, live_p);

   /* If this stmt is an original stmt in a pattern, we might need to mark its
      related pattern stmt instead of the original stmt.  However, such stmts
@@ -244,9 +246,10 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g

           pattern_stmt = STMT_VINFO_RELATED_STMT (stmt_info);

-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "last stmt in pattern. don't mark"
-                                " relevant/live.");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+                             "last stmt in pattern. don't mark"
+                             " relevant/live.");
           stmt_info = vinfo_for_stmt (pattern_stmt);
           gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == stmt);
           save_relevant = STMT_VINFO_RELEVANT (stmt_info);
@@ -262,8 +265,9 @@ vect_mark_relevant (VEC(gimple,heap) **worklist, g
   if (STMT_VINFO_RELEVANT (stmt_info) == save_relevant
       && STMT_VINFO_LIVE_P (stmt_info) == save_live_p)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "already marked relevant/live.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "already marked relevant/live.");
       return;
     }

@@ -306,8 +310,9 @@ vect_stmt_relevant_p (gimple stmt, loop_vec_info l
   if (gimple_code (stmt) != GIMPLE_PHI)
     if (gimple_vdef (stmt))
       {
-	if (vect_print_dump_info (REPORT_DETAILS))
-	  fprintf (vect_dump, "vec_stmt_relevant_p: stmt has vdefs.");
+	if (dump_kind_p (MSG_NOTE))
+	  dump_printf_loc (MSG_NOTE, vect_location,
+                           "vec_stmt_relevant_p: stmt has vdefs.");
 	*relevant = vect_used_in_scope;
       }

@@ -319,8 +324,9 @@ vect_stmt_relevant_p (gimple stmt, loop_vec_info l
 	  basic_block bb = gimple_bb (USE_STMT (use_p));
 	  if (!flow_bb_inside_loop_p (loop, bb))
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "vec_stmt_relevant_p: used out of loop.");
+	      if (dump_kind_p (MSG_NOTE))
+		dump_printf_loc (MSG_NOTE, vect_location,
+                                 "vec_stmt_relevant_p: used out of loop.");

 	      if (is_gimple_debug (USE_STMT (use_p)))
 		continue;
@@ -431,8 +437,9 @@ process_use (gimple stmt, tree use, loop_vec_info

   if (!vect_is_simple_use (use, stmt, loop_vinfo, NULL, &def_stmt, &def, &dt))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported use in stmt.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not vectorized: unsupported use in stmt.");
       return false;
     }

@@ -442,8 +449,8 @@ process_use (gimple stmt, tree use, loop_vec_info
   def_bb = gimple_bb (def_stmt);
   if (!flow_bb_inside_loop_p (loop, def_bb))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "def_stmt is out of loop.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location, "def_stmt is out of loop.");
       return true;
     }

@@ -460,8 +467,9 @@ process_use (gimple stmt, tree use, loop_vec_info
       && STMT_VINFO_DEF_TYPE (dstmt_vinfo) == vect_reduction_def
       && bb->loop_father == def_bb->loop_father)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "reduc-stmt defining reduc-phi in the same nest.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "reduc-stmt defining reduc-phi in the same nest.");
       if (STMT_VINFO_IN_PATTERN_P (dstmt_vinfo))
 	dstmt_vinfo = vinfo_for_stmt (STMT_VINFO_RELATED_STMT (dstmt_vinfo));
       gcc_assert (STMT_VINFO_RELEVANT (dstmt_vinfo) < vect_used_by_reduction);
@@ -479,8 +487,9 @@ process_use (gimple stmt, tree use, loop_vec_info
 		...		  */
   if (flow_loop_nested_p (def_bb->loop_father, bb->loop_father))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "outer-loop def-stmt defining inner-loop stmt.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "outer-loop def-stmt defining inner-loop stmt.");

       switch (relevant)
 	{
@@ -516,8 +525,9 @@ process_use (gimple stmt, tree use, loop_vec_info
 		stmt # use (d)		*/
   else if (flow_loop_nested_p (bb->loop_father, def_bb->loop_father))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "inner-loop def-stmt defining outer-loop stmt.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "inner-loop def-stmt defining outer-loop stmt.");

       switch (relevant)
         {
@@ -579,8 +589,9 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
   enum vect_relevant relevant, tmp_relevant;
   enum vect_def_type def_type;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "=== vect_mark_stmts_to_be_vectorized ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "=== vect_mark_stmts_to_be_vectorized ===");

   worklist = VEC_alloc (gimple, heap, 64);

@@ -591,10 +602,10 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
       for (si = gsi_start_phis (bb); !gsi_end_p (si); gsi_next (&si))
 	{
 	  phi = gsi_stmt (si);
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "init: phi relevant? ");
-	      print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location, "init: phi relevant? ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
 	    }

 	  if (vect_stmt_relevant_p (phi, loop_vinfo, &relevant, &live_p))
@@ -603,10 +614,10 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
       for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
 	{
 	  stmt = gsi_stmt (si);
-	  if (vect_print_dump_info (REPORT_DETAILS))
+	  if (dump_kind_p (MSG_NOTE))
 	    {
-	      fprintf (vect_dump, "init: stmt relevant? ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_NOTE, vect_location, "init: stmt relevant? ");
+	      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	    }

 	  if (vect_stmt_relevant_p (stmt, loop_vinfo, &relevant, &live_p))
@@ -621,10 +632,10 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
       ssa_op_iter iter;

       stmt = VEC_pop (gimple, worklist);
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
 	{
-          fprintf (vect_dump, "worklist: examine stmt: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "worklist:
examine stmt: ");
+          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}

       /* Examine the USEs of STMT. For each USE, mark the stmt that defines it
@@ -666,9 +677,9 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
   	          /* fall through */

 	        default:
-	          if (vect_print_dump_info (REPORT_DETAILS))
-	            fprintf (vect_dump, "unsupported use of reduction.");
-
+	          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                     "unsupported use of reduction.");
   	          VEC_free (gimple, heap, worklist);
 	          return false;
 	      }
@@ -681,8 +692,9 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
                 && tmp_relevant != vect_used_in_outer_by_reduction
                 && tmp_relevant != vect_used_in_outer)
               {
-                if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported use of nested cycle.");
+                if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "unsupported use of nested cycle.");

                 VEC_free (gimple, heap, worklist);
                 return false;
@@ -695,8 +707,9 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info lo
             if (tmp_relevant != vect_unused_in_scope
                 && tmp_relevant != vect_used_by_reduction)
               {
-                if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported use of double reduction.");
+                if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                   "unsupported use of double reduction.");

                 VEC_free (gimple, heap, worklist);
                 return false;
@@ -817,9 +830,10 @@ vect_model_simple_cost (stmt_vec_info stmt_info, i
   inside_cost = record_stmt_cost (body_cost_vec, ncopies, vector_stmt,
 				  stmt_info, 0, vect_body);

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_simple_cost: inside_cost = %d, "
-             "prologue_cost = %d .", inside_cost, prologue_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_model_simple_cost: inside_cost = %d, "
+                     "prologue_cost = %d .", inside_cost, prologue_cost);
 }


@@ -862,9 +876,10 @@ vect_model_promotion_demotion_cost (stmt_vec_info
       prologue_cost += add_stmt_cost (target_cost_data, 1, vector_stmt,
 				      stmt_info, 0, vect_prologue);

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_promotion_demotion_cost:
inside_cost = %d, "
-             "prologue_cost = %d .", inside_cost, prologue_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_model_promotion_demotion_cost: inside_cost = %d, "
+                     "prologue_cost = %d .", inside_cost, prologue_cost);
 }

 /* Function vect_cost_group_size
@@ -945,17 +960,19 @@ vect_model_store_cost (stmt_vec_info stmt_info, in
       inside_cost = record_stmt_cost (body_cost_vec, nstmts, vec_perm,
 				      stmt_info, 0, vect_body);

-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "vect_model_store_cost: strided group_size = %d .",
-                 group_size);
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "vect_model_store_cost: strided group_size = %d .",
+                         group_size);
     }

   /* Costs of the stores.  */
   vect_get_store_cost (first_dr, ncopies, &inside_cost, body_cost_vec);

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_store_cost: inside_cost = %d, "
-             "prologue_cost = %d .", inside_cost, prologue_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_model_store_cost: inside_cost = %d, "
+                     "prologue_cost = %d .", inside_cost, prologue_cost);
 }


@@ -977,9 +994,9 @@ vect_get_store_cost (struct data_reference *dr, in
 					  vector_store, stmt_info, 0,
 					  vect_body);

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: aligned.");
-
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_store_cost: aligned.");
         break;
       }

@@ -989,11 +1006,10 @@ vect_get_store_cost (struct data_reference *dr, in
 	*inside_cost += record_stmt_cost (body_cost_vec, ncopies,
 					  unaligned_store, stmt_info,
 					  DR_MISALIGNMENT (dr), vect_body);
-
-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: unaligned supported by "
-                   "hardware.");
-
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_store_cost: unaligned supported by "
+                           "hardware.");
         break;
       }

@@ -1001,9 +1017,9 @@ vect_get_store_cost (struct data_reference *dr, in
       {
         *inside_cost = VECT_MAX_COST;

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_store_cost: unsupported access.");
-
+        if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "vect_model_store_cost: unsupported access.");
         break;
       }

@@ -1060,9 +1076,10 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
       inside_cost += record_stmt_cost (body_cost_vec, nstmts, vec_perm,
 				       stmt_info, 0, vect_body);

-      if (vect_print_dump_info (REPORT_COST))
-        fprintf (vect_dump, "vect_model_load_cost: strided group_size = %d .",
-                 group_size);
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "vect_model_load_cost: strided group_size = %d .",
+                         group_size);
     }

   /* The loads themselves.  */
@@ -1083,9 +1100,10 @@ vect_model_load_cost (stmt_vec_info stmt_info, int
 			&inside_cost, &prologue_cost,
 			prologue_cost_vec, body_cost_vec, true);

-  if (vect_print_dump_info (REPORT_COST))
-    fprintf (vect_dump, "vect_model_load_cost: inside_cost = %d, "
-             "prologue_cost = %d .", inside_cost, prologue_cost);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "vect_model_load_cost: inside_cost = %d, "
+                     "prologue_cost = %d .", inside_cost, prologue_cost);
 }


@@ -1109,8 +1127,9 @@ vect_get_load_cost (struct data_reference *dr, int
 	*inside_cost += record_stmt_cost (body_cost_vec, ncopies, vector_load,
 					  stmt_info, 0, vect_body);

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: aligned.");
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_load_cost: aligned.");

         break;
       }
@@ -1121,9 +1140,10 @@ vect_get_load_cost (struct data_reference *dr, int
 					  unaligned_load, stmt_info,
 					  DR_MISALIGNMENT (dr), vect_body);

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unaligned supported by "
-                   "hardware.");
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_load_cost: unaligned supported by "
+                           "hardware.");

         break;
       }
@@ -1141,16 +1161,18 @@ vect_get_load_cost (struct data_reference *dr, int
 	  *inside_cost += record_stmt_cost (body_cost_vec, 1, vector_stmt,
 					    stmt_info, 0, vect_body);

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: explicit realign");
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_load_cost: explicit realign");

         break;
       }
     case dr_explicit_realign_optimized:
       {
-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unaligned software "
-                   "pipelined.");
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_load_cost: unaligned software "
+                           "pipelined.");

         /* Unaligned software pipeline has a load of an address, an initial
            load, and possibly a mask operation to "prime" the loop.  However,
@@ -1175,9 +1197,9 @@ vect_get_load_cost (struct data_reference *dr, int
 	*inside_cost += record_stmt_cost (body_cost_vec, ncopies, vec_perm,
 					  stmt_info, 0, vect_body);

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump,
-		   "vect_model_load_cost: explicit realign optimized");
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "vect_model_load_cost: explicit realign optimized");

         break;
       }
@@ -1186,9 +1208,9 @@ vect_get_load_cost (struct data_reference *dr, int
       {
         *inside_cost = VECT_MAX_COST;

-        if (vect_print_dump_info (REPORT_COST))
-          fprintf (vect_dump, "vect_model_load_cost: unsupported access.");
-
+        if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "vect_model_load_cost: unsupported access.");
         break;
       }

@@ -1236,10 +1258,11 @@ vect_init_vector_1 (gimple stmt, gimple new_stmt,
        }
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "created new init_stmt: ");
-      print_gimple_stmt (vect_dump, new_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+                       "created new init_stmt: ");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, new_stmt, 0);
     }
 }

@@ -1317,26 +1340,32 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
   bool is_simple_use;
   tree vector_type;

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "vect_get_vec_def_for_operand: ");
-      print_generic_expr (vect_dump, op, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+                       "vect_get_vec_def_for_operand: ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, op);
     }

   is_simple_use = vect_is_simple_use (op, stmt, loop_vinfo, NULL,
 				      &def_stmt, &def, &dt);
   gcc_assert (is_simple_use);
-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
+      int loc_printed = 0;
       if (def)
         {
-          fprintf (vect_dump, "def =  ");
-          print_generic_expr (vect_dump, def, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "def =  ");
+          loc_printed = 1;
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, def);
         }
       if (def_stmt)
         {
-          fprintf (vect_dump, "  def_stmt =  ");
-	  print_gimple_stmt (vect_dump, def_stmt, 0, TDF_SLIM);
+          if (loc_printed)
+            dump_printf (MSG_NOTE, "  def_stmt =  ");
+          else
+            dump_printf_loc (MSG_NOTE, vect_location, "  def_stmt =  ");
+	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, def_stmt, 0);
         }
     }

@@ -1353,8 +1382,9 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 	  *scalar_def = op;

         /* Create 'vect_cst_ = {cst,cst,...,cst}'  */
-        if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Create vector_cst. nunits = %d", nunits);
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "Create vector_cst. nunits = %d", nunits);

         return vect_init_vector (stmt, op, vector_type, NULL);
       }
@@ -1369,8 +1399,8 @@ vect_get_vec_def_for_operand (tree op, gimple stmt
 	  *scalar_def = def;

         /* Create 'vec_inv = {inv,inv,..,inv}'  */
-        if (vect_print_dump_info (REPORT_DETAILS))
-          fprintf (vect_dump, "Create vector_inv.");
+        if (dump_kind_p (MSG_NOTE))
+          dump_printf_loc (MSG_NOTE, vect_location, "Create vector_inv.");

         return vect_init_vector (stmt, def, vector_type, NULL);
       }
@@ -1631,10 +1661,10 @@ vect_finish_stmt_generation (gimple stmt, gimple v
   set_vinfo_for_stmt (vec_stmt, new_stmt_vec_info (vec_stmt, loop_vinfo,
                                                    bb_vinfo));

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "add new stmt: ");
-      print_gimple_stmt (vect_dump, vec_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location, "add new stmt: ");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, vec_stmt, 0);
     }

   gimple_set_location (vec_stmt, gimple_location (stmt));
@@ -1734,8 +1764,9 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
       if (rhs_type
 	  && !types_compatible_p (rhs_type, TREE_TYPE (op)))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "argument types differ.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "argument types differ.");
 	  return false;
 	}
       if (!rhs_type)
@@ -1744,8 +1775,9 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
       if (!vect_is_simple_use_1 (op, stmt, loop_vinfo, bb_vinfo,
 				 &def_stmt, &def, &dt[i], &opvectype))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "use not simple.");
 	  return false;
 	}

@@ -1754,8 +1786,9 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
       else if (opvectype
 	       && opvectype != vectype_in)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "argument vector types differ.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "argument vector types differ.");
 	  return false;
 	}
     }
@@ -1767,10 +1800,11 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
     gcc_assert (vectype_in);
   if (!vectype_in)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, rhs_type, TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "no vectype for scalar type ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
         }

       return false;
@@ -1795,8 +1829,9 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
   fndecl = vectorizable_function (stmt, vectype_out, vectype_in);
   if (fndecl == NULL_TREE)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "function is not vectorizable.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "function is not vectorizable.");

       return false;
     }
@@ -1817,16 +1852,16 @@ vectorizable_call (gimple stmt, gimple_stmt_iterat
   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = call_vec_info_type;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_call ===");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location, "=== vectorizable_call ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL);
       return true;
     }

   /** Transform.  **/

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform call.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "transform call.");

   /* Handle def.  */
   scalar_dest = gimple_call_lhs (stmt);
@@ -2340,9 +2375,9 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 	  && (TYPE_PRECISION (rhs_type)
 	      != GET_MODE_PRECISION (TYPE_MODE (rhs_type)))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump,
-		 "type conversion to/from bit-precision unsupported.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "type conversion to/from bit-precision unsupported.");
       return false;
     }

@@ -2350,8 +2385,9 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
   if (!vect_is_simple_use_1 (op0, stmt, loop_vinfo, bb_vinfo,
 			     &def_stmt, &def, &dt[0], &vectype_in))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "use not simple.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "use not simple.");
       return false;
     }
   if (op_type == binary_op)
@@ -2371,8 +2407,9 @@ vectorizable_conversion (gimple stmt, gimple_stmt_

       if (!ok)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "use not simple.");
 	  return false;
 	}
     }
@@ -2385,10 +2422,11 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
     gcc_assert (vectype_in);
   if (!vectype_in)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	{
-	  fprintf (vect_dump, "no vectype for scalar type ");
-	  print_generic_expr (vect_dump, rhs_type, TDF_SLIM);
+	  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "no vectype for scalar type ");
+	  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, rhs_type);
 	}

       return false;
@@ -2428,8 +2466,9 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
 	break;
       /* FALLTHRU */
     unsupported:
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "conversion not supported by target.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "conversion not supported by target.");
       return false;

     case WIDEN:
@@ -2526,8 +2565,9 @@ vectorizable_conversion (gimple stmt, gimple_stmt_

   if (!vec_stmt)		/* transformation not required.  */
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "=== vectorizable_conversion ===");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "=== vectorizable_conversion ===");
       if (code == FIX_TRUNC_EXPR || code == FLOAT_EXPR)
         {
 	  STMT_VINFO_TYPE (stmt_info) = type_conversion_vec_info_type;
@@ -2548,8 +2588,9 @@ vectorizable_conversion (gimple stmt, gimple_stmt_
     }

   /** Transform.  **/
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform conversion. ncopies = %d.", ncopies);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "transform conversion. ncopies = %d.", ncopies);

   if (op_type == binary_op)
     {
@@ -2900,8 +2941,9 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
   if (!vect_is_simple_use_1 (op, stmt, loop_vinfo, bb_vinfo,
 			     &def_stmt, &def, &dt[0], &vectype_in))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "use not simple.");
       return false;
     }

@@ -2928,24 +2970,26 @@ vectorizable_assignment (gimple stmt, gimple_stmt_
 	    > TYPE_PRECISION (TREE_TYPE (op)))
 	   && TYPE_UNSIGNED (TREE_TYPE (op))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "type conversion to/from bit-precision "
-		 "unsupported.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "type conversion to/from bit-precision "
+                         "unsupported.");
       return false;
     }

   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = assignment_vec_info_type;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_assignment ===");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "=== vectorizable_assignment ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL);
       return true;
     }

   /** Transform.  **/
-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform assignment.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "transform assignment.");

   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3091,8 +3135,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (TYPE_PRECISION (TREE_TYPE (scalar_dest))
       != GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (scalar_dest))))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bit-precision shifts not supported.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "bit-precision shifts not supported.");
       return false;
     }

@@ -3100,8 +3145,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (!vect_is_simple_use_1 (op0, stmt, loop_vinfo, bb_vinfo,
                              &def_stmt, &def, &dt[0], &vectype))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "use not simple.");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -3112,12 +3158,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     gcc_assert (vectype);
   if (!vectype)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, TREE_TYPE (op0), TDF_SLIM);
-        }
-
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "no vectype for scalar type ");
       return false;
     }

@@ -3130,8 +3173,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (!vect_is_simple_use_1 (op1, stmt, loop_vinfo, bb_vinfo, &def_stmt,
 			     &def, &dt[1], &op1_vectype))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "use not simple.");
       return false;
     }

@@ -3174,8 +3218,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
     }
   else
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "operand mode requires invariant argument.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "operand mode requires invariant argument.");
       return false;
     }

@@ -3183,16 +3228,19 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   if (!scalar_shift_arg)
     {
       optab = optab_for_tree_code (code, vectype, optab_vector);
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "vector/vector shift/rotate found.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "vector/vector shift/rotate found.");
+
       if (!op1_vectype)
 	op1_vectype = get_same_sized_vectype (TREE_TYPE (op1), vectype_out);
       if (op1_vectype == NULL_TREE
 	  || TYPE_MODE (op1_vectype) != TYPE_MODE (vectype))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "unusable type for last operand in"
-				" vector/vector shift/rotate.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "unusable type for last operand in"
+                             " vector/vector shift/rotate.");
 	  return false;
 	}
     }
@@ -3204,8 +3252,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
       if (optab
           && optab_handler (optab, TYPE_MODE (vectype)) != CODE_FOR_nothing)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "vector/scalar shift/rotate found.");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location,
+                             "vector/scalar shift/rotate found.");
         }
       else
         {
@@ -3216,8 +3265,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
             {
 	      scalar_shift_arg = false;

-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "vector/vector shift/rotate found.");
+              if (dump_kind_p (MSG_NOTE))
+                dump_printf_loc (MSG_NOTE, vect_location,
+                                 "vector/vector shift/rotate found.");

               /* Unlike the other binary operators, shifts/rotates have
                  the rhs being int, instead of the same type as the lhs,
@@ -3232,9 +3282,10 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
 		      && TYPE_MODE (TREE_TYPE (vectype))
 			 != TYPE_MODE (TREE_TYPE (op1)))
 		    {
-		      if (vect_print_dump_info (REPORT_DETAILS))
-		      fprintf (vect_dump, "unusable type for last operand in"
-					  " vector/vector shift/rotate.");
+                      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                        dump_printf_loc (MSG_MISSED_OPTIMIZATION,
vect_location,
+                                         "unusable type for last operand in"
+                                         " vector/vector shift/rotate.");
 			return false;
 		    }
 		  if (vec_stmt && !slp_node)
@@ -3251,23 +3302,25 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
   /* Supportable by target?  */
   if (!optab)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "no optab.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "no optab.");
       return false;
     }
   vec_mode = TYPE_MODE (vectype);
   icode = (int) optab_handler (optab, vec_mode);
   if (icode == CODE_FOR_nothing)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "op not supported by target.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "op not supported by target.");
       /* Check only during analysis.  */
       if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
           || (vf < vect_min_worthwhile_factor (code)
               && !vec_stmt))
         return false;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "proceeding using word mode.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location, "proceeding using
word mode.");
     }

   /* Worthwhile without SIMD support?  Check only during analysis.  */
@@ -3275,24 +3328,26 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
       && vf < vect_min_worthwhile_factor (code)
       && !vec_stmt)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not worthwhile without SIMD support.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not worthwhile without SIMD support.");
       return false;
     }

   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = shift_vec_info_type;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_shift ===");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location, "===
vectorizable_shift ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL);
       return true;
     }

   /** Transform.  **/

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform binary/unary operation.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "transform binary/unary operation.");

   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3327,8 +3382,9 @@ vectorizable_shift (gimple stmt, gimple_stmt_itera
               optab_op2_mode = insn_data[icode].operand[2].mode;
               if (!VECTOR_MODE_P (optab_op2_mode))
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "operand 1 using scalar mode.");
+                  if (dump_kind_p (MSG_NOTE))
+                    dump_printf_loc (MSG_NOTE, vect_location,
+                                     "operand 1 using scalar mode.");
                   vec_oprnd1 = op1;
                   VEC_quick_push (tree, vec_oprnds1, vec_oprnd1);
                   if (slp_node)
@@ -3454,9 +3510,10 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   op_type = TREE_CODE_LENGTH (code);
   if (op_type != unary_op && op_type != binary_op && op_type != ternary_op)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "num. args = %d (not unary/binary/ternary op).",
-		 op_type);
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "num. args = %d (not unary/binary/ternary op).",
+                         op_type);
       return false;
     }

@@ -3472,8 +3529,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       && code != BIT_XOR_EXPR
       && code != BIT_AND_EXPR)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "bit-precision arithmetic not supported.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "bit-precision arithmetic not supported.");
       return false;
     }

@@ -3481,8 +3539,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
   if (!vect_is_simple_use_1 (op0, stmt, loop_vinfo, bb_vinfo,
 			     &def_stmt, &def, &dt[0], &vectype))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "use not simple.");
       return false;
     }
   /* If op0 is an external or constant def use a vector type with
@@ -3493,10 +3552,12 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
     gcc_assert (vectype);
   if (!vectype)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "no vectype for scalar type ");
-          print_generic_expr (vect_dump, TREE_TYPE (op0), TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "no vectype for scalar type ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                             TREE_TYPE (op0));
         }

       return false;
@@ -3513,8 +3574,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       if (!vect_is_simple_use (op1, stmt, loop_vinfo, bb_vinfo, &def_stmt,
 			       &def, &dt[1]))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "use not simple.");
 	  return false;
 	}
     }
@@ -3524,8 +3586,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       if (!vect_is_simple_use (op2, stmt, loop_vinfo, bb_vinfo, &def_stmt,
 			       &def, &dt[2]))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "use not simple.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "use not simple.");
 	  return false;
 	}
     }
@@ -3565,8 +3628,9 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       optab = optab_for_tree_code (code, vectype, optab_default);
       if (!optab)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "no optab.");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "no optab.");
 	  return false;
 	}
       icode = (int) optab_handler (optab, vec_mode);
@@ -3574,14 +3638,15 @@ vectorizable_operation (gimple stmt, gimple_stmt_i

   if (icode == CODE_FOR_nothing)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "op not supported by target.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "op not supported by target.");
       /* Check only during analysis.  */
       if (GET_MODE_SIZE (vec_mode) != UNITS_PER_WORD
 	  || (!vec_stmt && vf < vect_min_worthwhile_factor (code)))
         return false;
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "proceeding using word mode.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location, "proceeding using word mode.");
     }

   /* Worthwhile without SIMD support?  Check only during analysis.  */
@@ -3589,24 +3654,26 @@ vectorizable_operation (gimple stmt, gimple_stmt_i
       && !vec_stmt
       && vf < vect_min_worthwhile_factor (code))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "not worthwhile without SIMD support.");
-      return false;
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not worthwhile without SIMD support.");
     }

   if (!vec_stmt) /* transformation not required.  */
     {
       STMT_VINFO_TYPE (stmt_info) = op_vec_info_type;
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "=== vectorizable_operation ===");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "=== vectorizable_operation ===");
       vect_model_simple_cost (stmt_info, ncopies, dt, NULL, NULL);
       return true;
     }

   /** Transform.  **/

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform binary/unary operation.");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "transform binary/unary operation.");

   /* Handle def.  */
   vec_dest = vect_create_destination_var (scalar_dest, vectype);
@@ -3792,8 +3859,9 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
   /* FORNOW. This restriction should be relaxed.  */
   if (loop && nested_in_vect_loop_p (loop, stmt) && ncopies > 1)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "multiple types in nested loop.");
       return false;
     }

@@ -3825,8 +3893,9 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
   if (!vect_is_simple_use (op, stmt, loop_vinfo, bb_vinfo, &def_stmt,
 			   &def, &dt))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "use not simple.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "use not simple.");
       return false;
     }

@@ -3845,8 +3914,9 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
 			    ? STMT_VINFO_DR_STEP (stmt_info) : DR_STEP (dr),
 			    size_zero_node) < 0)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "negative step for store.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "negative step for store.");
       return false;
     }

@@ -3875,8 +3945,9 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
               if (!vect_is_simple_use (op, next_stmt, loop_vinfo, bb_vinfo,
 				       &def_stmt, &def, &dt))
                 {
-                  if (vect_print_dump_info (REPORT_DETAILS))
-                    fprintf (vect_dump, "use not simple.");
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                     "use not simple.");
                   return false;
                 }
               next_stmt = GROUP_NEXT_ELEMENT (vinfo_for_stmt (next_stmt));
@@ -3936,8 +4007,9 @@ vectorizable_store (gimple stmt, gimple_stmt_itera
       group_size = vec_num = 1;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform store. ncopies = %d",ncopies);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "transform store. ncopies = %d", ncopies);

   dr_chain = VEC_alloc (tree, heap, group_size);
   oprnds = VEC_alloc (tree, heap, group_size);
@@ -4323,8 +4395,9 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
   /* FORNOW. This restriction should be relaxed.  */
   if (nested_in_vect_loop && ncopies > 1)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "multiple types in nested loop.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "multiple types in nested loop.");
       return false;
     }

@@ -4362,8 +4435,9 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
     (e.g. - data copies).  */
   if (optab_handler (mov_optab, mode) == CODE_FOR_nothing)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump, "Aligned load, but unsupported type.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "Aligned load, but unsupported type.");
       return false;
     }

@@ -4397,8 +4471,9 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 				 &def_stmt, &def, &gather_dt,
 				 &gather_off_vectype))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "gather index use not simple.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "gather index use not simple.");
 	  return false;
 	}
     }
@@ -4416,8 +4491,9 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 				       size_zero_node) < 0;
       if (negative && ncopies > 1)
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "multiple types with negative step.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "multiple types with negative step.");
 	  return false;
 	}

@@ -4428,14 +4504,16 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
 	  if (alignment_support_scheme != dr_aligned
 	      && alignment_support_scheme != dr_unaligned_supported)
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "negative step but alignment required.");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "negative step but alignment required.");
 	      return false;
 	    }
 	  if (!perm_mask_for_reverse (vectype))
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
-		fprintf (vect_dump, "negative step and reversing not supported.");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                 "negative step and reversing not supported.");
 	      return false;
 	    }
 	}
@@ -4448,8 +4526,9 @@ vectorizable_load (gimple stmt, gimple_stmt_iterat
       return true;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "transform load. ncopies = %d", ncopies);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+                     "transform load. ncopies = %d", ncopies);

   /** Transform.  **/

@@ -5248,8 +5327,9 @@ vectorizable_condition (gimple stmt, gimple_stmt_i
   /* FORNOW: not yet supported.  */
   if (STMT_VINFO_LIVE_P (stmt_info))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "value used after loop.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "value used after loop.");
       return false;
     }

@@ -5447,16 +5527,17 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
   gimple pattern_stmt;
   gimple_seq pattern_def_seq;

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "==> examining statement: ");
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location, "==> examining statement: ");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
     }

   if (gimple_has_volatile_ops (stmt))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: stmt has volatile operands");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not vectorized: stmt has volatile operands");

       return false;
     }
@@ -5487,16 +5568,17 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
           /* Analyze PATTERN_STMT instead of the original stmt.  */
           stmt = pattern_stmt;
           stmt_info = vinfo_for_stmt (pattern_stmt);
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_NOTE))
             {
-              fprintf (vect_dump, "==> examining pattern statement: ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_NOTE, vect_location,
+                               "==> examining pattern statement: ");
+              dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
             }
         }
       else
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
-            fprintf (vect_dump, "irrelevant.");
+          if (dump_kind_p (MSG_NOTE))
+            dump_printf_loc (MSG_NOTE, vect_location, "irrelevant.");

           return true;
         }
@@ -5508,10 +5590,11 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
                || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_stmt))))
     {
       /* Analyze PATTERN_STMT too.  */
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "==> examining pattern statement: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "==> examining pattern statement: ");
+          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
         }

       if (!vect_analyze_stmt (pattern_stmt, need_to_vectorize, node))
@@ -5531,10 +5614,11 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
 	      || STMT_VINFO_LIVE_P (vinfo_for_stmt (pattern_def_stmt)))
 	    {
 	      /* Analyze def stmt of STMT if it's a pattern stmt.  */
-	      if (vect_print_dump_info (REPORT_DETAILS))
+	      if (dump_kind_p (MSG_NOTE))
 		{
-		  fprintf (vect_dump, "==> examining pattern def statement: ");
-		  print_gimple_stmt (vect_dump, pattern_def_stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_NOTE, vect_location,
+                                   "==> examining pattern def statement: ");
+		  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, pattern_def_stmt, 0);
 		}

 	      if (!vect_analyze_stmt (pattern_def_stmt,
@@ -5569,27 +5653,30 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect
       gcc_assert (PURE_SLP_STMT (stmt_info));

       scalar_type = TREE_TYPE (gimple_get_lhs (stmt));
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "get vectype for scalar type:  ");
-          print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "get vectype for scalar type:  ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
         }

       vectype = get_vectype_for_scalar_type (scalar_type);
       if (!vectype)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-               fprintf (vect_dump, "not SLPed: unsupported data-type ");
-               print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                "not SLPed: unsupported data-type ");
+               dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+                                  scalar_type);
             }
           return false;
         }

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "vectype:  ");
-          print_generic_expr (vect_dump, vectype, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location, "vectype:  ");
+          dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
         }

       STMT_VINFO_VECTYPE (stmt_info) = vectype;
@@ -5630,11 +5717,12 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect

   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "not vectorized: relevant stmt not ");
-          fprintf (vect_dump, "supported: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "not vectorized: relevant stmt not ");
+          dump_printf (MSG_MISSED_OPTIMIZATION, "supported: ");
+          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }

       return false;
@@ -5651,11 +5739,12 @@ vect_analyze_stmt (gimple stmt, bool *need_to_vect

   if (!ok)
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "not vectorized: live stmt not ");
-          fprintf (vect_dump, "supported: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                           "not vectorized: live stmt not ");
+          dump_printf (MSG_MISSED_OPTIMIZATION,  "supported: ");
+          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }

        return false;
@@ -5750,8 +5839,9 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter
     default:
       if (!STMT_VINFO_LIVE_P (stmt_info))
 	{
-	  if (vect_print_dump_info (REPORT_DETAILS))
-	    fprintf (vect_dump, "stmt not supported.");
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                             "stmt not supported.");
 	  gcc_unreachable ();
 	}
     }
@@ -5774,8 +5864,9 @@ vect_transform_stmt (gimple stmt, gimple_stmt_iter
       tree scalar_dest;
       gimple exit_phi;

-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Record the vdef for outer-loop vectorization.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+                         "Record the vdef for outer-loop vectorization.");

       /* Find the relevant loop-exit phi-node, and reord the vec_stmt there
         (to be used when vectorizing outer-loop stmts that use the DEF of
@@ -6005,26 +6096,28 @@ get_vectype_for_scalar_type_and_size (tree scalar_
     return NULL_TREE;

   vectype = build_vector_type (scalar_type, nunits);
-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "get vectype with %d units of type ", nunits);
-      print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+                       "get vectype with %d units of type ", nunits);
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, scalar_type);
     }

   if (!vectype)
     return NULL_TREE;

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "vectype: ");
-      print_generic_expr (vect_dump, vectype, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location, "vectype: ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, vectype);
     }

   if (!VECTOR_MODE_P (TYPE_MODE (vectype))
       && !INTEGRAL_MODE_P (TYPE_MODE (vectype)))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "mode not supported by target.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "mode not supported by target.");
       return NULL_TREE;
     }

@@ -6093,10 +6186,11 @@ vect_is_simple_use (tree operand, gimple stmt, loo
   *def_stmt = NULL;
   *def = NULL_TREE;

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "vect_is_simple_use: operand ");
-      print_generic_expr (vect_dump, operand, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location,
+                       "vect_is_simple_use: operand ");
+      dump_generic_expr (MSG_NOTE, TDF_SLIM, operand);
     }

   if (CONSTANT_CLASS_P (operand))
@@ -6114,30 +6208,32 @@ vect_is_simple_use (tree operand, gimple stmt, loo

   if (TREE_CODE (operand) == PAREN_EXPR)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "non-associatable copy.");
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location, "non-associatable copy.");
       operand = TREE_OPERAND (operand, 0);
     }

   if (TREE_CODE (operand) != SSA_NAME)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "not ssa-name.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not ssa-name.");
       return false;
     }

   *def_stmt = SSA_NAME_DEF_STMT (operand);
   if (*def_stmt == NULL)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "no def_stmt.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "no def_stmt.");
       return false;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "def_stmt: ");
-      print_gimple_stmt (vect_dump, *def_stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE, vect_location, "def_stmt: ");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, *def_stmt, 0);
     }

   /* Empty stmt is expected only in case of a function argument.
@@ -6166,13 +6262,14 @@ vect_is_simple_use (tree operand, gimple stmt, loo
 	  && *dt == vect_double_reduction_def
 	  && gimple_code (stmt) != GIMPLE_PHI))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "Unsupported pattern.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "Unsupported pattern.");
       return false;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "type of def: %d.",*dt);
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "type of def: %d.", *dt);

   switch (gimple_code (*def_stmt))
     {
@@ -6190,8 +6287,9 @@ vect_is_simple_use (tree operand, gimple stmt, loo
 	break;
       /* FALLTHRU */
     default:
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "unsupported defining stmt: ");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "unsupported defining stmt: ");
       return false;
     }

Index: combine.c
===================================================================
--- combine.c	(revision 191208)
+++ combine.c	(working copy)
@@ -13779,8 +13779,10 @@ unmentioned_reg_p (rtx equiv, rtx expr)
   return for_each_rtx (&equiv, unmentioned_reg_p_1, expr);
 }
 \f
+/* Print detailed combiner stats on FILE. Used for debugging. */
+
 DEBUG_FUNCTION void
-dump_combine_stats (FILE *file)
+debug_combine_stats (FILE *file)
 {
   fprintf
     (file,
@@ -13789,7 +13791,7 @@ DEBUG_FUNCTION void
 }

 void
-dump_combine_total_stats (FILE *file)
+print_combine_total_stats (FILE *file)
 {
   fprintf
     (file,
Index: opts-global.c
===================================================================
--- opts-global.c	(revision 191208)
+++ opts-global.c	(working copy)
@@ -351,6 +351,12 @@ handle_common_deferred_options (void)
 	    error ("unrecognized command line option %<-fdump-%s%>", opt->arg);
 	  break;

+        case OPT_fopt_info_:
+	  if (!opt_info_switch_p (opt->arg))
+	    error ("unrecognized command line option %<-fopt-info-%s%>",
+                   opt->arg);
+          break;
+
 	case OPT_fenable_:
 	case OPT_fdisable_:
 	  if (opt->opt_index == OPT_fenable_)
@@ -410,6 +416,10 @@ handle_common_deferred_options (void)
 	  stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt->arg));
 	  break;

+        case OPT_ftree_vectorizer_verbose_:
+	  dump_remap_tree_vectorizer_verbose (opt->arg);
+          break;
+
 	default:
 	  gcc_unreachable ();
 	}
Index: Makefile.in
===================================================================
--- Makefile.in	(revision 191208)
+++ Makefile.in	(working copy)
@@ -2175,9 +2175,9 @@ tree.o: tree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h
    $(TREE_PASS_H) $(LANGHOOKS_DEF_H) $(DIAGNOSTIC_H) $(CGRAPH_H) \
    $(EXCEPT_H) debug.h intl.h tree-diagnostic.h $(TREE_PRETTY_PRINT_H) \
    $(COMMON_TARGET_H)
-tree-dump.o: tree-dump.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
-   $(TREE_H) langhooks.h toplev.h $(SPLAY_TREE_H) $(TREE_DUMP_H) \
-   tree-iterator.h $(TREE_PASS_H) $(DIAGNOSTIC_H)
+tree-dump.o: tree-dump.c $(CONFIG_H) $(GIMPLE_PRETTY_PRINT_H) $(SYSTEM_H) \
+   coretypes.h $(TM_H) $(TREE_H) langhooks.h rtl.h toplev.h $(SPLAY_TREE_H) \
+   $(TREE_DUMP_H) tree-iterator.h $(TREE_PASS_H) $(DIAGNOSTIC_H)
 tree-inline.o : tree-inline.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(TREE_H) $(RTL_H) $(FLAGS_H) $(PARAMS_H) $(INPUT_H) insn-config.h \
    $(HASHTAB_H) langhooks.h $(TREE_INLINE_H) $(CGRAPH_H) \
@@ -2537,12 +2537,12 @@ graphite-optimize-isl.o : graphite-optimize-isl.c
     coretypes.h dumpfile.h $(TREE_FLOW_H) $(CFGLOOP_H)
$(TREE_DATA_REF_H) $(SCEV_H) \
     sese.h graphite-poly.h
 tree-vect-loop.o: tree-vect-loop.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-   $(TM_H) $(GGC_H) $(TREE_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) \
+   $(TM_H) $(GGC_H) $(TREE_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) dumpfile.h \
    $(CFGLOOP_H) $(EXPR_H) $(RECOG_H) $(OPTABS_H) \
    $(DIAGNOSTIC_CORE_H) $(SCEV_H) $(TREE_VECTORIZER_H) \
    $(GIMPLE_PRETTY_PRINT_H) $(TARGET_H) $(TREE_DATA_REF_H)
 tree-vect-loop-manip.o: tree-vect-loop-manip.c $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h $(TM_H) $(GGC_H) $(TREE_H) $(BASIC_BLOCK_H) \
+   coretypes.h dumpfile.h $(TM_H) $(GGC_H) $(TREE_H) $(BASIC_BLOCK_H) \
    $(TREE_FLOW_H) $(CFGLOOP_H) $(DIAGNOSTIC_CORE_H) \
    $(SCEV_H) $(TREE_VECTORIZER_H) langhooks.h $(GIMPLE_PRETTY_PRINT_H)
 tree-vect-patterns.o: tree-vect-patterns.c $(CONFIG_H) $(SYSTEM_H) \
@@ -2551,8 +2551,8 @@ tree-vect-patterns.o: tree-vect-patterns.c $(CONFI
    $(TREE_FLOW_H) $(CFGLOOP_H) $(EXPR_H) $(OPTABS_H) $(PARAMS_H) \
    $(TREE_DATA_REF_H) $(TREE_VECTORIZER_H) $(RECOG_H) $(DIAGNOSTIC_CORE_H) \
    $(GIMPLE_PRETTY_PRINT_H)
-tree-vect-slp.o: tree-vect-slp.c $(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h $(TM_H) $(GGC_H) $(TREE_H) $(TARGET_H) $(BASIC_BLOCK_H) \
+tree-vect-slp.o: tree-vect-slp.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
+   dumpfile.h $(TM_H) $(GGC_H) $(TREE_H) $(TARGET_H) $(BASIC_BLOCK_H) \
    $(DIAGNOSTIC_H) $(TREE_FLOW_H) $(CFGLOOP_H) \
    $(EXPR_H) $(RECOG_H) $(OPTABS_H) $(TREE_VECTORIZER_H) \
    $(GIMPLE_PRETTY_PRINT_H) $(TREE_DATA_REF_H) langhooks.h
@@ -2567,7 +2567,7 @@ tree-vect-data-refs.o: tree-vect-data-refs.c $(CON
    $(EXPR_H) $(OPTABS_H) $(SCEV_H) $(TREE_VECTORIZER_H) \
    $(DIAGNOSTIC_CORE_H) $(TM_P_H) $(GIMPLE_PRETTY_PRINT_H)
 tree-vectorizer.o: tree-vectorizer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-   $(TM_H) $(GGC_H) $(TREE_H) $(TREE_FLOW_H) \
+   dumpfile.h $(TM_H) $(GGC_H) $(TREE_H) $(TREE_FLOW_H) \
    $(CFGLOOP_H) $(TREE_PASS_H) $(TREE_VECTORIZER_H) \
    $(TREE_PRETTY_PRINT_H)
 tree-loop-distribution.o: tree-loop-distribution.c $(CONFIG_H) $(SYSTEM_H) \
@@ -2615,7 +2615,7 @@ fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H
 diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
    version.h $(INPUT_H) intl.h $(DIAGNOSTIC_H) diagnostic.def
 opts.o : opts.c $(OPTS_H) $(OPTIONS_H) $(DIAGNOSTIC_CORE_H)
$(CONFIG_H) $(SYSTEM_H) \
-   coretypes.h $(TM_H) \
+   coretypes.h dumpfile.h $(TM_H) \
    $(DIAGNOSTIC_H) insn-attr-common.h intl.h $(COMMON_TARGET_H) \
    $(FLAGS_H) $(PARAMS_H) opts-diagnostic.h
 opts-global.o : opts-global.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
Index: passes.c
===================================================================
--- passes.c	(revision 191208)
+++ passes.c	(working copy)
@@ -231,27 +231,23 @@ finish_optimization_passes (void)
   timevar_push (TV_DUMP);
   if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities)
     {
-      dump_file = dump_begin (pass_profile.pass.static_pass_number, NULL);
+      dump_start (pass_profile.pass.static_pass_number, NULL);
       end_branch_prob ();
-      if (dump_file)
-	dump_end (pass_profile.pass.static_pass_number, dump_file);
+      dump_finish (pass_profile.pass.static_pass_number);
     }

   if (optimize > 0)
     {
-      dump_file = dump_begin (pass_combine.pass.static_pass_number, NULL);
-      if (dump_file)
-	{
-	  dump_combine_total_stats (dump_file);
-          dump_end (pass_combine.pass.static_pass_number, dump_file);
-	}
+      dump_start (pass_profile.pass.static_pass_number, NULL);
+      dump_combine_total_stats ();
+      dump_finish (pass_combine.pass.static_pass_number);
     }

   /* Do whatever is necessary to finish printing the graphs.  */
   if (graph_dump_format != no_graph)
     for (i = TDI_end; (dfi = get_dump_file_info (i)) != NULL; ++i)
       if (dump_initialized_p (i)
-	  && (dfi->flags & TDF_GRAPH) != 0
+	  && (dfi->pflags & TDF_GRAPH) != 0
 	  && (name = get_dump_file_name (i)) != NULL)
 	{
 	  finish_graph_dump_file (name);
@@ -1217,9 +1213,9 @@ register_pass (struct register_pass_info *pass_inf
       else
         tdi = TDI_rtl_all;
       /* Check if dump-all flag is specified.  */
-      if (get_dump_file_info (tdi)->state)
+      if (get_dump_file_info (tdi)->pstate)
         get_dump_file_info (added_pass_nodes->pass->static_pass_number)
-            ->state = get_dump_file_info (tdi)->state;
+            ->pstate = get_dump_file_info (tdi)->pstate;
       XDELETE (added_pass_nodes);
       added_pass_nodes = next_node;
     }
@@ -1904,7 +1900,7 @@ pass_init_dump_file (struct opt_pass *pass)
     {
       bool initializing_dump = !dump_initialized_p (pass->static_pass_number);
       dump_file_name = get_dump_file_name (pass->static_pass_number);
-      dump_file = dump_begin (pass->static_pass_number, &dump_flags);
+      dump_start (pass->static_pass_number, &dump_flags);
       if (dump_file && current_function_decl)
         dump_function_header (dump_file, current_function_decl, dump_flags);
       return initializing_dump;
@@ -1926,11 +1922,7 @@ pass_fini_dump_file (struct opt_pass *pass)
       dump_file_name = NULL;
     }

-  if (dump_file)
-    {
-      dump_end (pass->static_pass_number, dump_file);
-      dump_file = NULL;
-    }
+  dump_finish (pass->static_pass_number);
 }

 /* After executing the pass, apply expected changes to the function
@@ -2172,7 +2164,7 @@ execute_one_pass (struct opt_pass *pass)
       && (cfun->curr_properties & (PROP_cfg | PROP_rtl))
 	  == (PROP_cfg | PROP_rtl))
     {
-      get_dump_file_info (pass->static_pass_number)->flags |= TDF_GRAPH;
+      get_dump_file_info (pass->static_pass_number)->pflags |= TDF_GRAPH;
       dump_flags |= TDF_GRAPH;
       clean_graph_dump_file (dump_file_name);
     }
Index: tree-vect-slp.c
===================================================================
--- tree-vect-slp.c	(revision 191208)
+++ tree-vect-slp.c	(working copy)
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "dumpfile.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -237,10 +238,11 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 			       &def, &dt)
 	  || (!def_stmt && dt != vect_constant_def))
 	{
-	  if (vect_print_dump_info (REPORT_SLP))
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	    {
-	      fprintf (vect_dump, "Build SLP failed: can't find def for ");
-	      print_generic_expr (vect_dump, oprnd, TDF_SLIM);
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: can't find def for ");
+	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
 	    }

 	  return false;
@@ -261,11 +263,12 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
           pattern = true;
           if (!first && !oprnd_info->first_pattern)
 	    {
-	      if (vect_print_dump_info (REPORT_DETAILS))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump, "Build SLP failed: some of the stmts"
-				" are in a pattern, and others are not ");
-		  print_generic_expr (vect_dump, oprnd, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: some of the stmts"
+				   " are in a pattern, and others are not ");
+		  dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, oprnd);
 		}

 	      return false;
@@ -276,8 +279,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi

           if (dt == vect_unknown_def_type)
             {
-              if (vect_print_dump_info (REPORT_DETAILS))
-                fprintf (vect_dump, "Unsupported pattern.");
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				 "Unsupported pattern.");
               return false;
             }

@@ -292,8 +296,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
                 break;

               default:
-                if (vect_print_dump_info (REPORT_DETAILS))
-                  fprintf (vect_dump, "unsupported defining stmt: ");
+                if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "unsupported defining stmt: ");
                 return false;
             }
         }
@@ -356,8 +361,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 	    {
 	      if (number_of_oprnds != 2)
 		{
-		  if (vect_print_dump_info (REPORT_SLP))
-		    fprintf (vect_dump, "Build SLP failed: different types ");
+		  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+		    dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				     "Build SLP failed: different types ");

 		  return false;
                 }
@@ -382,10 +388,11 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
                            && !types_compatible_p (oprnd_info->first_def_type,
                                                    TREE_TYPE (def_op0))))
                     {
-                      if (vect_print_dump_info (REPORT_SLP))
+                      if (dump_kind_p (MSG_NOTE))
 	                {
-			  fprintf (vect_dump, "Swapping operands of ");
- 		          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+			  dump_printf_loc (MSG_NOTE, vect_location,
+					   "Swapping operands of ");
+ 		          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 			}

  		      swap_tree_operands (stmt, gimple_assign_rhs1_ptr (stmt),
@@ -393,8 +400,9 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi
 		    }
                   else
                     {
-         	      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: different types ");
+         	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+			dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+					 "Build SLP failed: different types ");

 		      return false;
 		    }
@@ -427,10 +435,11 @@ vect_get_and_check_slp_defs (loop_vec_info loop_vi

 	default:
 	  /* FORNOW: Not supported.  */
-	  if (vect_print_dump_info (REPORT_SLP))
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	    {
-	      fprintf (vect_dump, "Build SLP failed: illegal type of def ");
-	      print_generic_expr (vect_dump, def, TDF_SLIM);
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: illegal type of def ");
+	      dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, def);
 	    }

 	  return false;
@@ -495,20 +504,20 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
   /* For every stmt in NODE find its def stmt/s.  */
   FOR_EACH_VEC_ELT (gimple, stmts, i, stmt)
     {
-      if (vect_print_dump_info (REPORT_SLP))
+      if (dump_kind_p (MSG_NOTE))
 	{
-	  fprintf (vect_dump, "Build SLP for ");
-	  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	  dump_printf_loc (MSG_NOTE, vect_location, "Build SLP for ");
+	  dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
 	}

       /* Fail to vectorize statements marked as unvectorizable.  */
       if (!STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (stmt)))
         {
-          if (vect_print_dump_info (REPORT_SLP))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump,
-                       "Build SLP failed: unvectorizable statement ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: unvectorizable statement ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

 	  vect_free_oprnd_info (&oprnds_info);
@@ -518,11 +527,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
       lhs = gimple_get_lhs (stmt);
       if (lhs == NULL_TREE)
 	{
-	  if (vect_print_dump_info (REPORT_SLP))
+	  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 	    {
-	      fprintf (vect_dump,
-		       "Build SLP failed: not GIMPLE_ASSIGN nor GIMPLE_CALL ");
-	      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+	      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: not GIMPLE_ASSIGN nor "
+			       "GIMPLE_CALL ");
+	      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 	    }

 	  vect_free_oprnd_info (&oprnds_info);
@@ -534,11 +544,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
            && (cond = gimple_assign_rhs1 (stmt))
            && !COMPARISON_CLASS_P (cond))
         {
-          if (vect_print_dump_info (REPORT_SLP))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump,
-                       "Build SLP failed: condition is not comparison ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: condition is not "
+			       "comparison ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

 	  vect_free_oprnd_info (&oprnds_info);
@@ -549,10 +560,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
       vectype = get_vectype_for_scalar_type (scalar_type);
       if (!vectype)
         {
-          if (vect_print_dump_info (REPORT_SLP))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
-              print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: unsupported data-type ");
+              dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+				 scalar_type);
             }

 	  vect_free_oprnd_info (&oprnds_info);
@@ -578,11 +591,11 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	      || !gimple_call_nothrow_p (stmt)
 	      || gimple_call_chain (stmt))
 	    {
-	      if (vect_print_dump_info (REPORT_SLP))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: unsupported call type ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: unsupported call type ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}

 	      vect_free_oprnd_info (&oprnds_info);
@@ -618,17 +631,19 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_

 		  if (!optab)
 		    {
-		      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: no optab.");
+		      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+			dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+					 "Build SLP failed: no optab.");
 	  	      vect_free_oprnd_info (&oprnds_info);
 		      return false;
 		    }
 		  icode = (int) optab_handler (optab, vec_mode);
 		  if (icode == CODE_FOR_nothing)
 		    {
-		      if (vect_print_dump_info (REPORT_SLP))
-			fprintf (vect_dump, "Build SLP failed: "
-				            "op not supported by target.");
+		      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+			dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+					 "Build SLP failed: "
+					 "op not supported by target.");
 	  	      vect_free_oprnd_info (&oprnds_info);
 		      return false;
 		    }
@@ -659,11 +674,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                        || first_stmt_code == COMPONENT_REF
                        || first_stmt_code == MEM_REF)))
 	    {
-	      if (vect_print_dump_info (REPORT_SLP))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: different operation in stmt ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: different operation "
+				   "in stmt ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}

 	      vect_free_oprnd_info (&oprnds_info);
@@ -673,11 +689,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	  if (need_same_oprnds
 	      && !operand_equal_p (first_op1, gimple_assign_rhs2 (stmt), 0))
 	    {
-	      if (vect_print_dump_info (REPORT_SLP))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump,
-			   "Build SLP failed: different shift arguments in ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: different shift "
+				   "arguments in ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}

 	      vect_free_oprnd_info (&oprnds_info);
@@ -693,11 +710,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		  || gimple_call_fntype (first_stmt)
 		     != gimple_call_fntype (stmt))
 		{
-		  if (vect_print_dump_info (REPORT_SLP))
+		  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		    {
-		      fprintf (vect_dump,
-			       "Build SLP failed: different calls in ");
-		      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				       "Build SLP failed: different calls in ");
+		      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					stmt, 0);
 		    }

 		  vect_free_oprnd_info (&oprnds_info);
@@ -731,11 +749,13 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                   || (GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) != stmt
                       && GROUP_GAP (vinfo_for_stmt (stmt)) != 1))
                 {
-                  if (vect_print_dump_info (REPORT_SLP))
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                     {
-                      fprintf (vect_dump, "Build SLP failed: grouped "
-                                          "loads have gaps ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				       "Build SLP failed: grouped "
+				       "loads have gaps ");
+                      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					stmt, 0);
                     }

 	  	  vect_free_oprnd_info (&oprnds_info);
@@ -747,12 +767,14 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
               if (loop_vinfo
                   && GROUP_SIZE (vinfo_for_stmt (stmt)) > ncopies * group_size)
                 {
-                  if (vect_print_dump_info (REPORT_SLP))
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                     {
-                      fprintf (vect_dump, "Build SLP failed: the number of "
-                                          "interleaved loads is greater than"
-                                          " the SLP group size ");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				       "Build SLP failed: the number "
+				       "of interleaved loads is greater than "
+				       "the SLP group size ");
+                      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					stmt, 0);
                     }

 	  	  vect_free_oprnd_info (&oprnds_info);
@@ -767,16 +789,19 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                      chains in the same node.  The only exception is complex
                      numbers.  */
                   if (prev_first_load != first_load
-                      && rhs_code != REALPART_EXPR
+                      && rhs_code != REALPART_EXPR
                       && rhs_code != IMAGPART_EXPR)
-                    {
-                      if (vect_print_dump_info (REPORT_SLP))
+                    {
+                      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                         {
-                          fprintf (vect_dump, "Build SLP failed: different "
-                                           "interleaving chains in one node ");
-                          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                          dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+					   vect_location,
+					   "Build SLP failed: different "
+					   "interleaving chains in one node ");
+                          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					    stmt, 0);
                         }
-
+
 	  	      vect_free_oprnd_info (&oprnds_info);
                       return false;
                     }
@@ -792,11 +817,14 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
                   if (vect_supportable_dr_alignment (first_dr, false)
                       == dr_unaligned_unsupported)
                     {
-                      if (vect_print_dump_info (REPORT_SLP))
+                      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                         {
-                          fprintf (vect_dump, "Build SLP failed: unsupported "
-                                              "unaligned load ");
-                          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                          dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+					   vect_location,
+					   "Build SLP failed: unsupported "
+					   "unaligned load ");
+                          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					    stmt, 0);
                         }

 	  	      vect_free_oprnd_info (&oprnds_info);
@@ -829,10 +857,11 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	  if (TREE_CODE_CLASS (rhs_code) == tcc_reference)
 	    {
 	      /* Not grouped load.  */
-	      if (vect_print_dump_info (REPORT_SLP))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump, "Build SLP failed: not grouped load ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: not grouped load ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}

 	      /* FORNOW: Not grouped loads are not supported.  */
@@ -846,11 +875,12 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 	      && rhs_code != COND_EXPR
 	      && rhs_code != CALL_EXPR)
 	    {
-	      if (vect_print_dump_info (REPORT_SLP))
+	      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		{
-		  fprintf (vect_dump, "Build SLP failed: operation");
-		  fprintf (vect_dump, " unsupported ");
-		  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+		  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: operation");
+		  dump_printf (MSG_MISSED_OPTIMIZATION, " unsupported ");
+		  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
 		}

 	      vect_free_oprnd_info (&oprnds_info);
@@ -865,11 +895,13 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_
 		first_cond_code = TREE_CODE (cond_expr);
               else if (first_cond_code != TREE_CODE (cond_expr))
                 {
-                  if (vect_print_dump_info (REPORT_SLP))
+                  if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                     {
-                      fprintf (vect_dump, "Build SLP failed: different"
-					  " operation");
-                      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				       "Build SLP failed: different"
+				       " operation");
+                      dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					stmt, 0);
                     }

 		  vect_free_oprnd_info (&oprnds_info);
@@ -946,7 +978,7 @@ vect_build_slp_tree (loop_vec_info loop_vinfo, bb_


 static void
-vect_print_slp_tree (slp_tree node)
+vect_print_slp_tree (enum dump_msg_kind msg_type, slp_tree node)
 {
   int i;
   gimple stmt;
@@ -955,16 +987,16 @@ static void
   if (!node)
     return;

-  fprintf (vect_dump, "node ");
+  dump_printf (msg_type, "node ");
   FOR_EACH_VEC_ELT (gimple, SLP_TREE_SCALAR_STMTS (node), i, stmt)
     {
-      fprintf (vect_dump, "\n\tstmt %d ", i);
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      dump_printf (msg_type, "\n\tstmt %d ", i);
+      dump_gimple_stmt (msg_type, TDF_SLIM, stmt, 0);
     }
-  fprintf (vect_dump, "\n");
+  dump_printf (msg_type, "\n");

   FOR_EACH_VEC_ELT (slp_void_p, SLP_TREE_CHILDREN (node), i, child)
-    vect_print_slp_tree ((slp_tree) child);
+    vect_print_slp_tree (msg_type, (slp_tree) child);
 }


@@ -1047,11 +1079,13 @@ vect_supported_slp_permutation_p (slp_instance ins
       /* Check that the loads are all in the same interleaving chain.  */
       if (GROUP_FIRST_ELEMENT (vinfo_for_stmt (scalar_stmt)) != first_load)
         {
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "Build SLP failed: unsupported data "
-                                   "permutation ");
-              print_gimple_stmt (vect_dump, scalar_stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "Build SLP failed: unsupported data "
+			       "permutation ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+				scalar_stmt, 0);
             }

           free (tmp_loads);
@@ -1134,11 +1168,11 @@ vect_supported_load_permutation_p (slp_instance sl
   if (!slp_instn)
     return false;

-  if (vect_print_dump_info (REPORT_SLP))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "Load permutation ");
+      dump_printf_loc (MSG_NOTE, vect_location, "Load permutation ");
       FOR_EACH_VEC_ELT (int, load_permutation, i, next)
-        fprintf (vect_dump, "%d ", next);
+        dump_printf (MSG_NOTE, "%d ", next);
     }

   /* In case of reduction every load permutation is allowed, since the order
@@ -1341,11 +1375,13 @@ vect_supported_load_permutation_p (slp_instance sl
                   if (vect_supportable_dr_alignment (dr, false)
  	               == dr_unaligned_unsupported)
                     {
-   		      if (vect_print_dump_info (REPORT_SLP))
+   		      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 		        {
-  	                  fprintf (vect_dump, "unsupported unaligned load ");
-                          print_gimple_stmt (vect_dump, first_load, 0,
-					     TDF_SLIM);
+  	                  dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+					   vect_location,
+					   "unsupported unaligned load ");
+                          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM,
+					    first_load, 0);
                         }
   		      bad_permutation = true;
                       break;
@@ -1499,10 +1535,11 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf

   if (!vectype)
     {
-      if (vect_print_dump_info (REPORT_SLP))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "Build SLP failed: unsupported data-type ");
-          print_generic_expr (vect_dump, scalar_type, TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			   "Build SLP failed: unsupported data-type ");
+          dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, scalar_type);
         }

       return false;
@@ -1518,9 +1555,10 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
   unrolling_factor = least_common_multiple (nunits, group_size) / group_size;
   if (unrolling_factor != 1 && !loop_vinfo)
     {
-      if (vect_print_dump_info (REPORT_SLP))
-        fprintf (vect_dump, "Build SLP failed: unrolling required in basic"
-                            " block SLP");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "Build SLP failed: unrolling required in basic"
+			 " block SLP");

       return false;
     }
@@ -1579,9 +1617,10 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf

       if (unrolling_factor != 1 && !loop_vinfo)
         {
-          if (vect_print_dump_info (REPORT_SLP))
-            fprintf (vect_dump, "Build SLP failed: unrolling required in basic"
-                               " block SLP");
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			     "Build SLP failed: unrolling required in basic"
+			     " block SLP");
 	  vect_free_slp_tree (node);
 	  VEC_free (stmt_info_for_cost, heap, body_cost_vec);
 	  VEC_free (stmt_info_for_cost, heap, prologue_cost_vec);
@@ -1605,11 +1644,12 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
           if (!vect_supported_load_permutation_p (new_instance, group_size,
                                                   load_permutation))
             {
-              if (vect_print_dump_info (REPORT_SLP))
+              if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
                 {
-                  fprintf (vect_dump, "Build SLP failed: unsupported load "
-                                      "permutation ");
-                  print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+                  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+				   "Build SLP failed: unsupported load "
+				   "permutation ");
+                  dump_gimple_stmt (MSG_MISSED_OPTIMIZATION,
TDF_SLIM, stmt, 0);
                 }

               vect_free_slp_instance (new_instance);
@@ -1644,8 +1684,8 @@ vect_analyze_slp_instance (loop_vec_info loop_vinf
         VEC_safe_push (slp_instance, heap, BB_VINFO_SLP_INSTANCES (bb_vinfo),
                        new_instance);

-      if (vect_print_dump_info (REPORT_SLP))
-	vect_print_slp_tree (node);
+      if (dump_kind_p (MSG_NOTE))
+	vect_print_slp_tree (MSG_NOTE, node);

       return true;
     }
@@ -1676,8 +1716,8 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec
   gimple first_element;
   bool ok = false;

-  if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_analyze_slp ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "=== vect_analyze_slp ===");

   if (loop_vinfo)
     {
@@ -1695,8 +1735,9 @@ vect_analyze_slp (loop_vec_info loop_vinfo, bb_vec

   if (bb_vinfo && !ok)
     {
-      if (vect_print_dump_info (REPORT_SLP))
-        fprintf (vect_dump, "Failed to SLP the basic block.");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "Failed to SLP the basic block.");

       return false;
     }
@@ -1738,8 +1779,8 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)
   slp_instance instance;
   int decided_to_slp = 0;

-  if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_make_slp_decision ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "===
vect_make_slp_decision ===");

   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     {
@@ -1756,9 +1797,10 @@ vect_make_slp_decision (loop_vec_info loop_vinfo)

   LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo) = unrolling_factor;

-  if (decided_to_slp && vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "Decided to SLP %d instances. Unrolling factor %d",
-	     decided_to_slp, unrolling_factor);
+  if (decided_to_slp && dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+		     "Decided to SLP %d instances. Unrolling factor %d",
+		     decided_to_slp, unrolling_factor);

   return (decided_to_slp > 0);
 }
@@ -1820,8 +1862,8 @@ vect_detect_hybrid_slp (loop_vec_info loop_vinfo)
   VEC (slp_instance, heap) *slp_instances = LOOP_VINFO_SLP_INSTANCES
(loop_vinfo);
   slp_instance instance;

-  if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_detect_hybrid_slp ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "===
vect_detect_hybrid_slp ===");

   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     vect_detect_hybrid_slp_stmts (SLP_INSTANCE_TREE (instance));
@@ -2017,14 +2059,14 @@ vect_bb_vectorization_profitable_p (bb_vec_info bb

   vec_outside_cost = vec_prologue_cost + vec_epilogue_cost;

-  if (vect_print_dump_info (REPORT_COST))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "Cost model analysis: \n");
-      fprintf (vect_dump, "  Vector inside of basic block cost: %d\n",
-               vec_inside_cost);
-      fprintf (vect_dump, "  Vector prologue cost: %d\n", vec_prologue_cost);
-      fprintf (vect_dump, "  Vector epilogue cost: %d\n", vec_epilogue_cost);
-      fprintf (vect_dump, "  Scalar cost of basic block: %d", scalar_cost);
+      dump_printf_loc (MSG_NOTE, vect_location, "Cost model analysis: \n");
+      dump_printf (MSG_NOTE, "  Vector inside of basic block cost: %d\n",
+		   vec_inside_cost);
+      dump_printf (MSG_NOTE, "  Vector prologue cost: %d\n",
vec_prologue_cost);
+      dump_printf (MSG_NOTE, "  Vector epilogue cost: %d\n",
vec_epilogue_cost);
+      dump_printf (MSG_NOTE, "  Scalar cost of basic block: %d", scalar_cost);
     }

   /* Vectorization is profitable if its cost is less than the cost of scalar
@@ -2054,9 +2096,10 @@ vect_slp_analyze_bb_1 (basic_block bb)

   if (!vect_analyze_data_refs (NULL, bb_vinfo, &min_vf))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unhandled data-ref in basic "
-                            "block.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: unhandled data-ref in basic "
+			 "block.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2065,9 +2108,10 @@ vect_slp_analyze_bb_1 (basic_block bb)
   ddrs = BB_VINFO_DDRS (bb_vinfo);
   if (!VEC_length (ddr_p, ddrs))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: not enough data-refs in basic "
-                            "block.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: not enough data-refs in "
+			 "basic block.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2078,9 +2122,10 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (!vect_analyze_data_ref_dependences (NULL, bb_vinfo, &max_vf)
        || min_vf > max_vf)
      {
-       if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	 fprintf (vect_dump, "not vectorized: unhandled data dependence "
-		  "in basic block.\n");
+       if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+	 dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			  "not vectorized: unhandled data dependence "
+			  "in basic block.\n");

        destroy_bb_vec_info (bb_vinfo);
        return NULL;
@@ -2088,9 +2133,10 @@ vect_slp_analyze_bb_1 (basic_block bb)

   if (!vect_analyze_data_refs_alignment (NULL, bb_vinfo))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: bad data alignment in basic "
-                            "block.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: bad data alignment in basic "
+			 "block.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2098,9 +2144,10 @@ vect_slp_analyze_bb_1 (basic_block bb)

   if (!vect_analyze_data_ref_accesses (NULL, bb_vinfo))
     {
-     if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-       fprintf (vect_dump, "not vectorized: unhandled data access in basic "
-                           "block.\n");
+     if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			"not vectorized: unhandled data access in "
+			"basic block.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2110,9 +2157,10 @@ vect_slp_analyze_bb_1 (basic_block bb)
      trees.  */
   if (!vect_analyze_slp (NULL, bb_vinfo))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: failed to find SLP opportunities "
-                            "in basic block.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: failed to find SLP opportunities "
+			 "in basic block.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2130,18 +2178,19 @@ vect_slp_analyze_bb_1 (basic_block bb)

   if (!vect_verify_datarefs_alignment (NULL, bb_vinfo))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: unsupported alignment in basic "
-                            "block.\n");
-
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                         "not vectorized: unsupported alignment in basic "
+                         "block.\n");
       destroy_bb_vec_info (bb_vinfo);
       return NULL;
     }

   if (!vect_slp_analyze_operations (bb_vinfo))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: bad operation in basic block.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: bad operation in basic block.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
@@ -2151,16 +2200,18 @@ vect_slp_analyze_bb_1 (basic_block bb)
   if (flag_vect_cost_model
       && !vect_bb_vectorization_profitable_p (bb_vinfo))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: vectorization is not "
-                            "profitable.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: vectorization is not "
+			 "profitable.\n");

       destroy_bb_vec_info (bb_vinfo);
       return NULL;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "Basic block will be vectorized using SLP\n");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "Basic block will be vectorized using SLP\n");

   return bb_vinfo;
 }
@@ -2174,8 +2225,8 @@ vect_slp_analyze_bb (basic_block bb)
   gimple_stmt_iterator gsi;
   unsigned int vector_sizes;

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "===vect_slp_analyze_bb===\n");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "===vect_slp_analyze_bb===\n");

   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
     {
@@ -2188,9 +2239,10 @@ vect_slp_analyze_bb (basic_block bb)

   if (insns > PARAM_VALUE (PARAM_SLP_MAX_INSNS_IN_BB))
     {
-      if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-        fprintf (vect_dump, "not vectorized: too many instructions in basic "
-                            "block.\n");
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
+        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			 "not vectorized: too many instructions in "
+			 "basic block.\n");

       return NULL;
     }
@@ -2214,9 +2266,10 @@ vect_slp_analyze_bb (basic_block bb)

       /* Try the next biggest vector size.  */
       current_vector_size = 1 << floor_log2 (vector_sizes);
-      if (vect_print_dump_info (REPORT_DETAILS))
-        fprintf (vect_dump, "***** Re-trying analysis with "
-                 "vector size %d\n", current_vector_size);
+      if (dump_kind_p (MSG_NOTE))
+        dump_printf_loc (MSG_NOTE, vect_location,
+			 "***** Re-trying analysis with "
+			 "vector size %d\n", current_vector_size);
     }
 }

@@ -2238,8 +2291,9 @@ vect_update_slp_costs_according_to_vf (loop_vec_in
   stmt_info_for_cost *si;
   void *data = LOOP_VINFO_TARGET_COST_DATA (loop_vinfo);

-  if (vect_print_dump_info (REPORT_SLP))
-    fprintf (vect_dump, "=== vect_update_slp_costs_according_to_vf ===");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location,
+		     "=== vect_update_slp_costs_according_to_vf ===");

   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
     {
@@ -2719,10 +2773,11 @@ vect_get_mask_element (gimple stmt, int first_mask
      the next vector as well.  */
   if (only_one_vec && *current_mask_element >= mask_nunits)
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "permutation requires at least two vectors ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			   "permutation requires at least two vectors ");
+          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }

       return false;
@@ -2736,11 +2791,12 @@ vect_get_mask_element (gimple stmt, int first_mask
           /* We either need the first vector too or have already moved to the
              next vector. In both cases, this permutation needs three
              vectors.  */
-          if (vect_print_dump_info (REPORT_DETAILS))
+          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
             {
-              fprintf (vect_dump, "permutation requires at "
-                                  "least three vectors ");
-              print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+              dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			       "permutation requires at "
+			       "least three vectors ");
+              dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
             }

           return false;
@@ -2801,10 +2857,11 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tr

   if (!can_vec_perm_p (mode, false, NULL))
     {
-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
         {
-          fprintf (vect_dump, "no vect permute for ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+			   "no vect permute for ");
+          dump_gimple_stmt (MSG_MISSED_OPTIMIZATION, TDF_SLIM, stmt, 0);
         }
       return false;
     }
@@ -2880,12 +2937,15 @@ vect_transform_slp_perm_load (gimple stmt, VEC (tr

 		  if (!can_vec_perm_p (mode, false, mask))
 		    {
-		      if (vect_print_dump_info (REPORT_DETAILS))
+		      if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
 			{
-			  fprintf (vect_dump, "unsupported vect permute { ");
+			  dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+					   vect_location,
+					   "unsupported vect permute { ");
 			  for (i = 0; i < nunits; ++i)
-			    fprintf (vect_dump, "%d ", mask[i]);
-			  fprintf (vect_dump, "}\n");
+			    dump_printf (MSG_MISSED_OPTIMIZATION, "%d ",
+					 mask[i]);
+			  dump_printf (MSG_MISSED_OPTIMIZATION, "}\n");
 			}
 		      return false;
 		    }
@@ -2981,10 +3041,11 @@ vect_schedule_slp_instance (slp_tree node, slp_ins
       SLP_TREE_NUMBER_OF_VEC_STMTS (node) = vec_stmts_size;
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
+  if (dump_kind_p (MSG_NOTE))
     {
-      fprintf (vect_dump, "------>vectorizing SLP node starting from: ");
-      print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+      dump_printf_loc (MSG_NOTE,vect_location,
+		       "------>vectorizing SLP node starting from: ");
+      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
     }

   /* Loads should be inserted before the first load.  */
@@ -3089,9 +3150,9 @@ vect_schedule_slp (loop_vec_info loop_vinfo, bb_ve
       /* Schedule the tree of INSTANCE.  */
       is_store = vect_schedule_slp_instance (SLP_INSTANCE_TREE (instance),
                                              instance, vf);
-      if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)
-	  || vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS))
-	fprintf (vect_dump, "vectorizing stmts using SLP.");
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "vectorizing stmts using SLP.");
     }

   FOR_EACH_VEC_ELT (slp_instance, slp_instances, i, instance)
@@ -3134,18 +3195,19 @@ vect_slp_transform_bb (basic_block bb)

   gcc_assert (bb_vinfo);

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "SLPing BB\n");
+  if (dump_kind_p (MSG_NOTE))
+    dump_printf_loc (MSG_NOTE, vect_location, "SLPing BB\n");

   for (si = gsi_start_bb (bb); !gsi_end_p (si); gsi_next (&si))
     {
       gimple stmt = gsi_stmt (si);
       stmt_vec_info stmt_info;

-      if (vect_print_dump_info (REPORT_DETAILS))
+      if (dump_kind_p (MSG_NOTE))
         {
-          fprintf (vect_dump, "------>SLPing statement: ");
-          print_gimple_stmt (vect_dump, stmt, 0, TDF_SLIM);
+          dump_printf_loc (MSG_NOTE, vect_location,
+                           "------>SLPing statement: ");
+          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, stmt, 0);
         }

       stmt_info = vinfo_for_stmt (stmt);
@@ -3159,9 +3221,8 @@ vect_slp_transform_bb (basic_block bb)
         }
     }

-  if (vect_print_dump_info (REPORT_DETAILS))
-    fprintf (vect_dump, "BASIC BLOCK VECTORIZED\n");
+  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
+    dump_printf (MSG_OPTIMIZED_LOCATIONS, "BASIC BLOCK VECTORIZED\n");

   destroy_bb_vec_info (bb_vinfo);
 }
-
Index: statistics.c
===================================================================
--- statistics.c	(revision 191208)
+++ statistics.c	(working copy)
@@ -255,7 +255,7 @@ void
 statistics_init (void)
 {
   statistics_dump_file = dump_begin (statistics_dump_nr, NULL);
-  statistics_dump_flags = get_dump_file_info (statistics_dump_nr)->flags;
+  statistics_dump_flags = get_dump_file_info (statistics_dump_nr)->pflags;
 }

 /* Lookup or add a statistics counter in the hashtable HASH with ID, VAL

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
       [not found]                                                     ` <CAFiYyc3AJ1C92QhZHTk83rZPgLSqwk+=qgYDeY9HG-p4UPRrMA@mail.gmail.com>
@ 2012-09-12 10:40                                                       ` Richard Guenther
  2012-09-12 16:47                                                       ` Xinliang David Li
  1 sibling, 0 replies; 71+ messages in thread
From: Richard Guenther @ 2012-09-12 10:40 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Wed, Sep 12, 2012 at 12:30 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 10:12 AM, Sharad Singhai <singhai@google.com> wrote:
>> Thanks for your comments. Please see my responses inline.
>>
>> On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
>>> Can you resend your patch in text form (also need to resolve the
>>> latest conflicts) so that it can be commented inline?
>>
>> I tried to include inline patch earlier but my message was bounced
>> back from patches mailing list. I am trying it again.
>>
>>> Please also provide as summary a more up-to-date description of
>>> 1) Command line option syntax and semantics
>>
>> I added some documentation in the patch. Here are the relevant bits
>> from invoke.texi.
>>
>> `-fdump-tree-SWITCH-OPTIONS=FILENAME'
>>      Control the dumping at various stages of processing the
>>      intermediate language tree to a file.  The file name is generated
>>      by appending a switch-specific suffix to the source file name, and
>>      the file is created in the same directory as the output file. In
>>      case of `=FILENAME' option, the dump is output on the given file
>>      instead of the auto named dump files.
>>      ...
>>
>>     `=FILENAME'
>>           Instead of an auto named dump file, output into the given file
>>           name. The file names `stdout' and `stderr' are treated
>>           specially and are considered already open standard streams.
>>           For example,
>>
>>                gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>>                     -fdump-tree-pre=stderr file.c
>>
>>           outputs vectorizer dump into `foo.dump', while the PRE dump
>>           is output on to `stderr'. If two conflicting dump filenames
>>           are given for the same pass, then the latter option
>>           overrides the earlier one.
>>
>> `-fopt-info-PASS'
>> `-fopt-info-PASS-OPTIONS'
>> `-fopt-info-PASS-OPTIONS=FILENAME'
>>      Controls optimization dumps from various passes. If the `-OPTIONS'
>>      form is used, OPTIONS is a list of `-' separated options which
>>      controls the details of the dump.  If OPTIONS is not specified, it
>>      defaults to `optimized'. If the FILENAME is not specified, it
>>      defaults to `stderr'. Note that the output FILENAME will be
>>      overwritten in case of multiple translation units. If a combined
>>      output from multiple the translation units is desired, `stderr'
>>      should be used instead.
>>
>>      The PASS could be one of the tree or rtl passes. The following
>>      options are available
>
> I don't like that we have -PASS here.  That makes it awfully similar
> to -fdump-PASS-OPTIONS=FILENAME.  Are we merely having
> -fopt-info because OPTIONS are "different"?
>
>>     `optimized'
>>           Print information when a particular optimization is
>>           successfully applied. It is up to the pass to decide which
>>           information is relevant. For example, the vectorizer pass
>>           prints the location of loop which got vectorized.
>>
>>     `missed'
>>           Print information about missed optimizations. Individual
>>           passes control which information to include in the output.
>>           For example,
>>
>>                gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed
>
> At least for -PASS better names should be available.  And given the
> lack of pass support for the new scheme (apart from the vectorizer)
> we should enumerate the set of -PASS values we accept, currently
> -vec only.  IMHO it does not make sense to provide -fopt-info for
> the myriad of passes we have - usually only high-level ones are interesting
> to the user?
>
>>           will print information about missed vectorization
>>           opportunities on to stderr.
>>
>>     `note'
>>           Print verbose information about optimizations, such as certain
>>           transformations, more detailed information about decisions
>>           etc.
>>
>>     `details'
>>           Print detailed information from a particular pass. This
>>           includes OPTIMIZED, MISSED, and NOTE. For example,
>>
>>                gcc -O2 -ftree-vectorize
>> -fopt-info-tree-vect-details=vect.details
>>
>>           outputs detailed optimization report from the vectorization
>>           pass into `vect.details'.
>
> Can options be chained?  like -fopt-info-vec-missed-note?
>
>> `-fopt-info-tree-all'
>> `-fopt-info-tree-all-OPTIONS'
>> `-fopt-info-tree-all-OPTIONS=FILENAME'
>>      This is similar to `-fopt-info' but instead of a single pass, it
>>      applies the dump options to all the tree passes. If the FILENAME
>>      is provided, the dump from all the passes is concatenated,
>>      otherwise the dump is output onto `stderr'. If OPTIONS is omitted,
>>      it defaults to `optimized'.
>>
>>           gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump
>>
>>      This will output information about missed optimizations as well as
>>      optimized locations from all the tree passes into `tree.optdump'.
>
> That should be -fopt-info, thus omitting -PASS should default to enabling
> all.
>
>>> 2) New dumping APIs and semantics
>>
>> New dumping API:
>>
>> dump_kind_p ==> predicate for whether a particular type of dump is enabled
>> or not. Uses both dump_flags (TDF_*) and opt_info_flags (MSG_*).
>>
>> There are two variants, dump_xxx and dump_xxx_loc, the _loc variant is similar,
>> except it also prints the source location. The source location is
>> useful in certain
>> type of dumps, specially for -fopt-info.
>>
>> Most of these are straightforward.
>>
>> dump_gimple_stmt
>> dump_gimple_stmt_loc
>> dump_generic_expr
>> dump_generic_expr_loc
>> dump_printf
>> dump_printf_loc
>> dump_basic_block
>> dump_combine_total_stats
>>
>> dump_start/dump_finish:
>>
>> Before beginning of each pass, one needs to call dump_start ()
>> and at the end must call dump_finish (). I have already added the required
>> calls in passes.c.
>>
>> Instead of using dump_file directly, use one of the dump_* functions
>> declared in dumpfile.h. For example, dump_basic_block (...)
>> should be used for printing a basic block instead of accessing a dump stream
>> directly.
>>
>>> 3) Conversion changes
>>
>> I have converted vectorizer passes to use the new API. Here is an example
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_loop_bound ===");
>>
>> Instead of calling fprintf on vect_dump directly, use
>> dump_printf_loc. This dump is done only when the
>> MSG_OPTIMIZED_LOCATIONS dump is enabled. Both -fopt-info dumps and
>> regular pass dumps are handled uniformly by treating MSG_* flags as
>> extensions of dump flags.
>>
>> Unfortunately, for vectorizer passes the change was not mechanical. I had to
>> decide for each individual dump site what type of dump was appropriate there.
>> Another added wrinkle was that the source location was printed as a side-effect.
>> Thus I had to convert some calls to use dump_*_loc variant, but not others.
>
> That was expected I guess.
>
>>> Looking at the patch briefly, I am confused with the opt-info syntax.
>>> I thought the following is desired:
>>>
>>> -fopt-info=pass-flags
>>>
>>> where pass is the pass name, and flags is one of [optimized, notes,
>>> missed].  Both pass and flags can be omitted.
>>>
>>> Is it implemented this way in your patch?
>>
>> Close to it but not quite the same way.
>> I considered this syntax and in fact implemented it. But later updated it to
>> use -fopt-info-PASS-FLAGS=filename instead, since it was consistent with the
>> -fdump-PASS-FLAGS=filename. Thus it is very easy to specify opt info
>> flags for a specific
>> pass. For example,
>>
>> -fdump-tree-pre=filename ==> dump PRE pass info
>> -fopt-info-tree-pre=filename  ==> dump PRE optimization info
>>
>> Hopefully this syntax is not confusing.
>
> See above ;)  I think the -fdump- interface is somewhat confusing, so we should
> take the chance to design something better for -fopt-info which is targeted at
> GCC users and not developers.
>
> Aside from the -fopt-info flags management the patch is ok.  To go forward
> and allow others to adjust passes besides the vectorizer -fopt-info syntax
> can be massaged as a followup.
>
> Thus, ok if it bootstraps and regtests ok.

Re-sent, shortened for the list where it hits the message limit ...  you might
want to send the vectorizer pieces separately.

Richard.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
       [not found]                                                     ` <CAFiYyc3AJ1C92QhZHTk83rZPgLSqwk+=qgYDeY9HG-p4UPRrMA@mail.gmail.com>
  2012-09-12 10:40                                                       ` Richard Guenther
@ 2012-09-12 16:47                                                       ` Xinliang David Li
  2012-09-13 11:08                                                         ` Richard Guenther
  1 sibling, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-09-12 16:47 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Wed, Sep 12, 2012 at 3:30 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 10:12 AM, Sharad Singhai <singhai@google.com> wrote:
>> Thanks for your comments. Please see my responses inline.
>>
>> On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
>>> Can you resend your patch in text form (also need to resolve the
>>> latest conflicts) so that it can be commented inline?
>>
>> I tried to include inline patch earlier but my message was bounced
>> back from patches mailing list. I am trying it again.
>>
>>> Please also provide as summary a more up-to-date description of
>>> 1) Command line option syntax and semantics
>>
>> I added some documentation in the patch. Here are the relevant bits
>> from invoke.texi.
>>
>> `-fdump-tree-SWITCH-OPTIONS=FILENAME'
>>      Control the dumping at various stages of processing the
>>      intermediate language tree to a file.  The file name is generated
>>      by appending a switch-specific suffix to the source file name, and
>>      the file is created in the same directory as the output file. In
>>      case of `=FILENAME' option, the dump is output on the given file
>>      instead of the auto named dump files.
>>      ...
>>
>>     `=FILENAME'
>>           Instead of an auto named dump file, output into the given file
>>           name. The file names `stdout' and `stderr' are treated
>>           specially and are considered already open standard streams.
>>           For example,
>>
>>                gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>>                     -fdump-tree-pre=stderr file.c
>>
>>           outputs vectorizer dump into `foo.dump', while the PRE dump
>>           is output on to `stderr'. If two conflicting dump filenames
>>           are given for the same pass, then the latter option
>>           overrides the earlier one.
>>
>> `-fopt-info-PASS'
>> `-fopt-info-PASS-OPTIONS'
>> `-fopt-info-PASS-OPTIONS=FILENAME'
>>      Controls optimization dumps from various passes. If the `-OPTIONS'
>>      form is used, OPTIONS is a list of `-' separated options which
>>      controls the details of the dump.  If OPTIONS is not specified, it
>>      defaults to `optimized'. If the FILENAME is not specified, it
>>      defaults to `stderr'. Note that the output FILENAME will be
>>      overwritten in case of multiple translation units. If a combined
>>      output from multiple the translation units is desired, `stderr'
>>      should be used instead.
>>
>>      The PASS could be one of the tree or rtl passes. The following
>>      options are available
>
> I don't like that we have -PASS here.  That makes it awfully similar
> to -fdump-PASS-OPTIONS=FILENAME.  Are we merely having
> -fopt-info because OPTIONS are "different"?


Having PASS is useful to do filtering. But as your said, the option
design here is very much oriented towards developers not end users
which fopt-info is also intended for.


>
>>     `optimized'
>>           Print information when a particular optimization is
>>           successfully applied. It is up to the pass to decide which
>>           information is relevant. For example, the vectorizer pass
>>           prints the location of loop which got vectorized.
>>
>>     `missed'
>>           Print information about missed optimizations. Individual
>>           passes control which information to include in the output.
>>           For example,
>>
>>                gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed
>
> At least for -PASS better names should be available.  And given the
> lack of pass support for the new scheme (apart from the vectorizer)
> we should enumerate the set of -PASS values we accept, currently
> -vec only.  IMHO it does not make sense to provide -fopt-info for
> the myriad of passes we have - usually only high-level ones are interesting
> to the user?

I like the idea -- can be done via some mapping. The initial mapping
does not need to complete.

>
>>           will print information about missed vectorization
>>           opportunities on to stderr.
>>
>>     `note'
>>           Print verbose information about optimizations, such as certain
>>           transformations, more detailed information about decisions
>>           etc.
>>
>>     `details'
>>           Print detailed information from a particular pass. This
>>           includes OPTIMIZED, MISSED, and NOTE. For example,
>>
>>                gcc -O2 -ftree-vectorize
>> -fopt-info-tree-vect-details=vect.details
>>
>>           outputs detailed optimization report from the vectorization
>>           pass into `vect.details'.
>
> Can options be chained?  like -fopt-info-vec-missed-note?
>
>> `-fopt-info-tree-all'
>> `-fopt-info-tree-all-OPTIONS'
>> `-fopt-info-tree-all-OPTIONS=FILENAME'
>>      This is similar to `-fopt-info' but instead of a single pass, it
>>      applies the dump options to all the tree passes. If the FILENAME
>>      is provided, the dump from all the passes is concatenated,
>>      otherwise the dump is output onto `stderr'. If OPTIONS is omitted,
>>      it defaults to `optimized'.
>>
>>           gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump
>>
>>      This will output information about missed optimizations as well as
>>      optimized locations from all the tree passes into `tree.optdump'.
>
> That should be -fopt-info, thus omitting -PASS should default to enabling
> all.
>

yes.


>>> 2) New dumping APIs and semantics
>>
>> New dumping API:
>>
>> dump_kind_p ==> predicate for whether a particular type of dump is enabled
>> or not. Uses both dump_flags (TDF_*) and opt_info_flags (MSG_*).
>>
>> There are two variants, dump_xxx and dump_xxx_loc, the _loc variant is similar,
>> except it also prints the source location. The source location is
>> useful in certain
>> type of dumps, specially for -fopt-info.
>>
>> Most of these are straightforward.
>>
>> dump_gimple_stmt
>> dump_gimple_stmt_loc
>> dump_generic_expr
>> dump_generic_expr_loc
>> dump_printf
>> dump_printf_loc
>> dump_basic_block
>> dump_combine_total_stats
>>
>> dump_start/dump_finish:
>>
>> Before beginning of each pass, one needs to call dump_start ()
>> and at the end must call dump_finish (). I have already added the required
>> calls in passes.c.
>>
>> Instead of using dump_file directly, use one of the dump_* functions
>> declared in dumpfile.h. For example, dump_basic_block (...)
>> should be used for printing a basic block instead of accessing a dump stream
>> directly.
>>
>>> 3) Conversion changes
>>
>> I have converted vectorizer passes to use the new API. Here is an example
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_loop_bound ===");
>>
>> Instead of calling fprintf on vect_dump directly, use
>> dump_printf_loc. This dump is done only when the
>> MSG_OPTIMIZED_LOCATIONS dump is enabled. Both -fopt-info dumps and
>> regular pass dumps are handled uniformly by treating MSG_* flags as
>> extensions of dump flags.
>>
>> Unfortunately, for vectorizer passes the change was not mechanical. I had to
>> decide for each individual dump site what type of dump was appropriate there.
>> Another added wrinkle was that the source location was printed as a side-effect.
>> Thus I had to convert some calls to use dump_*_loc variant, but not others.
>
> That was expected I guess.
>
>>> Looking at the patch briefly, I am confused with the opt-info syntax.
>>> I thought the following is desired:
>>>
>>> -fopt-info=pass-flags
>>>
>>> where pass is the pass name, and flags is one of [optimized, notes,
>>> missed].  Both pass and flags can be omitted.
>>>
>>> Is it implemented this way in your patch?
>>
>> Close to it but not quite the same way.
>> I considered this syntax and in fact implemented it. But later updated it to
>> use -fopt-info-PASS-FLAGS=filename instead, since it was consistent with the
>> -fdump-PASS-FLAGS=filename. Thus it is very easy to specify opt info
>> flags for a specific
>> pass. For example,
>>
>> -fdump-tree-pre=filename ==> dump PRE pass info
>> -fopt-info-tree-pre=filename  ==> dump PRE optimization info
>>
>> Hopefully this syntax is not confusing.
>
> See above ;)  I think the -fdump- interface is somewhat confusing, so we should
> take the chance to design something better for -fopt-info which is targeted at
> GCC users and not developers.


agree !

thanks,

David

>
> Aside from the -fopt-info flags management the patch is ok.  To go forward
> and allow others to adjust passes besides the vectorizer -fopt-info syntax
> can be massaged as a followup.
>
> Thus, ok if it bootstraps and regtests ok.
>
> Thanks again,
> Richard.
>
>> Thanks,
>> Sharad
>>
>> Actual patch follows.
>> -------------------------------------------
>>
>> 2012-09-12  Sharad Singhai  <singhai@google.com>
>>
>>         * doc/invoke.texi: Add documentation for the new option.
>>         * tree-dump.c: Include "gimple-pretty-print.h".
>>         Include "rtl.h".
>>         (pflags): New variable.
>>         (alt_flags): Ditto.
>>         (alt_dump_file): Ditto.
>>         (dump_files):  Update to include additional fields.
>>         (struct dump_option_value_info): Add additional field.
>>         (get_dump_file_name): Use command line filename if available.
>>         (dump_open_alternate_stream): New function.
>>         (dump_loc): Ditto.
>>         (dump_gimple_stmt): Ditto.
>>         (dump_gimple_stmt_loc): Ditto.
>>         (dump_generic_expr): Ditto.
>>         (dump_generic_expr_loc): Ditto.
>>         (dump_printf): Ditto.
>>         (dump_printf_loc): Ditto.
>>         (dump_start): Ditto.
>>         (dump_finish): Ditto.
>>         (dump_begin): Ditto.
>>         (dump_enabled_p): Return true if either of the dump types is enabled.
>>         (dump_initialized_p): Return true if either type of dump is initialized.
>>         (dump_end): Do not close standard streams.
>>         (dump_enable_all): Handle filenames for regular dumps.
>>         (dump_switch_p_1): Handle command-line dump filenames.
>>         (opt_info_enable_all): New function.
>>         (remap_tdf_to_msg_flags): Ditto.
>>         (opt_info_switch_p_1): Ditto.
>>         (opt_info_switch_p): Ditto.
>>         (dump_kind_p): Ditto.
>>         (dump_basic_block): Ditto.
>>         (dump_combine_total_stats): Ditto.
>>         (dump_remap_tree_vectorizer_verbose): Ditto.
>>         * tree-dump.h: Include "input.h".
>>         * dumpfile.h: Include "coretypes.h".
>>         Include "input.h".
>>         (enum dump_msg_kind): New flags for opt-info.
>>         (struct dump_file_info): Rename flags to pflags, state to pstate,
>>         stream to pstream, filename to pfilename. All callers updated. Add
>>         alt_flags, alt_state, alt_filenmae, alt_stream.
>>         * opts.c: Include "dumpfile.h".
>>         (vect_set_verbosity_level): Remove.
>>         (common_handle_option): Handle -fopt-info flag. Deprecate
>>         -ftree-vectorizer-verbose.
>>         * tree-parloops.c (gather_scalar_reductions): Remove reference to
>>         vect_dump.
>>         * gimple-pretty-print.h: Rename dump_gimple_stmt to
>>         pp_gimple_stmt_1.  All callers updated.
>>         * tree-vect-loop-manip.c: Use dump_printf instead of directly
>>         printing to vect_dump file.
>>         * tree-vect-patterns.c: Include "dumpfile.h".
>>         * tree-vectorizer.c: Include "dumpfile.h". Remove vect_dump.
>>         (vect_set_dump_settings): Remove.
>>         (vect_print_dump_info): Ditto.
>>         * tree-vectorizer.h: Remove declaration of vect_dump and
>>         vect_print_dump_info.
>>         * profile.c: Include "dumpfile.h".
>>         Instead of dump_bb use dump_basic_block.
>>         * tree-vect-loop.c: Include "dumpfile.h".
>>         * tree-vect-data-refs.c: Include "dumpfile.h".
>>         * tree-vect-stmts.c: Include "dumpfile.h".
>>         * tree-vect-slp.c: Include "dumpfile.h".
>>         * flag-types.h: Remove vect_verbosity_levels.
>>         * common.opt: Add -fopt-info. Deprecate -ftree-vectorizer-verbose.
>>         * combine.c: rename dump_combine_stats to debug_combine_stats, and
>>         rename dump_combine_total_stats to print_combine_total_stats. All
>>         callers updated.
>>         * opts-global.c (handle_common_deferred_options): Handle -fopt-info
>>         and -ftree-vectorizer-verbose.
>>         * Makefile.in (tree-dump.o): Update dependencies.
>>         (tree-vect-loop.o): Ditto.
>>         (tree-vect-loop-manip.o): Ditto.
>>         (tree-vect-slp.o): Ditto.
>>         (tree-vect-stmts.o): Ditto.
>>         (tree-vectorizer.o): Ditto.
>>         (opts.o): Ditto.
>>         * passes.c (finish_optimization_passes): Instead of using
>>         dump_begin/dump_end, use dump_start/dump_finish. Do not use dump_file.
>>         (pass_init_dump_file): Ditto.
>>
>> Index: doc/invoke.texi
>> ===================================================================
>> --- doc/invoke.texi     (revision 191208)
>> +++ doc/invoke.texi     (working copy)
>> @@ -330,6 +330,9 @@ Objective-C and Objective-C++ Dialects}.
>>  -fenable-@var{kind}-@var{pass}=@var{range-list} @gol
>>  -fdebug-types-section -fmem-report-wpa @gol
>>  -fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs @gol
>> +-fopt-info-@var{pass}@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
>> +-fopt-info-tree-all@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
>> +-fopt-info-rtl-all@r{[}-@var{options}@r{]}@r{[}=@var{file}@r{]} @gol
>>  -frandom-seed=@var{string} -fsched-verbose=@var{n} @gol
>>  -fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose @gol
>>  -fstack-usage  -ftest-coverage  -ftime-report -fvar-tracking @gol
>> @@ -5345,20 +5348,23 @@ Here are some examples showing uses of these optio
>>
>>  @item -d@var{letters}
>>  @itemx -fdump-rtl-@var{pass}
>> +@itemx -fdump-rtl-@var{pass}=@var{filename}
>>  @opindex d
>>  Says to make debugging dumps during compilation at times specified by
>>  @var{letters}.  This is used for debugging the RTL-based passes of the
>>  compiler.  The file names for most of the dumps are made by appending
>>  a pass number and a word to the @var{dumpname}, and the files are
>> -created in the directory of the output file.  Note that the pass
>> -number is computed statically as passes get registered into the pass
>> -manager.  Thus the numbering is not related to the dynamic order of
>> -execution of passes.  In particular, a pass installed by a plugin
>> -could have a number over 200 even if it executed quite early.
>> -@var{dumpname} is generated from the name of the output file, if
>> -explicitly specified and it is not an executable, otherwise it is the
>> -basename of the source file. These switches may have different effects
>> -when @option{-E} is used for preprocessing.
>> +created in the directory of the output file. In case of
>> +@option{=@var{filename}} option, the dump is output on the given file
>> +instead of the pass numbered dump files. Note that the pass number is
>> +computed statically as passes get registered into the pass manager.
>> +Thus the numbering is not related to the dynamic order of execution of
>> +passes.  In particular, a pass installed by a plugin could have a
>> +number over 200 even if it executed quite early.  @var{dumpname} is
>> +generated from the name of the output file, if explicitly specified
>> +and it is not an executable, otherwise it is the basename of the
>> +source file. These switches may have different effects when
>> +@option{-E} is used for preprocessing.
>>
>>  Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
>>  @option{-d} option @var{letters}.  Here are the possible
>> @@ -5739,15 +5745,18 @@ counters for each function compiled.
>>
>>  @item -fdump-tree-@var{switch}
>>  @itemx -fdump-tree-@var{switch}-@var{options}
>> +@itemx -fdump-tree-@var{switch}-@var{options}=@var{filename}
>>  @opindex fdump-tree
>>  Control the dumping at various stages of processing the intermediate
>>  language tree to a file.  The file name is generated by appending a
>>  switch-specific suffix to the source file name, and the file is
>> -created in the same directory as the output file.  If the
>> -@samp{-@var{options}} form is used, @var{options} is a list of
>> -@samp{-} separated options which control the details of the dump.  Not
>> -all options are applicable to all dumps; those that are not
>> -meaningful are ignored.  The following options are available
>> +created in the same directory as the output file. In case of
>> +@option{=@var{filename}} option, the dump is output on the given file
>> +instead of the auto named dump files.  If the @samp{-@var{options}}
>> +form is used, @var{options} is a list of @samp{-} separated options
>> +which control the details of the dump.  Not all options are applicable
>> +to all dumps; those that are not meaningful are ignored.  The
>> +following options are available
>>
>>  @table @samp
>>  @item address
>> @@ -5785,6 +5794,22 @@ Enable showing the tree dump for each statement.
>>  Enable showing the EH region number holding each statement.
>>  @item scev
>>  Enable showing scalar evolution analysis details.
>> +@item =@var{filename}
>> +Instead of an auto named dump file, output into the given file
>> +name. The file names @file{stdout} and @file{stderr} are treated
>> +specially and are considered already open standard streams. For
>> +example,
>> +
>> +@smallexample
>> +gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>> +     -fdump-tree-pre=stderr file.c
>> +@end smallexample
>> +
>> +outputs vectorizer dump into @file{foo.dump}, while the PRE dump is
>> +output on to @file{stderr}. If two conflicting dump filenames are
>> +given for the same pass, then the latter option overrides the earlier
>> +one.
>> +
>>  @item all
>>  Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
>>  and @option{lineno}.
>> @@ -5935,34 +5960,98 @@ is made by appending @file{.vrp} to the source fil
>>  Enable all the available tree dumps with the flags provided in this option.
>>  @end table
>>
>> +@item -fopt-info-@var{pass}
>> +@itemx -fopt-info-@var{pass}-@var{options}
>> +@itemx -fopt-info-@var{pass}-@var{options}=@var{filename}
>> +@opindex fopt-info
>> +Controls optimization dumps from various passes. If the
>> +@samp{-@var{options}} form is used, @var{options} is a list of
>> +@samp{-} separated options which controls the details of the dump.  If
>> +@var{options} is not specified, it defaults to @option{optimized}. If
>> +the @var{filename} is not specified, it defaults to
>> +@file{stderr}. Note that the output @var{filename} will be overwritten
>> +in case of multiple translation units. If a combined output from
>> +multiple the translation units is desired, @file{stderr} should be
>> +used instead.
>> +
>> +The @var{pass} could be one of the tree or rtl passes. The following
>> +options are available
>> +
>> +@table @samp
>> +@item optimized
>> +Print information when a particular optimization is successfully
>> +applied. It is up to the pass to decide which information is
>> +relevant. For example, the vectorizer pass prints the location of loop
>> +which got vectorized.
>> +@item missed
>> +Print information about missed optimizations. Individual passes
>> +control which information to include in the output. For example,
>> +
>> +@smallexample
>> +gcc -O2 -ftree-vectorize -fopt-info-tree-vect-missed
>> +@end smallexample
>> +
>> +will print information about missed vectorization opportunities on
>> +to stderr.
>> +@item note
>> +Print verbose information about optimizations, such as certain
>> +transformations, more detailed information about decisions etc.
>> +@item details
>> +Print detailed information from a particular pass. This includes
>> +@var{optimized}, @var{missed}, and @var{note}. For example,
>> +
>> +@smallexample
>> +gcc -O2 -ftree-vectorize -fopt-info-tree-vect-details=vect.details
>> +@end smallexample
>> +
>> +outputs detailed optimization report from the vectorization pass into
>> +@file{vect.details}.
>> +@end table
>> +
>> +@item -fopt-info-tree-all
>> +@itemx -fopt-info-tree-all-@var{options}
>> +@itemx -fopt-info-tree-all-@var{options}=@var{filename}
>> +@opindex fopt-info-tree-all
>> +This is similar to @option{-fopt-info} but instead of a single pass,
>> +it applies the dump options to all the tree passes. If the
>> +@var{filename} is provided, the dump from all the passes is
>> +concatenated, otherwise the dump is output onto @file{stderr}. If
>> +@var{options} is omitted, it defaults to @option{optimized}.
>> +
>> +@smallexample
>> +gcc -O3 -fopt-info-tree-all-optimized-missed=tree.optdump
>> +@end smallexample
>> +
>> +This will output information about missed optimizations as well as
>> +optimized locations from all the tree passes into @file{tree.optdump}.
>> +
>> +@item -fopt-info-rtl-all
>> +@itemx -fopt-info-rtl-all-@var{options}
>> +@itemx -fopt-info-rtl-all-@var{options}=@var{filename}
>> +@opindex fopt-info-rtl-all
>> +This is similar to @option{-fopt-info-tree-all} but instead of tree
>> +passes, it applies the dump options to all the rtl passes.
>> +
>>  @item -ftree-vectorizer-verbose=@var{n}
>>  @opindex ftree-vectorizer-verbose
>> -This option controls the amount of debugging output the vectorizer prints.
>> -This information is written to standard error, unless
>> -@option{-fdump-tree-all} or @option{-fdump-tree-vect} is specified,
>> -in which case it is output to the usual dump listing file, @file{.vect}.
>> -For @var{n}=0 no diagnostic information is reported.
>> -If @var{n}=1 the vectorizer reports each loop that got vectorized,
>> -and the total number of loops that got vectorized.
>> -If @var{n}=2 the vectorizer also reports non-vectorized loops that passed
>> -the first analysis phase (vect_analyze_loop_form) - i.e.@: countable,
>> -inner-most, single-bb, single-entry/exit loops.  This is the same verbosity
>> -level that @option{-fdump-tree-vect-stats} uses.
>> -Higher verbosity levels mean either more information dumped for each
>> -reported loop, or same amount of information reported for more loops:
>> -if @var{n}=3, vectorizer cost model information is reported.
>> -If @var{n}=4, alignment related information is added to the reports.
>> -If @var{n}=5, data-references related information (e.g.@: memory dependences,
>> -memory access-patterns) is added to the reports.
>> -If @var{n}=6, the vectorizer reports also non-vectorized inner-most loops
>> -that did not pass the first analysis phase (i.e., may not be countable, or
>> -may have complicated control-flow).
>> -If @var{n}=7, the vectorizer reports also non-vectorized nested loops.
>> -If @var{n}=8, SLP related information is added to the reports.
>> -For @var{n}=9, all the information the vectorizer generates during its
>> -analysis and transformation is reported.  This is the same verbosity level
>> -that @option{-fdump-tree-vect-details} uses.
>> +This option is deprecated and is implemented in terms of
>> +@option{-fopt-info}. Please use
>> +@option{-fopt-info-tree-vect-@var{kind}} form instead, where
>> +@var{kind} is one of the valid opt-info kinds. It prints additional
>> +information about the vectorizer pass.  For @var{n}=0 no diagnostic
>> +information is reported.  If @var{n}=1 the vectorizer reports each
>> +loop that got vectorized, and the total number of loops that got
>> +vectorized.  If @var{n}=2 the vectorizer reports locations which could
>> +not be vectorized and the reasons for those. For any higher verbosity
>> +levels all the analysis and transformation information is reported.
>> +This is the same verbosity level that
>> +@option{-fdump-tree-vect-details} uses.
>>
>> +Note that the information output by @option{-ftree-vectorizer-verbose}
>> +option is sent to @file{stderr}. If the equivalent form
>> +@option{-fopt-info-tree-vect-@var{options}=@var{filename}}
>> +is used then the information is output into @var{filename} instead.
>> +
>>  @item -frandom-seed=@var{string}
>>  @opindex frandom-seed
>>  This option provides a seed that GCC uses in place of
>> Index: tree-dump.c
>> ===================================================================
>> --- tree-dump.c (revision 191208)
>> +++ tree-dump.c (working copy)
>> @@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "coretypes.h"
>>  #include "tm.h"
>>  #include "tree.h"
>> +#include "gimple-pretty-print.h"
>>  #include "splay-tree.h"
>>  #include "filenames.h"
>>  #include "diagnostic-core.h"
>> +#include "rtl.h"
>>  #include "toplev.h"
>>  #include "tree-dump.h"
>>  #include "langhooks.h"
>> @@ -37,12 +39,18 @@ along with GCC; see the file COPYING3.  If not see
>>  #define skip_leading_substring(whole,  part) \
>>     (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
>>
>> +static int pflags;                   /* current dump_flags */
>> +static int alt_flags;                /* current opt_info flags */
>> +static FILE *alt_dump_file = NULL;
>>  static unsigned int queue (dump_info_p, const_tree, int);
>>  static void dump_index (dump_info_p, unsigned int);
>>  static void dequeue_and_dump (dump_info_p);
>>  static void dump_new_line (dump_info_p);
>>  static void dump_maybe_newline (dump_info_p);
>> +static void dump_loc (int, FILE *, source_location);
>>
>> +extern void dump_bb (FILE *, basic_block, int, int);
>> +
>>  /* Add T to the end of the queue of nodes to dump.  Returns the index
>>     assigned to T.  */
>>
>> @@ -769,23 +777,28 @@ dump_node (const_tree t, int flags, FILE *stream)
>>
>>
>>  /* Table of tree dump switches. This must be consistent with the
>> -   tree_dump_index enumeration in tree-pass.h.  */
>> +   TREE_DUMP_INDEX enumeration in dumpfile.h.  */
>>  static struct dump_file_info dump_files[TDI_end] =
>>  {
>> -  {NULL, NULL, NULL, 0, 0, 0},
>> -  {".cgraph", "ipa-cgraph", NULL, TDF_IPA, 0,  0},
>> -  {".tu", "translation-unit", NULL, TDF_TREE, 0, 1},
>> -  {".class", "class-hierarchy", NULL, TDF_TREE, 0, 2},
>> -  {".original", "tree-original", NULL, TDF_TREE, 0, 3},
>> -  {".gimple", "tree-gimple", NULL, TDF_TREE, 0, 4},
>> -  {".nested", "tree-nested", NULL, TDF_TREE, 0, 5},
>> -  {".vcg", "tree-vcg", NULL, TDF_TREE, 0, 6},
>> -  {".ads", "ada-spec", NULL, 0, 0, 7},
>> +  {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0},
>> +  {".cgraph", "ipa-cgraph", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0},
>> +  {".tu", "translation-unit", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 1},
>> +  {".class", "class-hierarchy", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 2},
>> +  {".original", "tree-original", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 3},
>> +  {".gimple", "tree-gimple", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 4},
>> +  {".nested", "tree-nested", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0,
>> +   0, 5},
>> +  {".vcg", "tree-vcg", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 6},
>> +  {".ads", "ada-spec", NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 7},
>>  #define FIRST_AUTO_NUMBERED_DUMP 8
>>
>> -  {NULL, "tree-all", NULL, TDF_TREE, 0, 0},
>> -  {NULL, "rtl-all", NULL, TDF_RTL, 0, 0},
>> -  {NULL, "ipa-all", NULL, TDF_IPA, 0, 0},
>> +  {NULL, "tree-all", NULL, NULL, NULL, NULL, NULL, TDF_TREE, 0, 0, 0, 0},
>> +  {NULL, "rtl-all", NULL, NULL, NULL, NULL, NULL, TDF_RTL, 0, 0, 0, 0},
>> +  {NULL, "ipa-all", NULL, NULL, NULL, NULL, NULL, TDF_IPA, 0, 0, 0, 0},
>>  };
>>
>>  /* Dynamically registered tree dump files and switches.  */
>> @@ -798,38 +811,57 @@ struct dump_option_value_info
>>  {
>>    const char *const name;      /* the name of the value */
>>    const int value;             /* the value of the name */
>> +  const int msg_flags;           /* corresponding MSG_* flags */
>>  };
>>
>>  /* Table of dump options. This must be consistent with the TDF_* flags
>> -   in tree.h */
>> +   in dumpfile.h and opt_info_options below. */
>>  static const struct dump_option_value_info dump_options[] =
>>  {
>> -  {"address", TDF_ADDRESS},
>> -  {"asmname", TDF_ASMNAME},
>> -  {"slim", TDF_SLIM},
>> -  {"raw", TDF_RAW},
>> -  {"graph", TDF_GRAPH},
>> -  {"details", TDF_DETAILS},
>> -  {"cselib", TDF_CSELIB},
>> -  {"stats", TDF_STATS},
>> -  {"blocks", TDF_BLOCKS},
>> -  {"vops", TDF_VOPS},
>> -  {"lineno", TDF_LINENO},
>> -  {"uid", TDF_UID},
>> -  {"stmtaddr", TDF_STMTADDR},
>> -  {"memsyms", TDF_MEMSYMS},
>> -  {"verbose", TDF_VERBOSE},
>> -  {"eh", TDF_EH},
>> -  {"alias", TDF_ALIAS},
>> -  {"nouid", TDF_NOUID},
>> -  {"enumerate_locals", TDF_ENUMERATE_LOCALS},
>> -  {"scev", TDF_SCEV},
>> +  {"address", TDF_ADDRESS, 0},
>> +  {"asmname", TDF_ASMNAME, 0},
>> +  {"slim", TDF_SLIM, 0},
>> +  {"raw", TDF_RAW, 0},
>> +  {"graph", TDF_GRAPH, 0},
>> +  {"details", TDF_DETAILS, (MSG_OPTIMIZED_LOCATIONS
>> +                            | MSG_MISSED_OPTIMIZATION
>> +                            | MSG_NOTE)},
>> +  {"cselib", TDF_CSELIB, 0},
>> +  {"stats", TDF_STATS, 0},
>> +  {"blocks", TDF_BLOCKS, 0},
>> +  {"vops", TDF_VOPS, 0},
>> +  {"lineno", TDF_LINENO, 0},
>> +  {"uid", TDF_UID, 0},
>> +  {"stmtaddr", TDF_STMTADDR, 0},
>> +  {"memsyms", TDF_MEMSYMS, 0},
>> +  {"verbose", TDF_VERBOSE, 0},
>> +  {"eh", TDF_EH, 0},
>> +  {"alias", TDF_ALIAS, 0},
>> +  {"nouid", TDF_NOUID, 0},
>> +  {"enumerate_locals", TDF_ENUMERATE_LOCALS, 0},
>> +  {"scev", TDF_SCEV, 0},
>>    {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
>>             | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
>> -           | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV)},
>> -  {NULL, 0}
>> +           | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV),
>> +   (MSG_OPTIMIZED_LOCATIONS
>> +    | MSG_MISSED_OPTIMIZATION
>> +    | MSG_NOTE)},
>> +  {NULL, 0, 0}
>>  };
>>
>> +/* Table of opt-info options. This must be consistent with the MSG_*
>> +   flags in dumpfile.h. The third field of this table is unused. */
>> +static const struct dump_option_value_info opt_info_options[] =
>> +{
>> +  {"optimized", MSG_OPTIMIZED_LOCATIONS, 0},
>> +  {"missed", MSG_MISSED_OPTIMIZATION, 0},
>> +  {"note", MSG_NOTE, 0},
>> +  {"details", (MSG_OPTIMIZED_LOCATIONS
>> +               | MSG_MISSED_OPTIMIZATION
>> +               | MSG_NOTE), 0},
>> +  {NULL, 0, 0}
>> +};
>> +
>>  unsigned int
>>  dump_register (const char *suffix, const char *swtch, const char *glob,
>>                int flags)
>> @@ -854,7 +886,7 @@ dump_register (const char *suffix, const char *swt
>>    extra_dump_files[count].suffix = suffix;
>>    extra_dump_files[count].swtch = swtch;
>>    extra_dump_files[count].glob = glob;
>> -  extra_dump_files[count].flags = flags;
>> +  extra_dump_files[count].pflags = flags;
>>    extra_dump_files[count].num = num;
>>
>>    return count + TDI_end;
>> @@ -888,17 +920,21 @@ get_dump_file_name (int phase)
>>      return NULL;
>>
>>    dfi = get_dump_file_info (phase);
>> -  if (dfi->state == 0)
>> +  if (dfi->pstate == 0)
>>      return NULL;
>>
>> +  /* If available, use the command line dump filename. */
>> +  if (dfi->pfilename)
>> +    return xstrdup (dfi->pfilename);
>> +
>>    if (dfi->num < 0)
>>      dump_id[0] = '\0';
>>    else
>>      {
>>        char suffix;
>> -      if (dfi->flags & TDF_TREE)
>> +      if (dfi->pflags & TDF_TREE)
>>         suffix = 't';
>> -      else if (dfi->flags & TDF_IPA)
>> +      else if (dfi->pflags & TDF_IPA)
>>         suffix = 'i';
>>        else
>>         suffix = 'r';
>> @@ -910,6 +946,248 @@ get_dump_file_name (int phase)
>>    return concat (dump_base_name, dump_id, dfi->suffix, NULL);
>>  }
>>
>> +/* Open an alternate dump filename for PHASE (which could also be a
>> +   standard stream such as stdout/stderr). If the alternate dump file
>> +   cannot be opened, return NULL.  */
>> +
>> +static FILE *
>> +dump_open_alternate_stream (int phase)
>> +{
>> +  FILE *stream ;
>> +  struct dump_file_info *dfi;
>> +
>> +  dfi = get_dump_file_info (phase);
>> +  if (!dfi->alt_filename)
>> +    return NULL;
>> +
>> +  if (dfi->alt_stream)
>> +    return dfi->alt_stream;
>> +
>> +  stream = strcmp("stderr", dfi->alt_filename) == 0
>> +    ? stderr
>> +    : strcmp("stdout", dfi->alt_filename) == 0
>> +    ?  stdout
>> +    : fopen (dfi->alt_filename, dfi->alt_state < 0 ? "w" : "a");
>> +
>> +  if (!stream)
>> +    error ("could not open dump file %qs: %m", dfi->alt_filename);
>> +  else
>> +    dfi->alt_state = 1;
>> +
>> +  return stream;
>> +}
>> +
>> +/* Print source location on DFILE if enabled.  */
>> +
>> +void
>> +dump_loc (int dump_kind, FILE *dfile, source_location loc)
>> +{
>> +  /* Currently vectorization passes print location information.  */
>> +  if (dump_kind)
>> +    {
>> +      if (loc == UNKNOWN_LOCATION)
>> +        fprintf (dfile, "\n%s:%d: note: ",
>> +                 DECL_SOURCE_FILE (current_function_decl),
>> +                 DECL_SOURCE_LINE (current_function_decl));
>> +     else
>> +        fprintf (dfile, "\n%d: ", LOCATION_LINE (loc));
>> +    }
>> +}
>> +
>> +/* Dump gimple statement GS with SPC indentation spaces and
>> +   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
>> +
>> +void
>> +dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int spc)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    print_gimple_stmt (alt_dump_file, gs, spc, dump_flags | extra_dump_flags);
>> +}
>> +
>> +/* Similar to dump_gimple_stmt, except additionally print source location.  */
>> +
>> +void
>> +dump_gimple_stmt_loc (int dump_kind, source_location loc, int extra_dump_flags,
>> +                      gimple gs, int spc)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      dump_loc (dump_kind, dump_file, loc);
>> +      print_gimple_stmt (dump_file, gs, spc, dump_flags | extra_dump_flags);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      dump_loc (dump_kind, alt_dump_file, loc);
>> +      print_gimple_stmt (alt_dump_file, gs, spc, dump_flags |
>> extra_dump_flags);
>> +    }
>> +}
>> +
>> +/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
>> +   enabled.  */
>> +
>> +void
>> +dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
>> +}
>> +
>> +
>> +/* Similar to dump_generic_expr, except additionally print the source
>> +   location.  */
>> +
>> +void
>> +dump_generic_expr_loc (int dump_kind, source_location loc,
>> +                       int extra_dump_flags, tree t)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      dump_loc (dump_kind, dump_file, loc);
>> +      print_generic_expr (dump_file, t, dump_flags | extra_dump_flags);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      dump_loc (dump_kind, alt_dump_file, loc);
>> +      print_generic_expr (alt_dump_file, t, dump_flags | extra_dump_flags);
>> +    }
>> +}
>> +
>> +/* Output a formatted message using FORMAT on appropriate dump streams.  */
>> +
>> +void
>> +dump_printf (int dump_kind, const char *format, ...)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      va_list ap;
>> +      va_start (ap, format);
>> +      vfprintf (dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      va_list ap;
>> +      va_start (ap, format);
>> +      vfprintf (alt_dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +}
>> +
>> +/* Similar to dump_printf, except source location is also printed.  */
>> +
>> +void
>> +dump_printf_loc (int dump_kind, source_location loc, const char *format, ...)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    {
>> +      va_list ap;
>> +      dump_loc (dump_kind, dump_file, loc);
>> +      va_start (ap, format);
>> +      vfprintf (dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    {
>> +      va_list ap;
>> +      dump_loc (dump_kind, alt_dump_file, loc);
>> +      va_start (ap, format);
>> +      vfprintf (alt_dump_file, format, ap);
>> +      va_end (ap);
>> +    }
>> +}
>> +
>> +/* Start a dump for PHASE. Store user-supplied dump flags in
>> +   *FLAG_PTR.  Return the number of streams opened.  Set globals
>> +   DUMP_FILE, and ALT_DUMP_FILE to point to the opened streams, and
>> +   set dump_flags appropriately for both pass dump stream and opt-info
>> +   stream. */
>> +
>> +int
>> +dump_start (int phase, int *flag_ptr)
>> +{
>> +  int count = 0;
>> +  char *name;
>> +  struct dump_file_info *dfi;
>> +  FILE *stream;
>> +  if (phase == TDI_none || !dump_enabled_p (phase))
>> +    return 0;
>> +
>> +  dfi = get_dump_file_info (phase);
>> +  name = get_dump_file_name (phase);
>> +  if (name)
>> +    {
>> +      stream = strcmp("stderr", name) == 0
>> +          ? stderr
>> +          : strcmp("stdout", name) == 0
>> +          ?  stdout
>> +          : fopen (name, dfi->pstate < 0 ? "w" : "a");
>> +      if (!stream)
>> +        error ("could not open dump file %qs: %m", name);
>> +      else
>> +        {
>> +          dfi->pstate = 1;
>> +          count++;
>> +        }
>> +      free (name);
>> +      dfi->pstream = stream;
>> +      dump_file = dfi->pstream;
>> +      /* Initialize current dump flags. */
>> +      pflags = dfi->pflags;
>> +    }
>> +
>> +  stream = dump_open_alternate_stream (phase);
>> +  if (stream)
>> +    {
>> +      dfi->alt_stream = stream;
>> +      count++;
>> +      alt_dump_file = dfi->alt_stream;
>> +      /* Initialize current opt-info flags. */
>> +      alt_flags = dfi->alt_flags;
>> +    }
>> +
>> +  if (flag_ptr)
>> +    *flag_ptr = dfi->pflags;
>> +
>> +  return count;
>> +}
>> +
>> +/* Finish a tree dump for PHASE and close associated dump streams.  Also
>> +   reset the globals DUMP_FILE, ALT_DUMP_FILE, and DUMP_FLAGS.  */
>> +
>> +void
>> +dump_finish (int phase)
>> +{
>> +  struct dump_file_info *dfi;
>> +
>> +  if (phase < 0)
>> +    return;
>> +  dfi = get_dump_file_info (phase);
>> +  if (dfi->pstream)
>> +    fclose (dfi->pstream);
>> +
>> +  if (dfi->alt_stream && strcmp("stderr", dfi->alt_filename) != 0
>> +      && strcmp("stdout", dfi->alt_filename) != 0)
>> +    fclose (dfi->alt_stream);
>> +
>> +  dfi->alt_stream = NULL;
>> +  dfi->pstream = NULL;
>> +  dump_file = NULL;
>> +  alt_dump_file = NULL;
>> +  dump_flags = TDI_none;
>> +  alt_flags = 0;
>> +  pflags = 0;
>> +}
>> +
>>  /* Begin a tree dump for PHASE. Stores any user supplied flag in
>>     *FLAG_PTR and returns a stream to write to. If the dump is not
>>     enabled, returns NULL.
>> @@ -926,22 +1204,33 @@ dump_begin (int phase, int *flag_ptr)
>>      return NULL;
>>
>>    name = get_dump_file_name (phase);
>> +  if (!name)
>> +    return NULL;
>>    dfi = get_dump_file_info (phase);
>> -  stream = fopen (name, dfi->state < 0 ? "w" : "a");
>> +
>> +  stream = strcmp("stderr", name) == 0
>> +    ? stderr
>> +    : strcmp("stdout", name) == 0
>> +    ?  stdout
>> +    : fopen (name, dfi->pstate < 0 ? "w" : "a");
>> +
>>    if (!stream)
>>      error ("could not open dump file %qs: %m", name);
>>    else
>> -    dfi->state = 1;
>> +    dfi->pstate = 1;
>>    free (name);
>>
>>    if (flag_ptr)
>> -    *flag_ptr = dfi->flags;
>> +    *flag_ptr = dfi->pflags;
>>
>> +  /* Initialize current flags */
>> +  pflags = dfi->pflags;
>>    return stream;
>>  }
>>
>> -/* Returns nonzero if tree dump PHASE is enabled.  If PHASE is
>> -   TDI_tree_all, return nonzero if any dump is enabled.  */
>> +/* Returns nonzero if dump PHASE is enabled for at least one stream.
>> +   If PHASE is TDI_tree_all, return nonzero if any dump is enabled for
>> +   any phase.  */
>>
>>  int
>>  dump_enabled_p (int phase)
>> @@ -950,17 +1239,17 @@ dump_enabled_p (int phase)
>>      {
>>        size_t i;
>>        for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -       if (dump_files[i].state)
>> +       if (dump_files[i].pstate || dump_files[i].alt_state)
>>           return 1;
>>        for (i = 0; i < extra_dump_files_in_use; i++)
>> -       if (extra_dump_files[i].state)
>> +       if (extra_dump_files[i].pstate || extra_dump_files[i].alt_state)
>>           return 1;
>>        return 0;
>>      }
>>    else
>>      {
>>        struct dump_file_info *dfi = get_dump_file_info (phase);
>> -      return dfi->state;
>> +      return dfi->pstate || dfi->alt_state;
>>      }
>>  }
>>
>> @@ -970,7 +1259,7 @@ int
>>  dump_initialized_p (int phase)
>>  {
>>    struct dump_file_info *dfi = get_dump_file_info (phase);
>> -  return dfi->state > 0;
>> +  return dfi->pstate > 0 || dfi->alt_state > 0;
>>  }
>>
>>  /* Returns the switch name of PHASE.  */
>> @@ -988,37 +1277,130 @@ dump_flag_name (int phase)
>>  void
>>  dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
>>  {
>> -  fclose (stream);
>> +  if (stream != stderr && stream != stdout)
>> +    fclose (stream);
>>  }
>>
>> -/* Enable all tree dumps.  Return number of enabled tree dumps.  */
>> +/* Enable all tree dumps with FLAGS on FILENAME.  Return number of
>> +   enabled tree dumps.  */
>>
>>  static int
>> -dump_enable_all (int flags)
>> +dump_enable_all (int flags, const char *filename)
>>  {
>>    int ir_dump_type = (flags & (TDF_TREE | TDF_RTL | TDF_IPA));
>>    int n = 0;
>>    size_t i;
>>
>>    for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> -    if ((dump_files[i].flags & ir_dump_type))
>> -      {
>> -        dump_files[i].state = -1;
>> -        dump_files[i].flags |= flags;
>> -        n++;
>> -      }
>> +    {
>> +      if ((dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = dump_files[i].pfilename;
>> +          dump_files[i].pstate = -1;
>> +          dump_files[i].pflags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            {
>> +              dump_files[i].pfilename = xstrdup (filename);
>> +              /* Since it is a command-line provided file, which is
>> +                 common to all the phases, use it in append mode.  */
>> +              dump_files[i].pstate = 1;
>> +            }
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>>
>>    for (i = 0; i < extra_dump_files_in_use; i++)
>> -    if ((extra_dump_files[i].flags & ir_dump_type))
>> -      {
>> -        extra_dump_files[i].state = -1;
>> -        extra_dump_files[i].flags |= flags;
>> -       n++;
>> -      }
>> +    {
>> +      if ((extra_dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = extra_dump_files[i].pfilename;
>> +          extra_dump_files[i].pstate = -1;
>> +          extra_dump_files[i].pflags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            {
>> +              extra_dump_files[i].pfilename = xstrdup (filename);
>> +              /* Since it is a command-line provided file, which is
>> +                 common to all the phases, use it in append mode.  */
>> +              extra_dump_files[i].pstate = 1;
>> +            }
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>>
>>    return n;
>>  }
>>
>> +/* Enable opt-info dumps on all IR_DUMP_TYPE passes with FLAGS on
>> +   FILENAME.  Return the number of enabled dumps.  */
>> +
>> +static int
>> +opt_info_enable_all (int ir_dump_type, int flags, const char *filename)
>> +{
>> +  int n = 0;
>> +  size_t i;
>> +
>> +  for (i = TDI_none + 1; i < (size_t) TDI_end; i++)
>> +    {
>> +      if ((dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = dump_files[i].alt_filename;
>> +          dump_files[i].alt_state = -1;
>> +          dump_files[i].alt_flags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            dump_files[i].alt_filename = xstrdup (filename);
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>> +
>> +  for (i = 0; i < extra_dump_files_in_use; i++)
>> +    {
>> +      if ((extra_dump_files[i].pflags & ir_dump_type))
>> +        {
>> +          const char *old_filename = extra_dump_files[i].alt_filename;
>> +          extra_dump_files[i].alt_state = -1;
>> +          extra_dump_files[i].alt_flags |= flags;
>> +          n++;
>> +          /* Override the existing filename.  */
>> +          if (filename)
>> +            extra_dump_files[i].alt_filename = xstrdup (filename);
>> +          if (old_filename && filename != old_filename)
>> +            free (CONST_CAST (char *, old_filename));
>> +        }
>> +    }
>> +
>> +  return n;
>> +}
>> +
>> +/* For given TDF_FLAGS, return corresponding MSG_* flags. */
>> +
>> +static int
>> +remap_tdf_to_msg_flags (const int tdf_flags)
>> +{
>> +  const struct dump_option_value_info *option_ptr;
>> +  int msg_flags = 0;
>> +
>> +  for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>> +    if ((tdf_flags & option_ptr->value))
>> +      {
>> +        /* If we have msg flags in the table use those, otherwise just
>> +           use tdf_flags for compatibility reasons. Recall that TDF_*
>> +           and MSG_* flags are in exclusive range.  */
>> +        msg_flags |= (option_ptr->msg_flags)
>> +          ? option_ptr->msg_flags
>> +          : option_ptr->value;
>> +      }
>> +  return msg_flags;
>> +}
>> +
>>  /* Parse ARG as a dump switch. Return nonzero if it is, and store the
>>     relevant details in the dump_files array.  */
>>
>> @@ -1036,7 +1418,7 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>    if (!option_value)
>>      return 0;
>>
>> -  if (*option_value && *option_value != '-')
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>>      return 0;
>>
>>    ptr = option_value;
>> @@ -1046,11 +1428,17 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>      {
>>        const struct dump_option_value_info *option_ptr;
>>        const char *end_ptr;
>> +      const char *eq_ptr;
>>        unsigned length;
>>
>>        while (*ptr == '-')
>>         ptr++;
>>        end_ptr = strchr (ptr, '-');
>> +      eq_ptr = strchr (ptr, '=');
>> +
>> +      if (eq_ptr && !end_ptr)
>> +        end_ptr = eq_ptr;
>> +
>>        if (!end_ptr)
>>         end_ptr = ptr + strlen (ptr);
>>        length = end_ptr - ptr;
>> @@ -1058,23 +1446,36 @@ dump_switch_p_1 (const char *arg, struct dump_file
>>        for (option_ptr = dump_options; option_ptr->name; option_ptr++)
>>         if (strlen (option_ptr->name) == length
>>             && !memcmp (option_ptr->name, ptr, length))
>> -         {
>> -           flags |= option_ptr->value;
>> +          {
>> +            flags |= option_ptr->value;
>>             goto found;
>> -         }
>> -      warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>> -              length, ptr, dfi->swtch);
>> +          }
>> +
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  This
>> +             filename overrides other command line filenames.  */
>> +          if (dfi->pfilename)
>> +            free (CONST_CAST (char *, dfi->pfilename));
>> +          dfi->pfilename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +      else
>> +        warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
>> +                 length, ptr, dfi->swtch);
>>      found:;
>>        ptr = end_ptr;
>>      }
>>
>> -  dfi->state = -1;
>> -  dfi->flags |= flags;
>> +  dfi->pstate = -1;
>> +  dfi->pflags |= flags;
>> +  /* Translate these TDF_* flags to the additional MSG_* flags.  */
>> +  dfi->pflags |= remap_tdf_to_msg_flags (flags);
>>
>>    /* Process -fdump-tree-all and -fdump-rtl-all, by enabling all the
>>       known dumps.  */
>>    if (dfi->suffix == NULL)
>> -    dump_enable_all (dfi->flags);
>> +    dump_enable_all (dfi->pflags, dfi->pfilename);
>>
>>    return 1;
>>  }
>> @@ -1104,6 +1505,101 @@ dump_switch_p (const char *arg)
>>    return any;
>>  }
>>
>> +/* Parse ARG as a -fopt-info= switch and store corresponding info in
>> +   DFI.  Return non-zero if it is a recognized switch.  */
>> +
>> +static int
>> +opt_info_switch_p_1 (const char *arg, struct dump_file_info *dfi)
>> +{
>> +  const char *option_value;
>> +  const char *ptr;
>> +  int flags;
>> +
>> +  option_value = skip_leading_substring (arg, dfi->swtch);
>> +  if (!option_value)
>> +    return 0;
>> +
>> +  if (*option_value && *option_value != '-' && *option_value != '=')
>> +    return 0;
>> +
>> +  ptr = option_value;
>> +  flags = 0;
>> +
>> +  while (*ptr)
>> +    {
>> +      const struct dump_option_value_info *option_ptr;
>> +      const char *end_ptr;
>> +      const char *eq_ptr;
>> +      unsigned length;
>> +
>> +      while (*ptr == '-')
>> +       ptr++;
>> +      end_ptr = strchr (ptr, '-');
>> +      eq_ptr = strchr (ptr, '=');
>> +
>> +      if (eq_ptr && !end_ptr)
>> +        end_ptr = eq_ptr;
>> +
>> +      if (!end_ptr)
>> +       end_ptr = ptr + strlen (ptr);
>> +      length = end_ptr - ptr;
>> +
>> +      for (option_ptr = opt_info_options; option_ptr->name; option_ptr++)
>> +       if (strlen (option_ptr->name) == length
>> +           && !memcmp (option_ptr->name, ptr, length))
>> +          {
>> +            flags |= option_ptr->value;
>> +           goto found;
>> +          }
>> +
>> +      if (*ptr == '=')
>> +        {
>> +          /* Interpret rest of the argument as a dump filename.  This
>> +             filename overrides other command line filenames.  */
>> +          if (dfi->alt_filename)
>> +            free (CONST_CAST (char *, dfi->alt_filename));
>> +          dfi->alt_filename = xstrdup (ptr + 1);
>> +          break;
>> +        }
>> +      else
>> +        warning (0, "ignoring unknown option %q.*s in %<-fopt-info=%s%>",
>> +                 length, ptr, dfi->swtch);
>> +    found:;
>> +      ptr = end_ptr;
>> +    }
>> +
>> +  dfi->alt_state = -1;
>> +  /* If there was no command line opt-info dump option, use a default.  */
>> +  if (!flags)
>> +    flags = MSG_OPTIMIZED_LOCATIONS;
>> +  dfi->alt_flags |= flags;
>> +  /* If no filename was provided, use 'stderr'. */
>> +  if (!dfi->alt_filename)
>> +    dfi->alt_filename = xstrdup ("stderr");
>> +
>> +  /* Process -fopt-info-tree-all and -fopt-info-rtl-all, by enabling
>> +     all the known dumps.  */
>> +  if (dfi->suffix == NULL)
>> +    opt_info_enable_all (dfi->pflags, dfi->alt_flags, dfi->alt_filename);
>> +
>> +  return 1;
>> +}
>> +
>> +int
>> +opt_info_switch_p (const char *arg)
>> +{
>> +  size_t i;
>> +  int any = 0;
>> +
>> +  for (i = TDI_none + 1; i != TDI_end; i++)
>> +    any |= opt_info_switch_p_1 (arg, &dump_files[i]);
>> +
>> +  for (i = 0; i < extra_dump_files_in_use; i++)
>> +    any |= opt_info_switch_p_1 (arg, &extra_dump_files[i]);
>> +
>> +  return any;
>> +}
>> +
>>  /* Dump FUNCTION_DECL FN as tree dump PHASE.  */
>>
>>  void
>> @@ -1123,5 +1619,71 @@ dump_function (int phase, tree fn)
>>  bool
>>  enable_rtl_dump_file (void)
>>  {
>> -  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS) > 0;
>> +  return dump_enable_all (TDF_RTL | TDF_DETAILS | TDF_BLOCKS, NULL) > 0;
>>  }
>> +
>> +/* Return true if any dumps are enabled for the given MSG_TYPE, false
>> +   otherwise.  */
>> +
>> +bool
>> +dump_kind_p (int msg_type)
>> +{
>> +  if (!current_function_decl)
>> +    return 0;
>> +  return ((msg_type & pflags) || (msg_type & alt_flags));
>> +}
>> +
>> +/* Print basic block on the dump streams.  */
>> +
>> +void
>> +dump_basic_block (int dump_kind, basic_block bb, int indent)
>> +{
>> +  if (dump_file && (dump_kind & pflags))
>> +    dump_bb (dump_file, bb, indent, TDF_DETAILS);
>> +  if (alt_dump_file && (dump_kind & alt_flags))
>> +    dump_bb (alt_dump_file, bb, indent, TDF_DETAILS);
>> +}
>> +
>> +void
>> +dump_combine_total_stats (void)
>> +{
>> +  if (dump_file)
>> +    print_combine_total_stats (dump_file);
>> +  if (alt_dump_file && (alt_flags & MSG_NOTE))
>> +    print_combine_total_stats (alt_dump_file);
>> +}
>> +
>> +/* Handle -ftree-vectorizer-verbose ARG by remapping it to -fopt-info.
>> +   It remaps the old verbosity values as following:
>> +
>> +   REPORT_NONE ==> No dump is output
>> +   REPORT_VECTORIZED_LOCATIONS ==> "-optimized"
>> +   REPORT_UNVECTORIZED_LOCATIONS ==> "-missed"
>> +
>> +   Any higher verbosity levels result get mapped to "-details" flags.
>> +  */
>> +
>> +void
>> +dump_remap_tree_vectorizer_verbose (const char *arg)
>> +{
>> +  int value = atoi (arg);
>> +  const char *remapped_opt_info = NULL;
>> +
>> +  switch (value)
>> +    {
>> +    case 0:
>> +      break;
>> +    case 1:
>> +      remapped_opt_info = "tree-vect-optimized";
>> +      break;
>> +    case 2:
>> +      remapped_opt_info = "tree-vect-missed";
>> +      break;
>> +    default:
>> +      remapped_opt_info = "tree-vect-details";
>> +      break;
>> +    }
>> +
>> +  if (remapped_opt_info)
>> +    opt_info_switch_p (remapped_opt_info);
>> +}
>> Index: tree-dump.h
>> ===================================================================
>> --- tree-dump.h (revision 191208)
>> +++ tree-dump.h (working copy)
>> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_TREE_DUMP_H
>>  #define GCC_TREE_DUMP_H
>>
>> +#include "input.h"
>>  #include "splay-tree.h"
>>  #include "dumpfile.h"
>>
>> Index: c-family/c-ada-spec.c
>> ===================================================================
>> --- c-family/c-ada-spec.c       (revision 191208)
>> +++ c-family/c-ada-spec.c       (working copy)
>> @@ -2524,7 +2524,7 @@ print_ada_declaration (pretty_printer *buffer, tre
>>    int is_class = false;
>>    tree name = TYPE_NAME (TREE_TYPE (t));
>>    tree decl_name = DECL_NAME (t);
>> -  bool dump_internal = get_dump_file_info (TDI_ada)->flags & TDF_RAW;
>> +  bool dump_internal = get_dump_file_info (TDI_ada)->pflags & TDF_RAW;
>>    tree orig = NULL_TREE;
>>
>>    if (cpp_check && cpp_check (t, IS_TEMPLATE))
>> Index: c/c-decl.c
>> ===================================================================
>> --- c/c-decl.c  (revision 191208)
>> +++ c/c-decl.c  (working copy)
>> @@ -10082,7 +10082,7 @@ c_write_global_declarations (void)
>>    if (dump_enabled_p (TDI_ada))
>>      {
>>        /* Build a table of files to generate specs for */
>> -      if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
>> +      if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM)
>>         collect_source_ref (main_input_filename);
>>        else
>>         for_each_global_decl (collect_source_ref_cb);
>> Index: dumpfile.h
>> ===================================================================
>> --- dumpfile.h  (revision 191208)
>> +++ dumpfile.h  (working copy)
>> @@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_DUMPFILE_H
>>  #define GCC_DUMPFILE_H 1
>>
>> +#include "coretypes.h"
>> +#include "input.h"
>> +
>>  /* Different tree dump places.  When you add new tree dump places,
>>     extend the DUMP_FILES array in tree-dump.c.  */
>>  enum tree_dump_index
>> @@ -43,9 +46,11 @@ enum tree_dump_index
>>    TDI_end
>>  };
>>
>> -/* Bit masks to control dumping. Not all values are applicable to
>> -   all dumps. Add new ones at the end. When you define new
>> -   values, extend the DUMP_OPTIONS array in tree-dump.c */
>> +/* Bit masks to control dumping. Not all values are applicable to all
>> +   dumps. Add new ones at the end. When you define new values, extend
>> +   the DUMP_OPTIONS array in tree-dump.c. These TDF_* flags coexist
>> +   with MSG_* flags and the bit values must be chosen to allow that.
>> +*/
>>  #define TDF_ADDRESS    (1 << 0)        /* dump node addresses */
>>  #define TDF_SLIM       (1 << 1)        /* don't go wild following links */
>>  #define TDF_RAW        (1 << 2)        /* don't unparse the function */
>> @@ -83,6 +88,16 @@ enum tree_dump_index
>>  #define TDF_SCEV       (1 << 24)       /* Dump SCEV details.  */
>>  #define TDF_COMMENT    (1 << 25)       /* Dump lines with prefix ";;"  */
>>
>> +/* Different types of dump classifications. These are extension of
>> +   TDF_* flags and the bit values should be chosen accordingly. */
>> +enum dump_msg_kind {
>> +  /* During the transition to MSG_* dump system, the TDF_* flags and
>> +     MSG_* flags may coexist in a single word. Hence the MSG_* flag
>> +     bits start after the TDF_* bits. */
>> +  MSG_OPTIMIZED_LOCATIONS = 1 << 26,
>> +  MSG_MISSED_OPTIMIZATION = 1 << 27,
>> +  MSG_NOTE = 1 << 28
>> +};
>>
>>  /* In tree-dump.c */
>>
>> @@ -91,9 +106,23 @@ extern int dump_enabled_p (int);
>>  extern int dump_initialized_p (int);
>>  extern FILE *dump_begin (int, int *);
>>  extern void dump_end (int, FILE *);
>> +extern int dump_start (int, int *);
>> +extern void dump_finish (int);
>>  extern void dump_node (const_tree, int, FILE *);
>>  extern int dump_switch_p (const char *);
>> +extern int opt_info_switch_p (const char *);
>>  extern const char *dump_flag_name (int);
>> +extern bool dump_kind_p (int);
>> +extern void dump_printf (int, const char *, ...) ATTRIBUTE_PRINTF_2;
>> +extern void dump_printf_loc (int, source_location,
>> +                             const char *, ...) ATTRIBUTE_PRINTF_3;
>> +extern void dump_basic_block (int, basic_block, int);
>> +extern void dump_generic_expr_loc (int, source_location, int, tree);
>> +extern void dump_generic_expr (int, int, tree);
>> +extern void dump_gimple_stmt_loc (int, source_location, int, gimple, int);
>> +extern void dump_gimple_stmt (int, int, gimple, int);
>> +extern void dump_combine_total_stats (void);
>> +extern void dump_remap_tree_vectorizer_verbose (const char *);
>>
>>  /* Global variables used to communicate with passes.  */
>>  extern FILE *dump_file;
>> @@ -109,8 +138,14 @@ struct dump_file_info
>>    const char *suffix;           /* suffix to give output file.  */
>>    const char *swtch;            /* command line switch */
>>    const char *glob;             /* command line glob  */
>> -  int flags;                    /* user flags */
>> -  int state;                    /* state of play */
>> +  const char *pfilename;        /* filename for the pass-specific stream  */
>> +  const char *alt_filename;     /* filename for the opt-info stream  */
>> +  FILE *pstream;                /* pass-specific dump stream  */
>> +  FILE *alt_stream;             /* opt-info stream */
>> +  int pflags;                   /* dump flags */
>> +  int alt_flags;                /* flags for opt-info */
>> +  int pstate;                   /* state of pass-specific stream */
>> +  int alt_state;                /* state of the opt-info stream */
>>    int num;                      /* dump file number */
>>  };
>>
>> Index: tree-vect-loop-manip.c
>> ===================================================================
>> --- tree-vect-loop-manip.c      (revision 191208)
>> +++ tree-vect-loop-manip.c      (working copy)
>> @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "tm.h"
>>  #include "ggc.h"
>>  #include "tree.h"
>> @@ -791,14 +792,12 @@ slpeel_make_loop_iterate_ntimes (struct loop *loop
>>    free_stmt_vec_info (orig_cond);
>>
>>    loop_loc = find_loop_location (loop);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> +  if (dump_kind_p (MSG_NOTE))
>>      {
>> -      if (loop_loc != UNKNOWN_LOC)
>> -        fprintf (dump_file, "\nloop at %s:%d: ",
>> -                 LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> -      print_gimple_stmt (dump_file, cond_stmt, 0, TDF_SLIM);
>> +      dump_printf (MSG_NOTE, "\nloop at %s:%d: ", LOC_FILE (loop_loc),
>> +                   LOC_LINE (loop_loc));
>> +      dump_gimple_stmt (MSG_NOTE, TDF_SLIM, cond_stmt, 0);
>>      }
>> -
>>    loop->nb_iterations = niters;
>>  }
>>
>> @@ -1220,13 +1219,8 @@ slpeel_tree_peel_loop_to_edge (struct loop *loop,
>>    if (!(new_loop = slpeel_tree_duplicate_loop_to_edge_cfg (loop, e)))
>>      {
>>        loop_loc = find_loop_location (loop);
>> -      if (dump_file && (dump_flags & TDF_DETAILS))
>> -        {
>> -          if (loop_loc != UNKNOWN_LOC)
>> -            fprintf (dump_file, "\n%s:%d: note: ",
>> -                     LOC_FILE (loop_loc), LOC_LINE (loop_loc));
>> -          fprintf (dump_file, "tree_duplicate_loop_to_edge_cfg failed.\n");
>> -        }
>> +      dump_printf_loc (MSG_MISSED_OPTIMIZATION, loop_loc,
>> +                       "tree_duplicate_loop_to_edge_cfg failed.\n");
>>        return NULL;
>>      }
>>
>> @@ -1642,19 +1636,18 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>    /* Analyze phi functions of the loop header.  */
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "vect_can_advance_ivs_p:");
>> -
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf_loc (MSG_NOTE, vect_location, "vect_can_advance_ivs_p:");
>>    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
>>      {
>>        tree access_fn = NULL;
>>        tree evolution_part;
>>
>>        phi = gsi_stmt (gsi);
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> +      if (dump_kind_p (MSG_NOTE))
>>         {
>> -          fprintf (vect_dump, "Analyze phi: ");
>> -          print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> +          dump_printf_loc (MSG_NOTE, vect_location, "Analyze phi: ");
>> +          dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
>>         }
>>
>>        /* Skip virtual phi's. The data dependences that are associated with
>> @@ -1662,8 +1655,9 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>        if (virtual_operand_p (PHI_RESULT (phi)))
>>         {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "virtual phi. skip.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "virtual phi. skip.");
>>           continue;
>>         }
>>
>> @@ -1671,8 +1665,9 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>        if (STMT_VINFO_DEF_TYPE (vinfo_for_stmt (phi)) == vect_reduction_def)
>>          {
>> -          if (vect_print_dump_info (REPORT_DETAILS))
>> -            fprintf (vect_dump, "reduc phi. skip.");
>> +          if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +            dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "reduc phi. skip.");
>>            continue;
>>          }
>>
>> @@ -1683,23 +1678,25 @@ vect_can_advance_ivs_p (loop_vec_info loop_vinfo)
>>
>>        if (!access_fn)
>>         {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "No Access function.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "No Access function.");
>>           return false;
>>         }
>>
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> +      if (dump_kind_p (MSG_NOTE))
>>          {
>> -         fprintf (vect_dump, "Access function of PHI: ");
>> -         print_generic_expr (vect_dump, access_fn, TDF_SLIM);
>> +         dump_printf_loc (MSG_NOTE, vect_location,
>> +                           "Access function of PHI: ");
>> +         dump_generic_expr (MSG_NOTE, TDF_SLIM, access_fn);
>>          }
>>
>>        evolution_part = evolution_part_in_loop_num (access_fn, loop->num);
>>
>>        if (evolution_part == NULL_TREE)
>>          {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "No evolution.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf (MSG_MISSED_OPTIMIZATION, "No evolution.");
>>           return false;
>>          }
>>
>> @@ -1783,17 +1780,19 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
>>
>>        phi = gsi_stmt (gsi);
>>        phi1 = gsi_stmt (gsi1);
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> +      if (dump_kind_p (MSG_NOTE))
>>          {
>> -          fprintf (vect_dump, "vect_update_ivs_after_vectorizer: phi: ");
>> -         print_gimple_stmt (vect_dump, phi, 0, TDF_SLIM);
>> +          dump_printf_loc (MSG_NOTE, vect_location,
>> +                           "vect_update_ivs_after_vectorizer: phi: ");
>> +         dump_gimple_stmt (MSG_NOTE, TDF_SLIM, phi, 0);
>>          }
>>
>>        /* Skip virtual phi's.  */
>>        if (virtual_operand_p (PHI_RESULT (phi)))
>>         {
>> -         if (vect_print_dump_info (REPORT_DETAILS))
>> -           fprintf (vect_dump, "virtual phi. skip.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "virtual phi. skip.");
>>           continue;
>>         }
>>
>> @@ -1801,8 +1800,9 @@ vect_update_ivs_after_vectorizer (loop_vec_info lo
>>        stmt_info = vinfo_for_stmt (phi);
>>        if (STMT_VINFO_DEF_TYPE (stmt_info) == vect_reduction_def)
>>          {
>> -          if (vect_print_dump_info (REPORT_DETAILS))
>> -            fprintf (vect_dump, "reduc phi. skip.");
>> +         if (dump_kind_p (MSG_MISSED_OPTIMIZATION))
>> +           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +                             "reduc phi. skip.");
>>            continue;
>>          }
>>
>> @@ -1863,8 +1863,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
>>    tree cond_expr = NULL_TREE;
>>    gimple_seq cond_expr_stmt_list = NULL;
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_loop_bound ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_loop_bound ===");
>>
>>    initialize_original_copy_tables ();
>>
>> @@ -1909,9 +1910,9 @@ vect_do_peeling_for_loop_bound (loop_vec_info loop
>>    if (check_profitability)
>>      max_iter = MAX (max_iter, (int) th);
>>    record_niter_bound (new_loop, double_int::from_shwi (max_iter), false, true);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    fprintf (dump_file, "Setting upper bound of nb iterations for epilogue "
>> -            "loop to %d\n", max_iter);
>> +  dump_printf (MSG_OPTIMIZED_LOCATIONS,
>> +               "Setting upper bound of nb iterations for epilogue "
>> +               "loop to %d\n", max_iter);
>>
>>    /* After peeling we have to reset scalar evolution analyzer.  */
>>    scev_reset ();
>> @@ -1973,8 +1974,8 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
>>      {
>>        int npeel = LOOP_PEELING_FOR_ALIGNMENT (loop_vinfo);
>>
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> -        fprintf (vect_dump, "known peeling = %d.", npeel);
>> +      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +        dump_printf (MSG_OPTIMIZED_LOCATIONS, "known peeling = %d.", npeel);
>>
>>        iters = build_int_cst (niters_type, npeel);
>>      }
>> @@ -2024,10 +2025,11 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loo
>>    if (TREE_CODE (loop_niters) != INTEGER_CST)
>>      iters = fold_build2 (MIN_EXPR, niters_type, iters, loop_niters);
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>>      {
>> -      fprintf (vect_dump, "niters for prolog loop: ");
>> -      print_generic_expr (vect_dump, iters, TDF_SLIM);
>> +      dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                       "niters for prolog loop: ");
>> +      dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, iters);
>>      }
>>
>>    var = create_tmp_var (niters_type, "prolog_loop_niters");
>> @@ -2080,10 +2082,11 @@ vect_update_inits_of_drs (loop_vec_info loop_vinfo
>>    unsigned int i;
>>    VEC (data_reference_p, heap) *datarefs = LOOP_VINFO_DATAREFS (loop_vinfo);
>>    struct data_reference *dr;
>> +
>> + if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_update_inits_of_dr ===");
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_update_inits_of_dr ===");
>> -
>>    FOR_EACH_VEC_ELT (data_reference_p, datarefs, i, dr)
>>      vect_update_init_of_dr (dr, niters);
>>  }
>> @@ -2108,8 +2111,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
>>    struct loop *new_loop;
>>    int max_iter;
>>
>> -  if (vect_print_dump_info (REPORT_DETAILS))
>> -    fprintf (vect_dump, "=== vect_do_peeling_for_alignment ===");
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                     "=== vect_do_peeling_for_alignment ===");
>>
>>    initialize_original_copy_tables ();
>>
>> @@ -2131,9 +2135,9 @@ vect_do_peeling_for_alignment (loop_vec_info loop_
>>    if (check_profitability)
>>      max_iter = MAX (max_iter, (int) th);
>>    record_niter_bound (new_loop, double_int::from_shwi (max_iter), false, true);
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    fprintf (dump_file, "Setting upper bound of nb iterations for prologue "
>> -            "loop to %d\n", max_iter);
>> +  dump_printf (MSG_OPTIMIZED_LOCATIONS,
>> +               "Setting upper bound of nb iterations for prologue "
>> +               "loop to %d\n", max_iter);
>>
>>    /* Update number of times loop executes.  */
>>    n_iters = LOOP_VINFO_NITERS (loop_vinfo);
>> @@ -2416,13 +2420,13 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>        segment_length_a = vect_vfa_segment_size (dr_a, length_factor);
>>        segment_length_b = vect_vfa_segment_size (dr_b, length_factor);
>>
>> -      if (vect_print_dump_info (REPORT_DR_DETAILS))
>> +      if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>>         {
>> -         fprintf (vect_dump,
>> -                  "create runtime check for data references ");
>> -         print_generic_expr (vect_dump, DR_REF (dr_a), TDF_SLIM);
>> -         fprintf (vect_dump, " and ");
>> -         print_generic_expr (vect_dump, DR_REF (dr_b), TDF_SLIM);
>> +         dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                           "create runtime check for data references ");
>> +         dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, DR_REF (dr_a));
>> +         dump_printf (MSG_OPTIMIZED_LOCATIONS, " and ");
>> +         dump_generic_expr (MSG_OPTIMIZED_LOCATIONS, TDF_SLIM, DR_REF (dr_b));
>>         }
>>
>>        seg_a_min = addr_base_a;
>> @@ -2447,9 +2451,10 @@ vect_create_cond_for_alias_checks (loop_vec_info l
>>         *cond_expr = part_cond_expr;
>>      }
>>
>> -  if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> -    fprintf (vect_dump, "created %u versioning for alias checks.\n",
>> -             VEC_length (ddr_p, may_alias_ddrs));
>> +  if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                    "created %u versioning for alias checks.\n",
>> +                    VEC_length (ddr_p, may_alias_ddrs));
>>  }
>>
>>
>> Index: cp/decl2.c
>> ===================================================================
>> --- cp/decl2.c  (revision 191208)
>> +++ cp/decl2.c  (working copy)
>> @@ -3695,7 +3695,7 @@ cp_write_global_declarations (void)
>>    /* Handle -fdump-ada-spec[-slim] */
>>    if (dump_enabled_p (TDI_ada))
>>      {
>> -      if (get_dump_file_info (TDI_ada)->flags & TDF_SLIM)
>> +      if (get_dump_file_info (TDI_ada)->pflags & TDF_SLIM)
>>         collect_source_ref (main_input_filename);
>>        else
>>         collect_source_refs (global_namespace);
>> Index: opts.c
>> ===================================================================
>> --- opts.c      (revision 191208)
>> +++ opts.c      (working copy)
>> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "system.h"
>>  #include "intl.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "opts.h"
>>  #include "options.h"
>>  #include "tm.h" /* For STACK_CHECK_BUILTIN,
>> @@ -139,19 +140,6 @@ set_struct_debug_option (struct gcc_options *opts,
>>      }
>>  }
>>
>> -/* Handle -ftree-vectorizer-verbose=VAL for options OPTS.  */
>> -
>> -static void
>> -vect_set_verbosity_level (struct gcc_options *opts, int val)
>> -{
>> -   if (val < MAX_VERBOSITY_LEVEL)
>> -     opts->x_user_vect_verbosity_level = (enum vect_verbosity_levels) val;
>> -   else
>> -     opts->x_user_vect_verbosity_level
>> -      = (enum vect_verbosity_levels) (MAX_VERBOSITY_LEVEL - 1);
>> -}
>> -
>> -
>>  /* Strip off a legitimate source ending from the input string NAME of
>>     length LEN.  Rather than having to know the names used by all of
>>     our front ends, we strip off an ending of a period followed by
>> @@ -1671,8 +1659,14 @@ common_handle_option (struct gcc_options *opts,
>>        opts->x_flag_stack_usage_info = value != 0;
>>        break;
>>
>> +    case OPT_fopt_info_:
>> +      /* Deferred.  */
>> +      break;
>> +
>>      case OPT_ftree_vectorizer_verbose_:
>> -      vect_set_verbosity_level (opts, value);
>> +      /* -ftree-vectorizer-verbose is deprecated. It is defined in
>> +         -terms of fopt-info=N. */
>> +      /* Deferred.  */
>>        break;
>>
>>      case OPT_g:
>> Index: tree-parloops.c
>> ===================================================================
>> --- tree-parloops.c     (revision 191208)
>> +++ tree-parloops.c     (working copy)
>> @@ -1943,7 +1943,6 @@ gather_scalar_reductions (loop_p loop, htab_t redu
>>    gimple_stmt_iterator gsi;
>>    loop_vec_info simple_loop_info;
>>
>> -  vect_dump = NULL;
>>    simple_loop_info = vect_analyze_loop_form (loop);
>>
>>    for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
>> Index: gimple-pretty-print.c
>> ===================================================================
>> --- gimple-pretty-print.c       (revision 191208)
>> +++ gimple-pretty-print.c       (working copy)
>> @@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
>>  }
>>
>>
>> -/* Emit a newline and SPC indentantion spaces to BUFFER.  */
>> +/* Emit a newline and SPC indentation spaces to BUFFER.  */
>>
>>  static void
>>  newline_and_indent (pretty_printer *buffer, int spc)
>> @@ -89,20 +89,20 @@ debug_gimple_stmt (gimple gs)
>>  }
>>
>>
>> -/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
>> -   FLAGS as in dump_gimple_stmt.  */
>> +/* 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)
>>  {
>>    maybe_init_pretty_print (file);
>> -  dump_gimple_stmt (&buffer, g, spc, flags);
>> +  pp_gimple_stmt_1 (&buffer, g, spc, flags);
>>    pp_newline_and_flush (&buffer);
>>  }
>>
>>
>> -/* Dump GIMPLE statement G to FILE using SPC indentantion spaces and
>> -   FLAGS as in dump_gimple_stmt.  Print only the right-hand side
>> +/* Print GIMPLE statement G to FILE using SPC indentation spaces and
>> +   FLAGS as in pp_gimple_stmt_1.  Print only the right-hand side
>>     of the statement.  */
>>
>>  void
>> @@ -110,12 +110,12 @@ print_gimple_expr (FILE *file, gimple g, int spc,
>>  {
>>    flags |= TDF_RHS_ONLY;
>>    maybe_init_pretty_print (file);
>> -  dump_gimple_stmt (&buffer, g, spc, flags);
>> +  pp_gimple_stmt_1 (&buffer, g, spc, flags);
>>  }
>>
>>
>> -/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentantion
>> -   spaces and FLAGS as in dump_gimple_stmt.
>> +/* Print the GIMPLE sequence SEQ on BUFFER using SPC indentation
>> +   spaces and FLAGS as in pp_gimple_stmt_1.
>>     The caller is responsible for calling pp_flush on BUFFER to finalize
>>     the pretty printer.  */
>>
>> @@ -128,15 +128,15 @@ dump_gimple_seq (pretty_printer *buffer, gimple_se
>>      {
>>        gimple gs = gsi_stmt (i);
>>        INDENT (spc);
>> -      dump_gimple_stmt (buffer, gs, spc, flags);
>> +      pp_gimple_stmt_1 (buffer, gs, spc, flags);
>>        if (!gsi_one_before_end_p (i))
>>         pp_newline (buffer);
>>      }
>>  }
>>
>>
>> -/* Dump GIMPLE sequence SEQ to FILE using SPC indentantion spaces and
>> -   FLAGS as in dump_gimple_stmt.  */
>> +/* Print GIMPLE sequence SEQ to FILE using SPC indentation spaces and
>> +   FLAGS as in pp_gimple_stmt_1.  */
>>
>>  void
>>  print_gimple_seq (FILE *file, gimple_seq seq, int spc, int flags)
>> @@ -245,7 +245,7 @@ dump_gimple_fmt (pretty_printer *buffer, int spc,
>>
>>
>>  /* Helper for dump_gimple_assign.  Print the unary RHS of the
>> -   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
>> +   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_unary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -329,7 +329,7 @@ dump_unary_rhs (pretty_printer *buffer, gimple gs,
>>
>>
>>  /* Helper for dump_gimple_assign.  Print the binary RHS of the
>> -   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
>> +   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_binary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -385,7 +385,7 @@ dump_binary_rhs (pretty_printer *buffer, gimple gs
>>  }
>>
>>  /* Helper for dump_gimple_assign.  Print the ternary RHS of the
>> -   assignment GS.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.  */
>> +   assignment GS.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_ternary_rhs (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -470,7 +470,7 @@ dump_ternary_rhs (pretty_printer *buffer, gimple g
>>
>>
>>  /* Dump the gimple assignment GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_assign (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -529,7 +529,7 @@ dump_gimple_assign (pretty_printer *buffer, gimple
>>
>>
>>  /* Dump the return statement GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -616,7 +616,7 @@ pp_points_to_solution (pretty_printer *buffer, str
>>  }
>>
>>  /* Dump the call statement GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_call (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -749,7 +749,7 @@ dump_gimple_call (pretty_printer *buffer, gimple g
>>
>>
>>  /* Dump the switch statement GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_switch (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -782,7 +782,7 @@ dump_gimple_switch (pretty_printer *buffer, gimple
>>
>>
>>  /* Dump the gimple conditional GS.  BUFFER, SPC and FLAGS are as in
>> -   dump_gimple_stmt.  */
>> +   pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_cond (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -1573,7 +1573,7 @@ dump_gimple_asm (pretty_printer *buffer, gimple gs
>>  }
>>
>>
>> -/* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in dump_gimple_stmt.
>> +/* 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.  */
>>
>> @@ -1807,7 +1807,7 @@ dump_gimple_omp_atomic_store (pretty_printer *buff
>>
>>
>>  /* Dump all the memory operands for statement GS.  BUFFER, SPC and
>> -   FLAGS are as in dump_gimple_stmt.  */
>> +   FLAGS are as in pp_gimple_stmt_1.  */
>>
>>  static void
>>  dump_gimple_mem_ops (pretty_printer *buffer, gimple gs, int spc, int flags)
>> @@ -1838,13 +1838,13 @@ dump_gimple_mem_ops (pretty_printer *buffer, gimpl
>>  }
>>
>>
>> -/* Dump the gimple statement GS on the pretty printer BUFFER, SPC
>> +/* Print the gimple statement GS on the pretty printer BUFFER, SPC
>>     spaces of indent.  FLAGS specifies details to show in the dump (see
>>     TDF_* in dumpfile.h).  The caller is responsible for calling
>>     pp_flush on BUFFER to finalize the pretty printer.  */
>>
>>  void
>> -dump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, int flags)
>> +pp_gimple_stmt_1 (pretty_printer *buffer, gimple gs, int spc, int flags)
>>  {
>>    if (!gs)
>>      return;
>> @@ -2253,7 +2253,7 @@ gimple_dump_bb_buff (pretty_printer *buffer, basic
>>        curr_indent = gimple_code (stmt) == GIMPLE_LABEL ? label_indent : indent;
>>
>>        INDENT (curr_indent);
>> -      dump_gimple_stmt (buffer, stmt, curr_indent, flags);
>> +      pp_gimple_stmt_1 (buffer, stmt, curr_indent, flags);
>>        pp_newline_and_flush (buffer);
>>        gcc_checking_assert (DECL_STRUCT_FUNCTION (current_function_decl));
>>        dump_histograms_for_stmt (DECL_STRUCT_FUNCTION (current_function_decl),
>> Index: gimple-pretty-print.h
>> ===================================================================
>> --- gimple-pretty-print.h       (revision 191208)
>> +++ gimple-pretty-print.h       (working copy)
>> @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>>  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>>  extern void print_gimple_stmt (FILE *, gimple, int, int);
>>  extern void print_gimple_expr (FILE *, gimple, int, int);
>> -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
>> +extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>>
>>  #endif /* ! GCC_GIMPLE_PRETTY_PRINT_H */
>> Index: tree-vectorizer.c
>> ===================================================================
>> --- tree-vectorizer.c   (revision 191208)
>> +++ tree-vectorizer.c   (working copy)
>> @@ -58,6 +58,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "tm.h"
>>  #include "ggc.h"
>>  #include "tree.h"
>> @@ -67,13 +68,6 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "tree-vectorizer.h"
>>  #include "tree-pass.h"
>>
>> -/* vect_dump will be set to stderr or dump_file if exist.  */
>> -FILE *vect_dump;
>> -
>> -/* vect_verbosity_level set to an invalid value
>> -   to mark that it's uninitialized.  */
>> -static enum vect_verbosity_levels vect_verbosity_level = MAX_VERBOSITY_LEVEL;
>> -
>>  /* Loop or bb location.  */
>>  LOC vect_location;
>>
>> @@ -81,82 +75,6 @@ LOC vect_location;
>>  VEC(vec_void_p,heap) *stmt_vec_info_vec;
>>
>>
>> -
>> -/* Function vect_set_dump_settings.
>> -
>> -   Fix the verbosity level of the vectorizer if the
>> -   requested level was not set explicitly using the flag
>> -   -ftree-vectorizer-verbose=N.
>> -   Decide where to print the debugging information (dump_file/stderr).
>> -   If the user defined the verbosity level, but there is no dump file,
>> -   print to stderr, otherwise print to the dump file.  */
>> -
>> -static void
>> -vect_set_dump_settings (bool slp)
>> -{
>> -  vect_dump = dump_file;
>> -
>> -  /* Check if the verbosity level was defined by the user:  */
>> -  if (user_vect_verbosity_level != MAX_VERBOSITY_LEVEL)
>> -    {
>> -      vect_verbosity_level = user_vect_verbosity_level;
>> -      /* Ignore user defined verbosity if dump flags require higher level of
>> -         verbosity.  */
>> -      if (dump_file)
>> -        {
>> -          if (((dump_flags & TDF_DETAILS)
>> -                && vect_verbosity_level >= REPORT_DETAILS)
>> -              || ((dump_flags & TDF_STATS)
>> -                   && vect_verbosity_level >= REPORT_UNVECTORIZED_LOCATIONS))
>> -            return;
>> -        }
>> -      else
>> -        {
>> -          /* If there is no dump file, print to stderr in case of loop
>> -             vectorization.  */
>> -          if (!slp)
>> -            vect_dump = stderr;
>> -
>> -          return;
>> -        }
>> -    }
>> -
>> -  /* User didn't specify verbosity level:  */
>> -  if (dump_file && (dump_flags & TDF_DETAILS))
>> -    vect_verbosity_level = REPORT_DETAILS;
>> -  else if (dump_file && (dump_flags & TDF_STATS))
>> -    vect_verbosity_level = REPORT_UNVECTORIZED_LOCATIONS;
>> -  else
>> -    vect_verbosity_level = REPORT_NONE;
>> -
>> -  gcc_assert (dump_file || vect_verbosity_level == REPORT_NONE);
>> -}
>> -
>> -
>> -/* Function debug_loop_details.
>> -
>> -   For vectorization debug dumps.  */
>> -
>> -bool
>> -vect_print_dump_info (enum vect_verbosity_levels vl)
>> -{
>> -  if (vl > vect_verbosity_level)
>> -    return false;
>> -
>> -  if (!current_function_decl || !vect_dump)
>> -    return false;
>> -
>> -  if (vect_location == UNKNOWN_LOC)
>> -    fprintf (vect_dump, "\n%s:%d: note: ",
>> -            DECL_SOURCE_FILE (current_function_decl),
>> -            DECL_SOURCE_LINE (current_function_decl));
>> -  else
>> -    fprintf (vect_dump, "\n%d: ", LOC_LINE (vect_location));
>> -
>> -  return true;
>> -}
>> -
>> -
>>  /* Function vectorize_loops.
>>     Entry point to loop vectorization phase.  */
>> @@ -176,9 +94,6 @@ vectorize_loops (void)
>>    if (vect_loops_num <= 1)
>>      return 0;
>>
>> -  /* Fix the verbosity level if not defined explicitly by the user.  */
>> -  vect_set_dump_settings (false);
>> -
>>    init_stmt_vec_info_vec ();
>>
>>    /*  ----------- Analyze loops. -----------  */
>> @@ -192,10 +107,9 @@ vectorize_loops (void)
>>         loop_vec_info loop_vinfo;
>>
>>         vect_location = find_loop_location (loop);
>> -        if (vect_location != UNKNOWN_LOC
>> -            && vect_verbosity_level > REPORT_NONE)
>> -         fprintf (vect_dump, "\nAnalyzing loop at %s:%d\n",
>> -            LOC_FILE (vect_location), LOC_LINE (vect_location));
>> +        if (vect_location != UNKNOWN_LOC && dump_kind_p (MSG_NOTE))
>> +         dump_printf (MSG_NOTE, "\nAnalyzing loop at %s:%d\n",
>> +                       LOC_FILE (vect_location), LOC_LINE (vect_location));
>>
>>         loop_vinfo = vect_analyze_loop (loop);
>>         loop->aux = loop_vinfo;
>> @@ -203,11 +117,9 @@ vectorize_loops (void)
>>         if (!loop_vinfo || !LOOP_VINFO_VECTORIZABLE_P (loop_vinfo))
>>           continue;
>>
>> -        if (vect_location != UNKNOWN_LOC
>> -            && vect_verbosity_level > REPORT_NONE)
>> -          fprintf (vect_dump, "\n\nVectorizing loop at %s:%d\n",
>> -            LOC_FILE (vect_location), LOC_LINE (vect_location));
>> -
>> +        if (vect_location != UNKNOWN_LOC && dump_kind_p (MSG_NOTE))
>> +          dump_printf (MSG_NOTE, "\n\nVectorizing loop at %s:%d\n",
>> +                       LOC_FILE (vect_location), LOC_LINE (vect_location));
>>         vect_transform_loop (loop_vinfo);
>>         num_vectorized_loops++;
>>        }
>> @@ -215,11 +127,11 @@ vectorize_loops (void)
>>    vect_location = UNKNOWN_LOC;
>>
>>    statistics_counter_event (cfun, "Vectorized loops", num_vectorized_loops);
>> -  if (vect_print_dump_info (REPORT_UNVECTORIZED_LOCATIONS)
>> -      || (num_vectorized_loops > 0
>> -         && vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS)))
>> -    fprintf (vect_dump, "vectorized %u loops in function.\n",
>> -            num_vectorized_loops);
>> +  if (dump_kind_p (MSG_MISSED_OPTIMIZATION)
>> +      || (num_vectorized_loops > 0 && dump_kind_p (MSG_OPTIMIZED_LOCATIONS)))
>> +    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS | MSG_MISSED_OPTIMIZATION,
>> +                     vect_location, "vectorized %u loops in function.\n",
>> +                     num_vectorized_loops);
>>
>>    /*  ----------- Finalize. -----------  */
>>
>> @@ -248,9 +160,6 @@ execute_vect_slp (void)
>>  {
>>    basic_block bb;
>>
>> -  /* Fix the verbosity level if not defined explicitly by the user.  */
>> -  vect_set_dump_settings (true);
>> -
>>    init_stmt_vec_info_vec ();
>>
>>    FOR_EACH_BB (bb)
>> @@ -260,9 +169,9 @@ execute_vect_slp (void)
>>        if (vect_slp_analyze_bb (bb))
>>          {
>>            vect_slp_transform_bb (bb);
>> -
>> -          if (vect_print_dump_info (REPORT_VECTORIZED_LOCATIONS))
>> -            fprintf (vect_dump, "basic block vectorized using SLP\n");
>> +          if (dump_kind_p (MSG_OPTIMIZED_LOCATIONS))
>> +            dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
>> +                            "basic block vectorized using SLP\n");
>>          }
>>      }
>>
>> @@ -335,12 +244,9 @@ increase_alignment (void)
>>          {
>>            DECL_ALIGN (decl) = TYPE_ALIGN (vectype);
>>            DECL_USER_ALIGN (decl) = 1;
>> -          if (dump_file)
>> -            {
>> -              fprintf (dump_file, "Increasing alignment of decl: ");
>> -              print_generic_expr (dump_file, decl, TDF_SLIM);
>> -             fprintf (dump_file, "\n");
>> -            }
>> +          dump_printf (MSG_NOTE, "Increasing alignment of decl: ");
>> +          dump_generic_expr (MSG_NOTE, TDF_SLIM, decl);
>> +          dump_printf (MSG_NOTE, "\n");
>>          }
>>      }
>>    return 0;
>> Index: tree-vectorizer.h
>> ===================================================================
>> --- tree-vectorizer.h   (revision 191208)
>> +++ tree-vectorizer.h   (working copy)
>> @@ -848,9 +848,8 @@ known_alignment_for_access_p (struct data_referenc
>>    return (DR_MISALIGNMENT (data_ref_info) != -1);
>>  }
>>
>> -/* vect_dump will be set to stderr or dump_file if exist.  */
>> -extern FILE *vect_dump;
>> -extern LOC vect_loop_location;
>> +/* Source location */
>> +extern LOC vect_location;
>>
>>  /*-----------------------------------------------------------------*/
>>  /* Function prototypes.                                            */
>> @@ -1012,7 +1011,5 @@ void vect_pattern_recog (loop_vec_info, bb_vec_inf
>>
>>  /* In tree-vectorizer.c.  */
>>  unsigned vectorize_loops (void);
>> -/* Vectorization debug information */
>> -extern bool vect_print_dump_info (enum vect_verbosity_levels);
>>
>>  #endif  /* GCC_TREE_VECTORIZER_H  */
>> Index: profile.c
>> ===================================================================
>> --- profile.c   (revision 191208)
>> +++ profile.c   (working copy)
>> @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "config.h"
>>  #include "system.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>  #include "tm.h"
>>  #include "rtl.h"
>>  #include "flags.h"
>> @@ -133,8 +134,8 @@ instrument_edges (struct edge_list *el)
>>           if (!inf->ignore && !inf->on_tree)
>>             {
>>               gcc_assert (!(e->flags & EDGE_ABNORMAL));
>> -             if (dump_file)
>> -               fprintf (dump_file, "Edge %d to %d instrumented%s\n",
>> +             if (dump_kind_p (MSG_NOTE))
>> +               dump_printf (MSG_NOTE, "Edge %d to %d instrumented%s\n",
>>                          e->src->index, e->dest->index,
>>                          EDGE_CRITICAL_P (e) ? " (and split)" : "");
>>               gimple_gen_edge_profiler (num_instr_edges++, e);
>> @@ -143,8 +144,8 @@ instrument_edges (struct edge_list *el)
>>      }
>>
>>    total_num_blocks_created += num_edges;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d edges instrumented\n", num_instr_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d edges instrumented\n", num_instr_edges);
>>    return num_instr_edges;
>>  }
>>
>> @@ -397,13 +398,13 @@ is_edge_inconsistent (VEC(edge,gc) *edges)
>>               && (!(e->flags & EDGE_FAKE)
>>                   || !block_ends_with_call_p (e->src)))
>>             {
>> -             if (dump_file)
>> +             if (dump_kind_p (MSG_NOTE))
>>                 {
>> -                 fprintf (dump_file,
>> +                 dump_printf (MSG_NOTE,
>>                            "Edge %i->%i is inconsistent, count"HOST_WIDEST_INT_PRINT_DEC,
>>                            e->src->index, e->dest->index, e->count);
>> -                 dump_bb (dump_file, e->src, 0, TDF_DETAILS);
>> -                 dump_bb (dump_file, e->dest, 0, TDF_DETAILS);
>> +                 dump_basic_block (MSG_NOTE, e->src, 0);
>> +                  dump_basic_block (MSG_NOTE, e->dest, 0);
>>                 }
>>                return true;
>>             }
>> @@ -446,40 +447,40 @@ is_inconsistent (void)
>>         return true;
>>        if (bb->count < 0)
>>          {
>> -         if (dump_file)
>> +         if (dump_kind_p (MSG_NOTE))
>>             {
>> -             fprintf (dump_file, "BB %i count is negative "
>> +             dump_printf (MSG_NOTE, "BB %i count is negative "
>>                        HOST_WIDEST_INT_PRINT_DEC,
>>                        bb->index,
>>                        bb->count);
>> -             dump_bb (dump_file, bb, 0, TDF_DETAILS);
>> +             dump_basic_block (MSG_NOTE, bb, 0);
>>             }
>>           inconsistent = true;
>>         }
>>        if (bb->count != sum_edge_counts (bb->preds))
>>          {
>> -         if (dump_file)
>> +         if (dump_kind_p (MSG_NOTE))
>>             {
>> -             fprintf (dump_file, "BB %i count does not match sum of incoming edges "
>> +             dump_printf (MSG_NOTE, "BB %i count does not match sum of
>> incoming edges "
>>                        HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
>>                        bb->index,
>>                        bb->count,
>>                        sum_edge_counts (bb->preds));
>> -             dump_bb (dump_file, bb, 0, TDF_DETAILS);
>> +             dump_basic_block (MSG_NOTE, bb, 0);
>>             }
>>           inconsistent = true;
>>         }
>>        if (bb->count != sum_edge_counts (bb->succs) &&
>>            ! (find_edge (bb, EXIT_BLOCK_PTR) != NULL &&
>> block_ends_with_call_p (bb)))
>>         {
>> -         if (dump_file)
>> +         if (dump_kind_p (MSG_NOTE))
>>             {
>> -             fprintf (dump_file, "BB %i count does not match sum of outgoing edges "
>> +             dump_printf (MSG_NOTE, "BB %i count does not match sum of
>> outgoing edges "
>>                        HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC,
>>                        bb->index,
>>                        bb->count,
>>                        sum_edge_counts (bb->succs));
>> -             dump_bb (dump_file, bb, 0, TDF_DETAILS);
>> +             dump_basic_block (MSG_NOTE, bb, 0);
>>             }
>>           inconsistent = true;
>>         }
>> @@ -547,11 +548,11 @@ read_profile_edge_counts (gcov_type *exec_counts)
>>             EDGE_INFO (e)->count_valid = 1;
>>             BB_INFO (bb)->succ_count--;
>>             BB_INFO (e->dest)->pred_count--;
>> -           if (dump_file)
>> +           if (dump_kind_p (MSG_NOTE))
>>               {
>> -               fprintf (dump_file, "\nRead edge from %i to %i, count:",
>> +               dump_printf (MSG_NOTE, "\nRead edge from %i to %i, count:",
>>                          bb->index, e->dest->index);
>> -               fprintf (dump_file, HOST_WIDEST_INT_PRINT_DEC,
>> +               dump_printf (MSG_NOTE, HOST_WIDEST_INT_PRINT_DEC,
>>                          (HOST_WIDEST_INT) e->count);
>>               }
>>           }
>> @@ -647,8 +648,8 @@ compute_branch_probabilities (unsigned cfg_checksu
>>
>>    num_edges = read_profile_edge_counts (exec_counts);
>>
>> -  if (dump_file)
>> -    fprintf (dump_file, "\n%d edge counts read\n", num_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "\n%d edge counts read\n", num_edges);
>>
>>    /* For every block in the file,
>>       - if every exit/entrance edge has a known count, then set the block count
>> @@ -762,18 +763,18 @@ compute_branch_probabilities (unsigned cfg_checksu
>>             }
>>         }
>>      }
>> -  if (dump_file)
>> +  if (dump_kind_p (MSG_NOTE))
>>      {
>>        int overlap = compute_frequency_overlap ();
>>        gimple_dump_cfg (dump_file, dump_flags);
>> -      fprintf (dump_file, "Static profile overlap: %d.%d%%\n",
>> +      dump_printf (MSG_NOTE, "Static profile overlap: %d.%d%%\n",
>>                overlap / (OVERLAP_BASE / 100),
>>                overlap % (OVERLAP_BASE / 100));
>>      }
>>
>>    total_num_passes += passes;
>> -  if (dump_file)
>> -    fprintf (dump_file, "Graph solving took %d passes.\n\n", passes);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "Graph solving took %d passes.\n\n", passes);
>>
>>    /* If the graph has been correctly solved, every block will have a
>>       succ and pred count of zero.  */
>> @@ -799,8 +800,8 @@ compute_branch_probabilities (unsigned cfg_checksu
>>           correct_negative_edge_counts ();
>>           /* Set bb counts to the sum of the outgoing edge counts */
>>           set_bb_counts ();
>> -         if (dump_file)
>> -           fprintf (dump_file, "\nCalling mcf_smooth_cfg\n");
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "\nCalling mcf_smooth_cfg\n");
>>           mcf_smooth_cfg ();
>>         }
>>       else
>> @@ -912,12 +913,12 @@ compute_branch_probabilities (unsigned cfg_checksu
>>    profile_status = PROFILE_READ;
>>    compute_function_frequency ();
>>
>> -  if (dump_file)
>> +  if (dump_kind_p (MSG_NOTE))
>>      {
>> -      fprintf (dump_file, "%d branches\n", num_branches);
>> +      dump_printf (MSG_NOTE, "%d branches\n", num_branches);
>>        if (num_branches)
>>         for (i = 0; i < 10; i++)
>> -         fprintf (dump_file, "%d%% branches in range %d-%d%%\n",
>> +         dump_printf (MSG_NOTE, "%d%% branches in range %d-%d%%\n",
>>                    (hist_br_prob[i] + hist_br_prob[19-i]) * 100 / num_branches,
>>                    5 * i, 5 * i + 5);
>>
>> @@ -1152,15 +1153,15 @@ branch_prob (void)
>>
>>        if (need_exit_edge && !have_exit_edge)
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Adding fake exit edge to bb %i\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Adding fake exit edge to bb %i\n",
>>                      bb->index);
>>           make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
>>         }
>>        if (need_entry_edge && !have_entry_edge)
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Adding fake entry edge to bb %i\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Adding fake entry edge to bb %i\n",
>>                      bb->index);
>>           make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
>>           /* Avoid bbs that have both fake entry edge and also some
>> @@ -1192,8 +1193,8 @@ branch_prob (void)
>>                       && (DECL_FUNCTION_CODE (fndecl)
>>                           != BUILT_IN_SETJMP_DISPATCHER)))
>>                 {
>> -                 if (dump_file)
>> -                   fprintf (dump_file, "Splitting bb %i after labels\n",
>> +                 if (dump_kind_p (MSG_NOTE))
>> +                   dump_printf (MSG_NOTE, "Splitting bb %i after labels\n",
>>                              bb->index);
>>                   split_block_after_labels (bb);
>>                 }
>> @@ -1248,20 +1249,20 @@ branch_prob (void)
>>      }
>>
>>    total_num_blocks += n_basic_blocks;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d basic blocks\n", n_basic_blocks);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d basic blocks\n", n_basic_blocks);
>>
>>    total_num_edges += num_edges;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d edges\n", num_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d edges\n", num_edges);
>>
>>    total_num_edges_ignored += ignored_edges;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d ignored edges\n", ignored_edges);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d ignored edges\n", ignored_edges);
>>
>>    total_num_edges_instrumented += num_instrumented;
>> -  if (dump_file)
>> -    fprintf (dump_file, "%d instrumentation edges\n", num_instrumented);
>> +  if (dump_kind_p (MSG_NOTE))
>> +    dump_printf (MSG_NOTE, "%d instrumentation edges\n", num_instrumented);
>>
>>    /* Compute two different checksums. Note that we want to compute
>>       the checksum in only once place, since it depends on the shape
>> @@ -1467,8 +1468,8 @@ find_spanning_tree (struct edge_list *el)
>>           && !EDGE_INFO (e)->ignore
>>           && (find_group (e->src) != find_group (e->dest)))
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Abnormal edge %d to %d put to tree\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Abnormal edge %d to %d put to tree\n",
>>                      e->src->index, e->dest->index);
>>           EDGE_INFO (e)->on_tree = 1;
>>           union_groups (e->src, e->dest);
>> @@ -1482,8 +1483,8 @@ find_spanning_tree (struct edge_list *el)
>>        if (EDGE_CRITICAL_P (e) && !EDGE_INFO (e)->ignore
>>           && find_group (e->src) != find_group (e->dest))
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Critical edge %d to %d put to tree\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Critical edge %d to %d put to tree\n",
>>                      e->src->index, e->dest->index);
>>           EDGE_INFO (e)->on_tree = 1;
>>           union_groups (e->src, e->dest);
>> @@ -1497,8 +1498,8 @@ find_spanning_tree (struct edge_list *el)
>>        if (!EDGE_INFO (e)->ignore
>>           && find_group (e->src) != find_group (e->dest))
>>         {
>> -         if (dump_file)
>> -           fprintf (dump_file, "Normal edge %d to %d put to tree\n",
>> +         if (dump_kind_p (MSG_NOTE))
>> +           dump_printf (MSG_NOTE, "Normal edge %d to %d
> ...
>
> [Message clipped]

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-12 16:47                                                       ` Xinliang David Li
@ 2012-09-13 11:08                                                         ` Richard Guenther
  2012-09-13 15:02                                                           ` Sharad Singhai
  2012-09-13 16:10                                                           ` Xinliang David Li
  0 siblings, 2 replies; 71+ messages in thread
From: Richard Guenther @ 2012-09-13 11:08 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Wed, Sep 12, 2012 at 6:46 PM, Xinliang David Li <davidxl@google.com> wrote:
> On Wed, Sep 12, 2012 at 3:30 AM, Richard Guenther
> <richard.guenther@gmail.com> wrote:
>> On Wed, Sep 12, 2012 at 10:12 AM, Sharad Singhai <singhai@google.com> wrote:
>>> Thanks for your comments. Please see my responses inline.
>>>
>>> On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>> Can you resend your patch in text form (also need to resolve the
>>>> latest conflicts) so that it can be commented inline?
>>>
>>> I tried to include inline patch earlier but my message was bounced
>>> back from patches mailing list. I am trying it again.
>>>
>>>> Please also provide as summary a more up-to-date description of
>>>> 1) Command line option syntax and semantics
>>>
>>> I added some documentation in the patch. Here are the relevant bits
>>> from invoke.texi.
>>>
>>> `-fdump-tree-SWITCH-OPTIONS=FILENAME'
>>>      Control the dumping at various stages of processing the
>>>      intermediate language tree to a file.  The file name is generated
>>>      by appending a switch-specific suffix to the source file name, and
>>>      the file is created in the same directory as the output file. In
>>>      case of `=FILENAME' option, the dump is output on the given file
>>>      instead of the auto named dump files.
>>>      ...
>>>
>>>     `=FILENAME'
>>>           Instead of an auto named dump file, output into the given file
>>>           name. The file names `stdout' and `stderr' are treated
>>>           specially and are considered already open standard streams.
>>>           For example,
>>>
>>>                gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>>>                     -fdump-tree-pre=stderr file.c
>>>
>>>           outputs vectorizer dump into `foo.dump', while the PRE dump
>>>           is output on to `stderr'. If two conflicting dump filenames
>>>           are given for the same pass, then the latter option
>>>           overrides the earlier one.
>>>
>>> `-fopt-info-PASS'
>>> `-fopt-info-PASS-OPTIONS'
>>> `-fopt-info-PASS-OPTIONS=FILENAME'
>>>      Controls optimization dumps from various passes. If the `-OPTIONS'
>>>      form is used, OPTIONS is a list of `-' separated options which
>>>      controls the details of the dump.  If OPTIONS is not specified, it
>>>      defaults to `optimized'. If the FILENAME is not specified, it
>>>      defaults to `stderr'. Note that the output FILENAME will be
>>>      overwritten in case of multiple translation units. If a combined
>>>      output from multiple the translation units is desired, `stderr'
>>>      should be used instead.
>>>
>>>      The PASS could be one of the tree or rtl passes. The following
>>>      options are available
>>
>> I don't like that we have -PASS here.  That makes it awfully similar
>> to -fdump-PASS-OPTIONS=FILENAME.  Are we merely having
>> -fopt-info because OPTIONS are "different"?
>
>
> Having PASS is useful to do filtering. But as your said, the option
> design here is very much oriented towards developers not end users
> which fopt-info is also intended for.

Just to add a comment here - -fopt-info is _only_ targeted at end users.
Developers can use -fdump-tree-XXX=stderr now (which, with the correct
pass / flags should produce identical output to -fopt-info - at least that
was the whole point with the re-design of the dump API - to make it
possible to implement -fopt-info in a way that it simply provides a nice
interface to end-users to our existing dumping information.

If it doesn't work like that right now we should make it work this way.

Richard.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-13 11:08                                                         ` Richard Guenther
@ 2012-09-13 15:02                                                           ` Sharad Singhai
  2012-09-13 16:10                                                           ` Xinliang David Li
  1 sibling, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-09-13 15:02 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

That is a good point. Currently I am making a distinction between dump
flags and opt-info flags, but it is not necessary since the opt-info
flags can be thought of an extension of dump flags.

I will update the patch so that -fdump-tree-vect-optimized also works.

Thanks,
Sharad

On Thu, Sep 13, 2012 at 4:08 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 6:46 PM, Xinliang David Li <davidxl@google.com> wrote:
>> On Wed, Sep 12, 2012 at 3:30 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Wed, Sep 12, 2012 at 10:12 AM, Sharad Singhai <singhai@google.com> wrote:
>>>> Thanks for your comments. Please see my responses inline.
>>>>
>>>> On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> Can you resend your patch in text form (also need to resolve the
>>>>> latest conflicts) so that it can be commented inline?
>>>>
>>>> I tried to include inline patch earlier but my message was bounced
>>>> back from patches mailing list. I am trying it again.
>>>>
>>>>> Please also provide as summary a more up-to-date description of
>>>>> 1) Command line option syntax and semantics
>>>>
>>>> I added some documentation in the patch. Here are the relevant bits
>>>> from invoke.texi.
>>>>
>>>> `-fdump-tree-SWITCH-OPTIONS=FILENAME'
>>>>      Control the dumping at various stages of processing the
>>>>      intermediate language tree to a file.  The file name is generated
>>>>      by appending a switch-specific suffix to the source file name, and
>>>>      the file is created in the same directory as the output file. In
>>>>      case of `=FILENAME' option, the dump is output on the given file
>>>>      instead of the auto named dump files.
>>>>      ...
>>>>
>>>>     `=FILENAME'
>>>>           Instead of an auto named dump file, output into the given file
>>>>           name. The file names `stdout' and `stderr' are treated
>>>>           specially and are considered already open standard streams.
>>>>           For example,
>>>>
>>>>                gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>>>>                     -fdump-tree-pre=stderr file.c
>>>>
>>>>           outputs vectorizer dump into `foo.dump', while the PRE dump
>>>>           is output on to `stderr'. If two conflicting dump filenames
>>>>           are given for the same pass, then the latter option
>>>>           overrides the earlier one.
>>>>
>>>> `-fopt-info-PASS'
>>>> `-fopt-info-PASS-OPTIONS'
>>>> `-fopt-info-PASS-OPTIONS=FILENAME'
>>>>      Controls optimization dumps from various passes. If the `-OPTIONS'
>>>>      form is used, OPTIONS is a list of `-' separated options which
>>>>      controls the details of the dump.  If OPTIONS is not specified, it
>>>>      defaults to `optimized'. If the FILENAME is not specified, it
>>>>      defaults to `stderr'. Note that the output FILENAME will be
>>>>      overwritten in case of multiple translation units. If a combined
>>>>      output from multiple the translation units is desired, `stderr'
>>>>      should be used instead.
>>>>
>>>>      The PASS could be one of the tree or rtl passes. The following
>>>>      options are available
>>>
>>> I don't like that we have -PASS here.  That makes it awfully similar
>>> to -fdump-PASS-OPTIONS=FILENAME.  Are we merely having
>>> -fopt-info because OPTIONS are "different"?
>>
>>
>> Having PASS is useful to do filtering. But as your said, the option
>> design here is very much oriented towards developers not end users
>> which fopt-info is also intended for.
>
> Just to add a comment here - -fopt-info is _only_ targeted at end users.
> Developers can use -fdump-tree-XXX=stderr now (which, with the correct
> pass / flags should produce identical output to -fopt-info - at least that
> was the whole point with the re-design of the dump API - to make it
> possible to implement -fopt-info in a way that it simply provides a nice
> interface to end-users to our existing dumping information.
>
> If it doesn't work like that right now we should make it work this way.
>
> Richard.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
       [not found]                                                     ` <CAAe5K+WvHvnmT8QvKbs9+kxNwO1xdm=RxqqGU3T=z7tcRzQVZg@mail.gmail.com>
@ 2012-09-13 15:10                                                       ` Sharad Singhai
  0 siblings, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-09-13 15:10 UTC (permalink / raw)
  To: Teresa Johnson
  Cc: Xinliang David Li, Richard Guenther, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

> Is -fopt-info-rtl-all also accepted?

Currently it is accepted. However, based on the recent comments, I am
going to remove the pass name from the flags.

>
> It would be useful to have a good default for -fopt-info so that users
> can get high level info about optimizations without having to specify
> a pass. Can -fopt-info be mapped to
> "-fopt-info-tree-all-optimized=stderr

Yes, I have updated the patch so that -fopt-info without any pass
specifier would map to all passes which support this. Currently, only
vectorizer.

> -fopt-info-rtl-all-optimized=stderr"? And perhaps
> -fopt-info-all-OPTIONS can be mapped to all tree and rtl passes?
>
> Thanks,
> Teresa

Thanks,
Sharad

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-13 11:08                                                         ` Richard Guenther
  2012-09-13 15:02                                                           ` Sharad Singhai
@ 2012-09-13 16:10                                                           ` Xinliang David Li
  2012-09-18  8:49                                                             ` Sharad Singhai
  1 sibling, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-09-13 16:10 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Sharad Singhai, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Yes, indeed.

thanks,

David

On Thu, Sep 13, 2012 at 4:08 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Wed, Sep 12, 2012 at 6:46 PM, Xinliang David Li <davidxl@google.com> wrote:
>> On Wed, Sep 12, 2012 at 3:30 AM, Richard Guenther
>> <richard.guenther@gmail.com> wrote:
>>> On Wed, Sep 12, 2012 at 10:12 AM, Sharad Singhai <singhai@google.com> wrote:
>>>> Thanks for your comments. Please see my responses inline.
>>>>
>>>> On Tue, Sep 11, 2012 at 1:16 PM, Xinliang David Li <davidxl@google.com> wrote:
>>>>> Can you resend your patch in text form (also need to resolve the
>>>>> latest conflicts) so that it can be commented inline?
>>>>
>>>> I tried to include inline patch earlier but my message was bounced
>>>> back from patches mailing list. I am trying it again.
>>>>
>>>>> Please also provide as summary a more up-to-date description of
>>>>> 1) Command line option syntax and semantics
>>>>
>>>> I added some documentation in the patch. Here are the relevant bits
>>>> from invoke.texi.
>>>>
>>>> `-fdump-tree-SWITCH-OPTIONS=FILENAME'
>>>>      Control the dumping at various stages of processing the
>>>>      intermediate language tree to a file.  The file name is generated
>>>>      by appending a switch-specific suffix to the source file name, and
>>>>      the file is created in the same directory as the output file. In
>>>>      case of `=FILENAME' option, the dump is output on the given file
>>>>      instead of the auto named dump files.
>>>>      ...
>>>>
>>>>     `=FILENAME'
>>>>           Instead of an auto named dump file, output into the given file
>>>>           name. The file names `stdout' and `stderr' are treated
>>>>           specially and are considered already open standard streams.
>>>>           For example,
>>>>
>>>>                gcc -O2 -ftree-vectorize -fdump-tree-vect-details=foo.dump
>>>>                     -fdump-tree-pre=stderr file.c
>>>>
>>>>           outputs vectorizer dump into `foo.dump', while the PRE dump
>>>>           is output on to `stderr'. If two conflicting dump filenames
>>>>           are given for the same pass, then the latter option
>>>>           overrides the earlier one.
>>>>
>>>> `-fopt-info-PASS'
>>>> `-fopt-info-PASS-OPTIONS'
>>>> `-fopt-info-PASS-OPTIONS=FILENAME'
>>>>      Controls optimization dumps from various passes. If the `-OPTIONS'
>>>>      form is used, OPTIONS is a list of `-' separated options which
>>>>      controls the details of the dump.  If OPTIONS is not specified, it
>>>>      defaults to `optimized'. If the FILENAME is not specified, it
>>>>      defaults to `stderr'. Note that the output FILENAME will be
>>>>      overwritten in case of multiple translation units. If a combined
>>>>      output from multiple the translation units is desired, `stderr'
>>>>      should be used instead.
>>>>
>>>>      The PASS could be one of the tree or rtl passes. The following
>>>>      options are available
>>>
>>> I don't like that we have -PASS here.  That makes it awfully similar
>>> to -fdump-PASS-OPTIONS=FILENAME.  Are we merely having
>>> -fopt-info because OPTIONS are "different"?
>>
>>
>> Having PASS is useful to do filtering. But as your said, the option
>> design here is very much oriented towards developers not end users
>> which fopt-info is also intended for.
>
> Just to add a comment here - -fopt-info is _only_ targeted at end users.
> Developers can use -fdump-tree-XXX=stderr now (which, with the correct
> pass / flags should produce identical output to -fopt-info - at least that
> was the whole point with the re-design of the dump API - to make it
> possible to implement -fopt-info in a way that it simply provides a nice
> interface to end-users to our existing dumping information.
>
> If it doesn't work like that right now we should make it work this way.
>
> Richard.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-13 16:10                                                           ` Xinliang David Li
@ 2012-09-18  8:49                                                             ` Sharad Singhai
  2012-09-18 15:43                                                               ` Xinliang David Li
  2012-09-19 12:02                                                               ` Richard Guenther
  0 siblings, 2 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-09-18  8:49 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

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

In response to the recent comments, I have updated the patch to do the
following:

- Remove pass handling from -fopt-info
- Support additional flags in regular dumps

I have massaged the options so that they have the following (hopefully
clearer) behavior:

gcc ... -fopt-info ....   ---> dump all optimization info on stderr
gcc ... -fopt-info-missed-optimized=file.txt  --> dump info about
optimization applied as well as missed opportunities on to file.txt.
If no file.txt is provided, then use stderr.

I have enhanced regular dump flags, so that values accepted by
-fopt-info are also accepted. For example,
gcc ... -O2 -ftree-vectorize -fdump-tree-vect-optimized=foo.dump

Now foo.dump will include the regular tree-vect dump as well as the
output of -fopt-info=optimized. This way developers can get more
detailed dumps when needed.

I have also changed the meaning of dump option "details" to include
optimization details. Thus "-details" flag implies
"-missed-optimized-note" in addition to other dumps.

The pass level filtering of -fopt-info dumps can be done in a follow
up patch. It may even turn out to be unnecessary, because the
equivalent effect can be achieved by
-ftree-PASS-optimized-missed-note.

I have bootstrapped and tested the attached patch on x86_64 and didn't
observe any new failures. Okay for trunk?

Thanks,
Sharad

[-- Attachment #2: opt-info-2.diff.bz2 --]
[-- Type: application/x-bzip2, Size: 45751 bytes --]

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-18  8:49                                                             ` Sharad Singhai
@ 2012-09-18 15:43                                                               ` Xinliang David Li
  2012-09-18 16:26                                                                 ` Sharad Singhai
  2012-09-19 12:02                                                               ` Richard Guenther
  1 sibling, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-09-18 15:43 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Tue, Sep 18, 2012 at 1:48 AM, Sharad Singhai <singhai@google.com> wrote:
> In response to the recent comments, I have updated the patch to do the
> following:
>
> - Remove pass handling from -fopt-info
> - Support additional flags in regular dumps
>
> I have massaged the options so that they have the following (hopefully
> clearer) behavior:
>
> gcc ... -fopt-info ....   ---> dump all optimization info on stderr
> gcc ... -fopt-info-missed-optimized=file.txt  --> dump info about
> optimization applied as well as missed opportunities on to file.txt.
> If no file.txt is provided, then use stderr.
>
> I have enhanced regular dump flags, so that values accepted by
> -fopt-info are also accepted. For example,
> gcc ... -O2 -ftree-vectorize -fdump-tree-vect-optimized=foo.dump
>
> Now foo.dump will include the regular tree-vect dump as well as the
> output of -fopt-info=optimized. This way developers can get more
> detailed dumps when needed.
>
> I have also changed the meaning of dump option "details" to include
> optimization details. Thus "-details" flag implies
> "-missed-optimized-note" in addition to other dumps.
>
> The pass level filtering of -fopt-info dumps can be done in a follow
> up patch. It may even turn out to be unnecessary, because the
> equivalent effect can be achieved by
> -ftree-PASS-optimized-missed-note.
>

Richard's suggestion to map high level 'pass' names to internal passes
and make it available to -fopt-info filtering for end users as a
follow up pass will be useful.

thanks,

David



> I have bootstrapped and tested the attached patch on x86_64 and didn't
> observe any new failures. Okay for trunk?
>
> Thanks,
> Sharad

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-18 15:43                                                               ` Xinliang David Li
@ 2012-09-18 16:26                                                                 ` Sharad Singhai
  0 siblings, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-09-18 16:26 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Gabriel Dos Reis, Andrew Pinski, gcc-patches, Richard Guenther

On Sep 18, 2012 8:43 AM, "Xinliang David Li" <davidxl@google.com> wrote:
>
> On Tue, Sep 18, 2012 at 1:48 AM, Sharad Singhai <singhai@google.com> wrote:
> > In response to the recent comments, I have updated the patch to do the
> > following:
> >
> > - Remove pass handling from -fopt-info
> > - Support additional flags in regular dumps
> >
> > I have massaged the options so that they have the following (hopefully
> > clearer) behavior:
> >
> > gcc ... -fopt-info ....   ---> dump all optimization info on stderr
> > gcc ... -fopt-info-missed-optimized=file.txt  --> dump info about
> > optimization applied as well as missed opportunities on to file.txt.
> > If no file.txt is provided, then use stderr.
> >
> > I have enhanced regular dump flags, so that values accepted by
> > -fopt-info are also accepted. For example,
> > gcc ... -O2 -ftree-vectorize -fdump-tree-vect-optimized=foo.dump
> >
> > Now foo.dump will include the regular tree-vect dump as well as the
> > output of -fopt-info=optimized. This way developers can get more
> > detailed dumps when needed.
> >
> > I have also changed the meaning of dump option "details" to include
> > optimization details. Thus "-details" flag implies
> > "-missed-optimized-note" in addition to other dumps.
> >
> > The pass level filtering of -fopt-info dumps can be done in a follow
> > up patch. It may even turn out to be unnecessary, because the
> > equivalent effect can be achieved by
> > -ftree-PASS-optimized-missed-note.
> >
>
> Richard's suggestion to map high level 'pass' names to internal passes
> and make it available to -fopt-info filtering for end users as a
> follow up pass will be useful.


Yes, certainly. I plan to do that in a follow up patch. Currently only
vectorization passes use the new dump infrastructure. But as more
passes get converted, it will be nice to have an option for high-level
-fopt-info filtering for end users.

I presume a group of passes would be covered under a single -fopt-info
name, such as loop-optimizations. The exact scheme is yet to be
designed/discussed.

Thanks,
Sharad

>
>
> thanks,
>
> David
>
>
>
> > I have bootstrapped and tested the attached patch on x86_64 and didn't
> > observe any new failures. Okay for trunk?
> >
> > Thanks,
> > Sharad

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-18  8:49                                                             ` Sharad Singhai
  2012-09-18 15:43                                                               ` Xinliang David Li
@ 2012-09-19 12:02                                                               ` Richard Guenther
  2012-09-20  7:15                                                                 ` Sharad Singhai
  1 sibling, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-09-19 12:02 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Tue, Sep 18, 2012 at 10:48 AM, Sharad Singhai <singhai@google.com> wrote:
> In response to the recent comments, I have updated the patch to do the
> following:
>
> - Remove pass handling from -fopt-info
> - Support additional flags in regular dumps
>
> I have massaged the options so that they have the following (hopefully
> clearer) behavior:
>
> gcc ... -fopt-info ....   ---> dump all optimization info on stderr
> gcc ... -fopt-info-missed-optimized=file.txt  --> dump info about
> optimization applied as well as missed opportunities on to file.txt.
> If no file.txt is provided, then use stderr.
>
> I have enhanced regular dump flags, so that values accepted by
> -fopt-info are also accepted. For example,
> gcc ... -O2 -ftree-vectorize -fdump-tree-vect-optimized=foo.dump
>
> Now foo.dump will include the regular tree-vect dump as well as the
> output of -fopt-info=optimized. This way developers can get more
> detailed dumps when needed.

In addition?  The dumping infrastructure has only one dump statement
for each bit so you make it emit things twice in some circumstances then?
That doesn't sound too useful.

> I have also changed the meaning of dump option "details" to include
> optimization details. Thus "-details" flag implies
> "-missed-optimized-note" in addition to other dumps.

I think regular dumps should not accept the -fopt-info flags.

> The pass level filtering of -fopt-info dumps can be done in a follow
> up patch. It may even turn out to be unnecessary, because the
> equivalent effect can be achieved by
> -ftree-PASS-optimized-missed-note.

It can be done as followup, but I think that is what is really useful.
Directing users to -fdump-tree... should never be the answer here.

Richard.

> I have bootstrapped and tested the attached patch on x86_64 and didn't
> observe any new failures. Okay for trunk?
>
> Thanks,
> Sharad

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-19 12:02                                                               ` Richard Guenther
@ 2012-09-20  7:15                                                                 ` Sharad Singhai
  2012-09-24 20:38                                                                   ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-09-20  7:15 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

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

I am enclosing an updated patch. Please see comments inline.

On Wed, Sep 19, 2012 at 5:01 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Tue, Sep 18, 2012 at 10:48 AM, Sharad Singhai <singhai@google.com> wrote:
>> In response to the recent comments, I have updated the patch to do the
>> following:
>>
>> - Remove pass handling from -fopt-info
>> - Support additional flags in regular dumps
>>
>> I have massaged the options so that they have the following (hopefully
>> clearer) behavior:
>>
>> gcc ... -fopt-info ....   ---> dump all optimization info on stderr
>> gcc ... -fopt-info-missed-optimized=file.txt  --> dump info about
>> optimization applied as well as missed opportunities on to file.txt.
>> If no file.txt is provided, then use stderr.
>>
>> I have enhanced regular dump flags, so that values accepted by
>> -fopt-info are also accepted. For example,
>> gcc ... -O2 -ftree-vectorize -fdump-tree-vect-optimized=foo.dump
>>
>> Now foo.dump will include the regular tree-vect dump as well as the
>> output of -fopt-info=optimized. This way developers can get more
>> detailed dumps when needed.
>
> In addition?  The dumping infrastructure has only one dump statement
> for each bit so you make it emit things twice in some circumstances then?
> That doesn't sound too useful.

Perhaps I misled earlier, there is no duplicate information present on
the dump output. There are two separate streams with two disjoint set
of flags. All of the old behavior is preserved except in case of
"-details" flag -- its meaning is augmented to print *all* available
information. Thus a regular dump plus opt-info dump (if any) is output
in response to "-details". Even in this case the output is not
duplicated. So for example,

   gcc ... -ftree-vectorize -fdump-tree-vect-details

would have regular dump plus information about vectorization since the
user asked for details. Earlier this information was missing from the
regular dumps and was only available via -ftree-vectorizer-verbose=N.

As another example, in case of

   gcc ... -fdump-tree-vect-details=foo.details -fopt-info-optimized

The regular tree-vect dump + opt-info dumps are sent to foo.details,
while information about optimized locations only is output onto
stderr. Note that there is some duplication of information here in the
sense that foo.details is a superset of what is dumped to stderr. But
that is what user asked for and this duplication is across two
separate streams.

>> I have also changed the meaning of dump option "details" to include
>> optimization details. Thus "-details" flag implies
>> "-missed-optimized-note" in addition to other dumps.
>
> I think regular dumps should not accept the -fopt-info flags.

Okay, agreed. It is confusing. I have updated the patch so the
-fopt-info flags are no longer accepted by the regular dumps.

>> The pass level filtering of -fopt-info dumps can be done in a follow
>> up patch. It may even turn out to be unnecessary, because the
>> equivalent effect can be achieved by
>> -ftree-PASS-optimized-missed-note.
>
> It can be done as followup, but I think that is what is really useful.
> Directing users to -fdump-tree... should never be the answer here.

Agreed. I still need to come up with some kind of mapping between
higher-level optimizations and corresponding group of passes. That
needs some discussion and that is why I didn't want to tackle it right
away as part of this patch.

Thanks,
Sharad

> Richard.
>
>> I have bootstrapped and tested the attached patch on x86_64 and didn't
>> observe any new failures. Okay for trunk?
>>
>> Thanks,
>> Sharad

[-- Attachment #2: opt-info-3.diff.bz2 --]
[-- Type: application/x-bzip2, Size: 45721 bytes --]

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-20  7:15                                                                 ` Sharad Singhai
@ 2012-09-24 20:38                                                                   ` Sharad Singhai
  2012-09-26 14:13                                                                     ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-09-24 20:38 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Ping.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-24 20:38                                                                   ` Sharad Singhai
@ 2012-09-26 14:13                                                                     ` Richard Guenther
  2012-09-27 12:27                                                                       ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-09-26 14:13 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Mon, Sep 24, 2012 at 10:10 PM, Sharad Singhai <singhai@google.com> wrote:
> Ping.

Some minor issues:

        * c/c-decl.c (c_write_global_declarations): Use different method to
        determine if the dump has ben initialized.
        * cp/decl2.c (cp_write_global_declarations): Ditto.
        * testsuite/gcc.target/i386/vect-double-1.c: Fix test.

these subdirs all have their separate ChangeLog entry from where the
directory name is omitted.

Index: tree-dump.c
===================================================================
--- tree-dump.c (revision 191490)
+++ tree-dump.c (working copy)
@@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "coretypes.h"
 #include "tm.h"
 #include "tree.h"
+#include "gimple-pretty-print.h"
 #include "splay-tree.h"
 #include "filenames.h"
 #include "diagnostic-core.h"
+#include "rtl.h"

what do you need gimple-pretty-print.h and rtl.h for?

+
+extern void dump_bb (FILE *, basic_block, int, int);
+

that should be declared in some header

+/* Dump gimple statement GS with SPC indentation spaces and
+   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
+
+void
+dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int spc)
+{

the gimple stuff really belongs in to gimple-pretty-print.c

(parts of tree-dump.c should be moved to a new file dumpfile.c)

+/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
+   enabled.  */
+
+void
+dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
+{

belongs to tree-pretty-print.c (to where the routines are it calls)

+int
+dump_start (int phase, int *flag_ptr)
+{

perfect candidate for dumpfile.c

You can do this re-shuffling as followup, but please try to not include rtl.h
or gimple-pretty-print.h from tree-dump.c.  Thus re-shuffling required by that
do now.  tree-dump.c should only know about dumping 'tree'.

Index: tree-dump.h
===================================================================
--- tree-dump.h (revision 191490)
+++ tree-dump.h (working copy)
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_TREE_DUMP_H
 #define GCC_TREE_DUMP_H

+#include "input.h"

probably no longer required.

Index: dumpfile.h
===================================================================
--- dumpfile.h  (revision 191490)
+++ dumpfile.h  (working copy)
@@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
 #ifndef GCC_DUMPFILE_H
 #define GCC_DUMPFILE_H 1

+#include "coretypes.h"
+#include "input.h"

likewise for input.h.

Index: testsuite/gcc.target/i386/vect-double-1.c
===================================================================
--- testsuite/gcc.target/i386/vect-double-1.c   (revision 191490)
+++ testsuite/gcc.target/i386/vect-double-1.c   (working copy)
@@ -32,5 +32,5 @@ sse2_test (void)
     }
 }

-/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
+/* { dg-final { scan-tree-dump-times "Vectorized loops: 1" 1 "vect" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */

I am sure you need a gazillion more testsuite adjustments?  Thus, did you
really test the patch by a bootstrap and a toplevel make -k check for
regressions?

Index: opts.c
===================================================================
--- opts.c      (revision 191490)
+++ opts.c      (working copy)
@@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "intl.h"
 #include "coretypes.h"
+#include "dumpfile.h"

I don't see that you add a use for this.  Please double-check all your include
file changes.

Index: gimple-pretty-print.c
===================================================================
--- gimple-pretty-print.c       (revision 191490)
+++ gimple-pretty-print.c       (working copy)
@@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
 }
...
Index: gimple-pretty-print.h
===================================================================
--- gimple-pretty-print.h       (revision 191490)
+++ gimple-pretty-print.h       (working copy)
@@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
 extern void print_gimple_stmt (FILE *, gimple, int, int);
 extern void print_gimple_expr (FILE *, gimple, int, int);
-extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
+extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);

it looks like changes to these files are only renaming of existing
dump_ functions
to print_ functions.  Consider testing and applying those separately (hereby
pre-approved).

Index: profile.c
===================================================================
--- profile.c   (revision 191490)
+++ profile.c   (working copy)
@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see

please leave further changes to passes as followup, thus omit changes to this
file for the initial commit and submit it separately.


Index: rtl.h
===================================================================
--- rtl.h       (revision 191490)
+++ rtl.h       (working copy)
@@ -2482,8 +2482,8 @@ extern bool validate_subreg (enum machine_mode, en
 /* In combine.c  */
 extern unsigned int extended_count (const_rtx, enum machine_mode, int);
 extern rtx remove_death (unsigned int, rtx);
-extern void dump_combine_stats (FILE *);
-extern void dump_combine_total_stats (FILE *);
+extern void debug_combine_stats (FILE *);
+extern void print_combine_total_stats (FILE *);
 extern rtx make_compound_operation (rtx, enum rtx_code);
Index: combine.c
===================================================================
--- combine.c   (revision 191490)
+++ combine.c   (working copy)
...

Likewise a patch just doing this re-name is pre-approved and should be checked
in separately.

@@ -410,6 +419,10 @@ handle_common_deferred_options (void)
          stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt->arg));
          break;

+        case OPT_ftree_vectorizer_verbose_:
+         dump_remap_tree_vectorizer_verbose (opt->arg);
+          break;
+

can you please move that function here (opts-global.c) and make it static?

Index: Makefile.in
===================================================================
--- Makefile.in (revision 191490)
+++ Makefile.in (working copy)

remember to adjust for any changes you do above

Otherwise the patch looks ok to me.

Thanks,
Richard.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-26 14:13                                                                     ` Richard Guenther
@ 2012-09-27 12:27                                                                       ` Sharad Singhai
  2012-09-27 17:06                                                                         ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-09-27 12:27 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Thanks for the review. A couple of comments inline:

> Some minor issues:
>
>         * c/c-decl.c (c_write_global_declarations): Use different method to
>         determine if the dump has ben initialized.
>         * cp/decl2.c (cp_write_global_declarations): Ditto.
>         * testsuite/gcc.target/i386/vect-double-1.c: Fix test.
>
> these subdirs all have their separate ChangeLog entry from where the
> directory name is omitted.
>
> Index: tree-dump.c
> ===================================================================
> --- tree-dump.c (revision 191490)
> +++ tree-dump.c (working copy)
> @@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
>  #include "coretypes.h"
>  #include "tm.h"
>  #include "tree.h"
> +#include "gimple-pretty-print.h"
>  #include "splay-tree.h"
>  #include "filenames.h"
>  #include "diagnostic-core.h"
> +#include "rtl.h"
>
> what do you need gimple-pretty-print.h and rtl.h for?
>
> +
> +extern void dump_bb (FILE *, basic_block, int, int);
> +
>
> that should be declared in some header
>
> +/* Dump gimple statement GS with SPC indentation spaces and
> +   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
> +
> +void
> +dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int spc)
> +{
>
> the gimple stuff really belongs in to gimple-pretty-print.c

This dump_gimple_stmt () is just a dispatcher, which uses internal
data structure such as dump streams/flags. If I move it into
gimple-pretty-print.c, then I would have to export those
streams/flags. I was hoping to avoid it by keeping all dump_* ()
methods together in dumpfile.c (earlier in tree-dump.c). Thus, later
one could just make dump_file/dump_flags static when all the passes
have converted to this scheme.

>
> (parts of tree-dump.c should be moved to a new file dumpfile.c)
>
> +/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
> +   enabled.  */
> +
> +void
> +dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
> +{
>
> belongs to tree-pretty-print.c (to where the routines are it calls)

This is again a dispatcher for dump_generic_expr () which writes to
the appropriate stream depending upon dump_kind.

>
> +int
> +dump_start (int phase, int *flag_ptr)
> +{
>
> perfect candidate for dumpfile.c
>
> You can do this re-shuffling as followup, but please try to not include rtl.h
> or gimple-pretty-print.h from tree-dump.c.  Thus re-shuffling required by that
> do now.  tree-dump.c should only know about dumping 'tree'.

Okay, I have moved relevant methods into dumpfile.c.

>
> Index: tree-dump.h
> ===================================================================
> --- tree-dump.h (revision 191490)
> +++ tree-dump.h (working copy)
> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>  #ifndef GCC_TREE_DUMP_H
>  #define GCC_TREE_DUMP_H
>
> +#include "input.h"
>
> probably no longer required.
>
> Index: dumpfile.h
> ===================================================================
> --- dumpfile.h  (revision 191490)
> +++ dumpfile.h  (working copy)
> @@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
>  #ifndef GCC_DUMPFILE_H
>  #define GCC_DUMPFILE_H 1
>
> +#include "coretypes.h"
> +#include "input.h"
>
> likewise for input.h.
>
> Index: testsuite/gcc.target/i386/vect-double-1.c
> ===================================================================
> --- testsuite/gcc.target/i386/vect-double-1.c   (revision 191490)
> +++ testsuite/gcc.target/i386/vect-double-1.c   (working copy)
> @@ -32,5 +32,5 @@ sse2_test (void)
>      }
>  }
>
> -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
> +/* { dg-final { scan-tree-dump-times "Vectorized loops: 1" 1 "vect" } } */
>  /* { dg-final { cleanup-tree-dump "vect" } } */
>
> I am sure you need a gazillion more testsuite adjustments?  Thus, did you
> really test the patch by a bootstrap and a toplevel make -k check for
> regressions?
>
> Index: opts.c
> ===================================================================
> --- opts.c      (revision 191490)
> +++ opts.c      (working copy)
> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "system.h"
>  #include "intl.h"
>  #include "coretypes.h"
> +#include "dumpfile.h"
>
> I don't see that you add a use for this.  Please double-check all your include
> file changes.
>
> Index: gimple-pretty-print.c
> ===================================================================
> --- gimple-pretty-print.c       (revision 191490)
> +++ gimple-pretty-print.c       (working copy)
> @@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
>  }
> ...
> Index: gimple-pretty-print.h
> ===================================================================
> --- gimple-pretty-print.h       (revision 191490)
> +++ gimple-pretty-print.h       (working copy)
> @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>  extern void print_gimple_stmt (FILE *, gimple, int, int);
>  extern void print_gimple_expr (FILE *, gimple, int, int);
> -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
> +extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>
> it looks like changes to these files are only renaming of existing
> dump_ functions
> to print_ functions.  Consider testing and applying those separately (hereby
> pre-approved).
>
> Index: profile.c
> ===================================================================
> --- profile.c   (revision 191490)
> +++ profile.c   (working copy)
> @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
>
> please leave further changes to passes as followup, thus omit changes to this
> file for the initial commit and submit it separately.

Okay.

>
>
> Index: rtl.h
> ===================================================================
> --- rtl.h       (revision 191490)
> +++ rtl.h       (working copy)
> @@ -2482,8 +2482,8 @@ extern bool validate_subreg (enum machine_mode, en
>  /* In combine.c  */
>  extern unsigned int extended_count (const_rtx, enum machine_mode, int);
>  extern rtx remove_death (unsigned int, rtx);
> -extern void dump_combine_stats (FILE *);
> -extern void dump_combine_total_stats (FILE *);
> +extern void debug_combine_stats (FILE *);
> +extern void print_combine_total_stats (FILE *);
>  extern rtx make_compound_operation (rtx, enum rtx_code);
> Index: combine.c
> ===================================================================
> --- combine.c   (revision 191490)
> +++ combine.c   (working copy)
> ...
>
> Likewise a patch just doing this re-name is pre-approved and should be checked
> in separately.
>
> @@ -410,6 +419,10 @@ handle_common_deferred_options (void)
>           stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt->arg));
>           break;
>
> +        case OPT_ftree_vectorizer_verbose_:
> +         dump_remap_tree_vectorizer_verbose (opt->arg);
> +          break;
> +
>
> can you please move that function here (opts-global.c) and make it static?

Done.

>
> Index: Makefile.in
> ===================================================================
> --- Makefile.in (revision 191490)
> +++ Makefile.in (working copy)
>
> remember to adjust for any changes you do above
>
> Otherwise the patch looks ok to me.
>
> Thanks,
> Richard.

Thanks,
Sharad

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-09-27 12:27                                                                       ` Sharad Singhai
@ 2012-09-27 17:06                                                                         ` Xinliang David Li
       [not found]                                                                           ` <CAKxPW65ohN989RuyK+XqJDjOJ4gFVF9hB4+qfP0LfU_6q4i8yw@mail.gmail.com>
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-09-27 17:06 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Thu, Sep 27, 2012 at 4:35 AM, Sharad Singhai <singhai@google.com> wrote:
> Thanks for the review. A couple of comments inline:
>
>> Some minor issues:
>>
>>         * c/c-decl.c (c_write_global_declarations): Use different method to
>>         determine if the dump has ben initialized.
>>         * cp/decl2.c (cp_write_global_declarations): Ditto.
>>         * testsuite/gcc.target/i386/vect-double-1.c: Fix test.
>>
>> these subdirs all have their separate ChangeLog entry from where the
>> directory name is omitted.
>>
>> Index: tree-dump.c
>> ===================================================================
>> --- tree-dump.c (revision 191490)
>> +++ tree-dump.c (working copy)
>> @@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "coretypes.h"
>>  #include "tm.h"
>>  #include "tree.h"
>> +#include "gimple-pretty-print.h"
>>  #include "splay-tree.h"
>>  #include "filenames.h"
>>  #include "diagnostic-core.h"
>> +#include "rtl.h"
>>
>> what do you need gimple-pretty-print.h and rtl.h for?
>>
>> +
>> +extern void dump_bb (FILE *, basic_block, int, int);
>> +
>>
>> that should be declared in some header
>>
>> +/* Dump gimple statement GS with SPC indentation spaces and
>> +   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
>> +
>> +void
>> +dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int spc)
>> +{
>>
>> the gimple stuff really belongs in to gimple-pretty-print.c
>
> This dump_gimple_stmt () is just a dispatcher, which uses internal
> data structure such as dump streams/flags. If I move it into
> gimple-pretty-print.c, then I would have to export those
> streams/flags. I was hoping to avoid it by keeping all dump_* ()
> methods together in dumpfile.c (earlier in tree-dump.c). Thus, later
> one could just make dump_file/dump_flags static when all the passes
> have converted to this scheme.
>

You can make the flags/streams global but only expose them via inline
accessors in the header file.

David

>>
>> (parts of tree-dump.c should be moved to a new file dumpfile.c)
>>
>> +/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
>> +   enabled.  */
>> +
>> +void
>> +dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
>> +{
>>
>> belongs to tree-pretty-print.c (to where the routines are it calls)
>
> This is again a dispatcher for dump_generic_expr () which writes to
> the appropriate stream depending upon dump_kind.
>
>>
>> +int
>> +dump_start (int phase, int *flag_ptr)
>> +{
>>
>> perfect candidate for dumpfile.c
>>
>> You can do this re-shuffling as followup, but please try to not include rtl.h
>> or gimple-pretty-print.h from tree-dump.c.  Thus re-shuffling required by that
>> do now.  tree-dump.c should only know about dumping 'tree'.
>
> Okay, I have moved relevant methods into dumpfile.c.
>
>>
>> Index: tree-dump.h
>> ===================================================================
>> --- tree-dump.h (revision 191490)
>> +++ tree-dump.h (working copy)
>> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_TREE_DUMP_H
>>  #define GCC_TREE_DUMP_H
>>
>> +#include "input.h"
>>
>> probably no longer required.
>>
>> Index: dumpfile.h
>> ===================================================================
>> --- dumpfile.h  (revision 191490)
>> +++ dumpfile.h  (working copy)
>> @@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
>>  #ifndef GCC_DUMPFILE_H
>>  #define GCC_DUMPFILE_H 1
>>
>> +#include "coretypes.h"
>> +#include "input.h"
>>
>> likewise for input.h.
>>
>> Index: testsuite/gcc.target/i386/vect-double-1.c
>> ===================================================================
>> --- testsuite/gcc.target/i386/vect-double-1.c   (revision 191490)
>> +++ testsuite/gcc.target/i386/vect-double-1.c   (working copy)
>> @@ -32,5 +32,5 @@ sse2_test (void)
>>      }
>>  }
>>
>> -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */
>> +/* { dg-final { scan-tree-dump-times "Vectorized loops: 1" 1 "vect" } } */
>>  /* { dg-final { cleanup-tree-dump "vect" } } */
>>
>> I am sure you need a gazillion more testsuite adjustments?  Thus, did you
>> really test the patch by a bootstrap and a toplevel make -k check for
>> regressions?
>>
>> Index: opts.c
>> ===================================================================
>> --- opts.c      (revision 191490)
>> +++ opts.c      (working copy)
>> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>>  #include "system.h"
>>  #include "intl.h"
>>  #include "coretypes.h"
>> +#include "dumpfile.h"
>>
>> I don't see that you add a use for this.  Please double-check all your include
>> file changes.
>>
>> Index: gimple-pretty-print.c
>> ===================================================================
>> --- gimple-pretty-print.c       (revision 191490)
>> +++ gimple-pretty-print.c       (working copy)
>> @@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
>>  }
>> ...
>> Index: gimple-pretty-print.h
>> ===================================================================
>> --- gimple-pretty-print.h       (revision 191490)
>> +++ gimple-pretty-print.h       (working copy)
>> @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>>  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>>  extern void print_gimple_stmt (FILE *, gimple, int, int);
>>  extern void print_gimple_expr (FILE *, gimple, int, int);
>> -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
>> +extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>>
>> it looks like changes to these files are only renaming of existing
>> dump_ functions
>> to print_ functions.  Consider testing and applying those separately (hereby
>> pre-approved).
>>
>> Index: profile.c
>> ===================================================================
>> --- profile.c   (revision 191490)
>> +++ profile.c   (working copy)
>> @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
>>
>> please leave further changes to passes as followup, thus omit changes to this
>> file for the initial commit and submit it separately.
>
> Okay.
>
>>
>>
>> Index: rtl.h
>> ===================================================================
>> --- rtl.h       (revision 191490)
>> +++ rtl.h       (working copy)
>> @@ -2482,8 +2482,8 @@ extern bool validate_subreg (enum machine_mode, en
>>  /* In combine.c  */
>>  extern unsigned int extended_count (const_rtx, enum machine_mode, int);
>>  extern rtx remove_death (unsigned int, rtx);
>> -extern void dump_combine_stats (FILE *);
>> -extern void dump_combine_total_stats (FILE *);
>> +extern void debug_combine_stats (FILE *);
>> +extern void print_combine_total_stats (FILE *);
>>  extern rtx make_compound_operation (rtx, enum rtx_code);
>> Index: combine.c
>> ===================================================================
>> --- combine.c   (revision 191490)
>> +++ combine.c   (working copy)
>> ...
>>
>> Likewise a patch just doing this re-name is pre-approved and should be checked
>> in separately.
>>
>> @@ -410,6 +419,10 @@ handle_common_deferred_options (void)
>>           stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (opt->arg));
>>           break;
>>
>> +        case OPT_ftree_vectorizer_verbose_:
>> +         dump_remap_tree_vectorizer_verbose (opt->arg);
>> +          break;
>> +
>>
>> can you please move that function here (opts-global.c) and make it static?
>
> Done.
>
>>
>> Index: Makefile.in
>> ===================================================================
>> --- Makefile.in (revision 191490)
>> +++ Makefile.in (working copy)
>>
>> remember to adjust for any changes you do above
>>
>> Otherwise the patch looks ok to me.
>>
>> Thanks,
>> Richard.
>
> Thanks,
> Sharad

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
       [not found]                                                                           ` <CAKxPW65ohN989RuyK+XqJDjOJ4gFVF9hB4+qfP0LfU_6q4i8yw@mail.gmail.com>
@ 2012-10-01  6:37                                                                             ` Sharad Singhai
  2012-10-01 11:51                                                                               ` H.J. Lu
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-10-01  6:37 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Richard Guenther, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Resend to gcc-patches

I have addressed the comments by fixing all the minor issues,
bootstrapped and tested on x86_64. I did the recommended reshuffling
by moving non-tree code from tree-dump.c into a new file dumpfile.c.

I committed two successive revisions
r191883 Main patch with the dump infrastructure changes. However, I
accidentally left out a new file, dumpfile.c.
r191884 Added dumpfile.c, and did the renaming of dump_* functions
from gimple_pretty_print.[ch].

As things stand right now, r191883 is broken because of the missing
file 'dumpfile.c', which the very next commit fixes. Anyone who got
broken revision r191883, please svn update. I am really very sorry
about that.

I have a couple more minor patches which deal with renaming; I plan to
address those later.

Thanks,
Sharad

> On Thu, Sep 27, 2012 at 9:10 AM, Xinliang David Li <davidxl@google.com>
> wrote:
>>
>> On Thu, Sep 27, 2012 at 4:35 AM, Sharad Singhai <singhai@google.com>
>> wrote:
>> > Thanks for the review. A couple of comments inline:
>> >
>> >> Some minor issues:
>> >>
>> >>         * c/c-decl.c (c_write_global_declarations): Use different
>> >> method to
>> >>         determine if the dump has ben initialized.
>> >>         * cp/decl2.c (cp_write_global_declarations): Ditto.
>> >>         * testsuite/gcc.target/i386/vect-double-1.c: Fix test.
>> >>
>> >> these subdirs all have their separate ChangeLog entry from where the
>> >> directory name is omitted.
>> >>
>> >> Index: tree-dump.c
>> >> ===================================================================
>> >> --- tree-dump.c (revision 191490)
>> >> +++ tree-dump.c (working copy)
>> >> @@ -24,9 +24,11 @@ along with GCC; see the file COPYING3.  If not see
>> >>  #include "coretypes.h"
>> >>  #include "tm.h"
>> >>  #include "tree.h"
>> >> +#include "gimple-pretty-print.h"
>> >>  #include "splay-tree.h"
>> >>  #include "filenames.h"
>> >>  #include "diagnostic-core.h"
>> >> +#include "rtl.h"
>> >>
>> >> what do you need gimple-pretty-print.h and rtl.h for?
>> >>
>> >> +
>> >> +extern void dump_bb (FILE *, basic_block, int, int);
>> >> +
>> >>
>> >> that should be declared in some header
>> >>
>> >> +/* Dump gimple statement GS with SPC indentation spaces and
>> >> +   EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
>> >> +
>> >> +void
>> >> +dump_gimple_stmt (int dump_kind, int extra_dump_flags, gimple gs, int
>> >> spc)
>> >> +{
>> >>
>> >> the gimple stuff really belongs in to gimple-pretty-print.c
>> >
>> > This dump_gimple_stmt () is just a dispatcher, which uses internal
>> > data structure such as dump streams/flags. If I move it into
>> > gimple-pretty-print.c, then I would have to export those
>> > streams/flags. I was hoping to avoid it by keeping all dump_* ()
>> > methods together in dumpfile.c (earlier in tree-dump.c). Thus, later
>> > one could just make dump_file/dump_flags static when all the passes
>> > have converted to this scheme.
>> >
>>
>> You can make the flags/streams global but only expose them via inline
>> accessors in the header file.
>>
>> David
>>
>> >>
>> >> (parts of tree-dump.c should be moved to a new file dumpfile.c)
>> >>
>> >> +/* Dump tree T using EXTRA_DUMP_FLAGS on dump streams if DUMP_KIND is
>> >> +   enabled.  */
>> >> +
>> >> +void
>> >> +dump_generic_expr (int dump_kind, int extra_dump_flags, tree t)
>> >> +{
>> >>
>> >> belongs to tree-pretty-print.c (to where the routines are it calls)
>> >
>> > This is again a dispatcher for dump_generic_expr () which writes to
>> > the appropriate stream depending upon dump_kind.
>> >
>> >>
>> >> +int
>> >> +dump_start (int phase, int *flag_ptr)
>> >> +{
>> >>
>> >> perfect candidate for dumpfile.c
>> >>
>> >> You can do this re-shuffling as followup, but please try to not include
>> >> rtl.h
>> >> or gimple-pretty-print.h from tree-dump.c.  Thus re-shuffling required
>> >> by that
>> >> do now.  tree-dump.c should only know about dumping 'tree'.
>> >
>> > Okay, I have moved relevant methods into dumpfile.c.
>> >
>> >>
>> >> Index: tree-dump.h
>> >> ===================================================================
>> >> --- tree-dump.h (revision 191490)
>> >> +++ tree-dump.h (working copy)
>> >> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>> >>  #ifndef GCC_TREE_DUMP_H
>> >>  #define GCC_TREE_DUMP_H
>> >>
>> >> +#include "input.h"
>> >>
>> >> probably no longer required.
>> >>
>> >> Index: dumpfile.h
>> >> ===================================================================
>> >> --- dumpfile.h  (revision 191490)
>> >> +++ dumpfile.h  (working copy)
>> >> @@ -22,6 +22,9 @@ along with GCC; see the file COPYING3.  If not see
>> >>  #ifndef GCC_DUMPFILE_H
>> >>  #define GCC_DUMPFILE_H 1
>> >>
>> >> +#include "coretypes.h"
>> >> +#include "input.h"
>> >>
>> >> likewise for input.h.
>> >>
>> >> Index: testsuite/gcc.target/i386/vect-double-1.c
>> >> ===================================================================
>> >> --- testsuite/gcc.target/i386/vect-double-1.c   (revision 191490)
>> >> +++ testsuite/gcc.target/i386/vect-double-1.c   (working copy)
>> >> @@ -32,5 +32,5 @@ sse2_test (void)
>> >>      }
>> >>  }
>> >>
>> >> -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } }
>> >> */
>> >> +/* { dg-final { scan-tree-dump-times "Vectorized loops: 1" 1 "vect" }
>> >> } */
>> >>  /* { dg-final { cleanup-tree-dump "vect" } } */
>> >>
>> >> I am sure you need a gazillion more testsuite adjustments?  Thus, did
>> >> you
>> >> really test the patch by a bootstrap and a toplevel make -k check for
>> >> regressions?
>> >>
>> >> Index: opts.c
>> >> ===================================================================
>> >> --- opts.c      (revision 191490)
>> >> +++ opts.c      (working copy)
>> >> @@ -25,6 +25,7 @@ along with GCC; see the file COPYING3.  If not see
>> >>  #include "system.h"
>> >>  #include "intl.h"
>> >>  #include "coretypes.h"
>> >> +#include "dumpfile.h"
>> >>
>> >> I don't see that you add a use for this.  Please double-check all your
>> >> include
>> >> file changes.
>> >>
>> >> Index: gimple-pretty-print.c
>> >> ===================================================================
>> >> --- gimple-pretty-print.c       (revision 191490)
>> >> +++ gimple-pretty-print.c       (working copy)
>> >> @@ -69,7 +69,7 @@ maybe_init_pretty_print (FILE *file)
>> >>  }
>> >> ...
>> >> Index: gimple-pretty-print.h
>> >> ===================================================================
>> >> --- gimple-pretty-print.h       (revision 191490)
>> >> +++ gimple-pretty-print.h       (working copy)
>> >> @@ -31,6 +31,6 @@ extern void debug_gimple_seq (gimple_seq);
>> >>  extern void print_gimple_seq (FILE *, gimple_seq, int, int);
>> >>  extern void print_gimple_stmt (FILE *, gimple, int, int);
>> >>  extern void print_gimple_expr (FILE *, gimple, int, int);
>> >> -extern void dump_gimple_stmt (pretty_printer *, gimple, int, int);
>> >> +extern void pp_gimple_stmt_1 (pretty_printer *, gimple, int, int);
>> >>
>> >> it looks like changes to these files are only renaming of existing
>> >> dump_ functions
>> >> to print_ functions.  Consider testing and applying those separately
>> >> (hereby
>> >> pre-approved).
>> >>
>> >> Index: profile.c
>> >> ===================================================================
>> >> --- profile.c   (revision 191490)
>> >> +++ profile.c   (working copy)
>> >> @@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.  If not see
>> >>
>> >> please leave further changes to passes as followup, thus omit changes
>> >> to this
>> >> file for the initial commit and submit it separately.
>> >
>> > Okay.
>> >
>> >>
>> >>
>> >> Index: rtl.h
>> >> ===================================================================
>> >> --- rtl.h       (revision 191490)
>> >> +++ rtl.h       (working copy)
>> >> @@ -2482,8 +2482,8 @@ extern bool validate_subreg (enum machine_mode,
>> >> en
>> >>  /* In combine.c  */
>> >>  extern unsigned int extended_count (const_rtx, enum machine_mode,
>> >> int);
>> >>  extern rtx remove_death (unsigned int, rtx);
>> >> -extern void dump_combine_stats (FILE *);
>> >> -extern void dump_combine_total_stats (FILE *);
>> >> +extern void debug_combine_stats (FILE *);
>> >> +extern void print_combine_total_stats (FILE *);
>> >>  extern rtx make_compound_operation (rtx, enum rtx_code);
>> >> Index: combine.c
>> >> ===================================================================
>> >> --- combine.c   (revision 191490)
>> >> +++ combine.c   (working copy)
>> >> ...
>> >>
>> >> Likewise a patch just doing this re-name is pre-approved and should be
>> >> checked
>> >> in separately.
>> >>
>> >> @@ -410,6 +419,10 @@ handle_common_deferred_options (void)
>> >>           stack_limit_rtx = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup
>> >> (opt->arg));
>> >>           break;
>> >>
>> >> +        case OPT_ftree_vectorizer_verbose_:
>> >> +         dump_remap_tree_vectorizer_verbose (opt->arg);
>> >> +          break;
>> >> +
>> >>
>> >> can you please move that function here (opts-global.c) and make it
>> >> static?
>> >
>> > Done.
>> >
>> >>
>> >> Index: Makefile.in
>> >> ===================================================================
>> >> --- Makefile.in (revision 191490)
>> >> +++ Makefile.in (working copy)
>> >>
>> >> remember to adjust for any changes you do above
>> >>
>> >> Otherwise the patch looks ok to me.
>> >>
>> >> Thanks,
>> >> Richard.
>> >
>> > Thanks,
>> > Sharad
>
>

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01  6:37                                                                             ` Sharad Singhai
@ 2012-10-01 11:51                                                                               ` H.J. Lu
  2012-10-01 13:50                                                                                 ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: H.J. Lu @ 2012-10-01 11:51 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Richard Guenther, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

On Sun, Sep 30, 2012 at 11:36 PM, Sharad Singhai <singhai@google.com> wrote:
> Resend to gcc-patches
>
> I have addressed the comments by fixing all the minor issues,
> bootstrapped and tested on x86_64. I did the recommended reshuffling
> by moving non-tree code from tree-dump.c into a new file dumpfile.c.
>
> I committed two successive revisions
> r191883 Main patch with the dump infrastructure changes. However, I
> accidentally left out a new file, dumpfile.c.
> r191884 Added dumpfile.c, and did the renaming of dump_* functions
> from gimple_pretty_print.[ch].
>
> As things stand right now, r191883 is broken because of the missing
> file 'dumpfile.c', which the very next commit fixes. Anyone who got
> broken revision r191883, please svn update. I am really very sorry
> about that.
>
> I have a couple more minor patches which deal with renaming; I plan to
> address those later.
>

It caused:

FAIL: gcc.dg/tree-ssa/gen-vect-11.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-11.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-11a.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-11a.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-11b.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-11b.c scan-tree-dump-times vect
"vectorized 0 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-11c.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-11c.c scan-tree-dump-times vect
"vectorized 0 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-2.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-2.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-25.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-25.c scan-tree-dump-times vect
"vectorized 2 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-26.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
"Alignment of access forced using peeling" 1
FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-28.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
"Alignment of access forced using peeling" 1
FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gcc.dg/tree-ssa/gen-vect-32.c (test for excess errors)
FAIL: gcc.dg/tree-ssa/gen-vect-32.c scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gfortran.dg/vect/O3-pr36119.f90 (test for excess errors)
FAIL: gfortran.dg/vect/O3-pr39595.f (test for excess errors)
FAIL: gfortran.dg/vect/Ofast-pr50414.f90 (test for excess errors)
FAIL: gfortran.dg/vect/cost-model-pr34445.f (test for excess errors)
FAIL: gfortran.dg/vect/cost-model-pr34445a.f (test for excess errors)
FAIL: gfortran.dg/vect/fast-math-pr38968.f90 (test for excess errors)
FAIL: gfortran.dg/vect/fast-math-pr38968.f90 scan-tree-dump vect
"vectorized 1 loops"
FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
FAIL: gfortran.dg/vect/fast-math-vect-8.f90 (test for excess errors)
FAIL: gfortran.dg/vect/fast-math-vect-8.f90 scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90 (test for
excess errors)
FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 (test for excess errors)
FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 scan-tree-dump-times vect
"vectorized 2 loops" 1
FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 (test for excess errors)
FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 scan-tree-dump-times vect
"vectorized 0 loops" 1
FAIL: gfortran.dg/vect/pr19049.f90  -O   scan-tree-dump-times vect
"complicated access pattern" 1
FAIL: gfortran.dg/vect/pr19049.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr32377.f90  -O   scan-tree-dump-times vect
"vectorized 2 loops" 1
FAIL: gfortran.dg/vect/pr32377.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr32380.f  -O   scan-tree-dump-times vect
"vectorized 6 loops" 1
FAIL: gfortran.dg/vect/pr32380.f  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr33301.f  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr50178.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr50412.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr51058-2.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr51058.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/pr51285.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/vect-1.f90  -O   scan-tree-dump-times vect
"vectorized 3 loops" 1
FAIL: gfortran.dg/vect/vect-1.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
"Alignment of access forced using peeling" 3
FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
"Vectorizing an unaligned access" 2
FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
"vectorized 3 loops" 1
FAIL: gfortran.dg/vect/vect-2.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
"Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
"Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/vect-3.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
"Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
"Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
"accesses have the same alignment." 1
FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gfortran.dg/vect/vect-4.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
"Alignment of access forced using peeling" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
"Vectorizing an unaligned access" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
"vectorized 1 loops" 1
FAIL: gfortran.dg/vect/vect-5.f90  -O  (test for excess errors)
FAIL: gfortran.dg/vect/vect-6.f  -O  (test for excess errors)

on Linux/x86.

-- 
H.J.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 11:51                                                                               ` H.J. Lu
@ 2012-10-01 13:50                                                                                 ` Sharad Singhai
  2012-10-01 13:52                                                                                   ` H.J. Lu
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-10-01 13:50 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Xinliang David Li, Richard Guenther, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

I am sorry, I didn't enable all the languages. Will fix the fortran
test breakage shortly.

Thanks,
Sharad
Sharad


On Mon, Oct 1, 2012 at 4:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Sun, Sep 30, 2012 at 11:36 PM, Sharad Singhai <singhai@google.com> wrote:
>> Resend to gcc-patches
>>
>> I have addressed the comments by fixing all the minor issues,
>> bootstrapped and tested on x86_64. I did the recommended reshuffling
>> by moving non-tree code from tree-dump.c into a new file dumpfile.c.
>>
>> I committed two successive revisions
>> r191883 Main patch with the dump infrastructure changes. However, I
>> accidentally left out a new file, dumpfile.c.
>> r191884 Added dumpfile.c, and did the renaming of dump_* functions
>> from gimple_pretty_print.[ch].
>>
>> As things stand right now, r191883 is broken because of the missing
>> file 'dumpfile.c', which the very next commit fixes. Anyone who got
>> broken revision r191883, please svn update. I am really very sorry
>> about that.
>>
>> I have a couple more minor patches which deal with renaming; I plan to
>> address those later.
>>
>
> It caused:
>
> FAIL: gcc.dg/tree-ssa/gen-vect-11.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-11.c scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c scan-tree-dump-times vect
> "vectorized 0 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c scan-tree-dump-times vect
> "vectorized 0 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-2.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-2.c scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-25.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-25.c scan-tree-dump-times vect
> "vectorized 2 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-26.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
> "Alignment of access forced using peeling" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-28.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
> "Alignment of access forced using peeling" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gcc.dg/tree-ssa/gen-vect-32.c (test for excess errors)
> FAIL: gcc.dg/tree-ssa/gen-vect-32.c scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gfortran.dg/vect/O3-pr36119.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/O3-pr39595.f (test for excess errors)
> FAIL: gfortran.dg/vect/Ofast-pr50414.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/cost-model-pr34445.f (test for excess errors)
> FAIL: gfortran.dg/vect/cost-model-pr34445a.f (test for excess errors)
> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 scan-tree-dump vect
> "vectorized 1 loops"
> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90 (test for
> excess errors)
> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 scan-tree-dump-times vect
> "vectorized 2 loops" 1
> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 (test for excess errors)
> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 scan-tree-dump-times vect
> "vectorized 0 loops" 1
> FAIL: gfortran.dg/vect/pr19049.f90  -O   scan-tree-dump-times vect
> "complicated access pattern" 1
> FAIL: gfortran.dg/vect/pr19049.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr32377.f90  -O   scan-tree-dump-times vect
> "vectorized 2 loops" 1
> FAIL: gfortran.dg/vect/pr32377.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr32380.f  -O   scan-tree-dump-times vect
> "vectorized 6 loops" 1
> FAIL: gfortran.dg/vect/pr32380.f  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr33301.f  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr50178.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr50412.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr51058-2.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr51058.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/pr51285.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/vect-1.f90  -O   scan-tree-dump-times vect
> "vectorized 3 loops" 1
> FAIL: gfortran.dg/vect/vect-1.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
> "Alignment of access forced using peeling" 3
> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
> "Vectorizing an unaligned access" 2
> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
> "vectorized 3 loops" 1
> FAIL: gfortran.dg/vect/vect-2.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
> "Alignment of access forced using peeling" 1
> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
> "Vectorizing an unaligned access" 1
> FAIL: gfortran.dg/vect/vect-3.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
> "Alignment of access forced using peeling" 1
> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
> "Vectorizing an unaligned access" 1
> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
> "accesses have the same alignment." 1
> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gfortran.dg/vect/vect-4.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
> "Alignment of access forced using peeling" 1
> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
> "Vectorizing an unaligned access" 1
> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
> "vectorized 1 loops" 1
> FAIL: gfortran.dg/vect/vect-5.f90  -O  (test for excess errors)
> FAIL: gfortran.dg/vect/vect-6.f  -O  (test for excess errors)
>
> on Linux/x86.
>
> --
> H.J.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 13:50                                                                                 ` Sharad Singhai
@ 2012-10-01 13:52                                                                                   ` H.J. Lu
  2012-10-01 13:56                                                                                     ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: H.J. Lu @ 2012-10-01 13:52 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Xinliang David Li, Richard Guenther, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 6:49 AM, Sharad Singhai <singhai@google.com> wrote:
> I am sorry, I didn't enable all the languages. Will fix the fortran
> test breakage shortly.

It is not just Fortran.  There are some failures in C testcases.

> Thanks,
> Sharad
> Sharad
>
>
> On Mon, Oct 1, 2012 at 4:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Sun, Sep 30, 2012 at 11:36 PM, Sharad Singhai <singhai@google.com> wrote:
>>> Resend to gcc-patches
>>>
>>> I have addressed the comments by fixing all the minor issues,
>>> bootstrapped and tested on x86_64. I did the recommended reshuffling
>>> by moving non-tree code from tree-dump.c into a new file dumpfile.c.
>>>
>>> I committed two successive revisions
>>> r191883 Main patch with the dump infrastructure changes. However, I
>>> accidentally left out a new file, dumpfile.c.
>>> r191884 Added dumpfile.c, and did the renaming of dump_* functions
>>> from gimple_pretty_print.[ch].
>>>
>>> As things stand right now, r191883 is broken because of the missing
>>> file 'dumpfile.c', which the very next commit fixes. Anyone who got
>>> broken revision r191883, please svn update. I am really very sorry
>>> about that.
>>>
>>> I have a couple more minor patches which deal with renaming; I plan to
>>> address those later.
>>>
>>
>> It caused:
>>
>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c scan-tree-dump-times vect
>> "vectorized 0 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c scan-tree-dump-times vect
>> "vectorized 0 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c scan-tree-dump-times vect
>> "vectorized 2 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>> "Alignment of access forced using peeling" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>> "Alignment of access forced using peeling" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c (test for excess errors)
>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gfortran.dg/vect/O3-pr36119.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/O3-pr39595.f (test for excess errors)
>> FAIL: gfortran.dg/vect/Ofast-pr50414.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/cost-model-pr34445.f (test for excess errors)
>> FAIL: gfortran.dg/vect/cost-model-pr34445a.f (test for excess errors)
>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 scan-tree-dump vect
>> "vectorized 1 loops"
>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90 (test for
>> excess errors)
>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 scan-tree-dump-times vect
>> "vectorized 2 loops" 1
>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 (test for excess errors)
>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 scan-tree-dump-times vect
>> "vectorized 0 loops" 1
>> FAIL: gfortran.dg/vect/pr19049.f90  -O   scan-tree-dump-times vect
>> "complicated access pattern" 1
>> FAIL: gfortran.dg/vect/pr19049.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr32377.f90  -O   scan-tree-dump-times vect
>> "vectorized 2 loops" 1
>> FAIL: gfortran.dg/vect/pr32377.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr32380.f  -O   scan-tree-dump-times vect
>> "vectorized 6 loops" 1
>> FAIL: gfortran.dg/vect/pr32380.f  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr33301.f  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr50178.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr50412.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr51058-2.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr51058.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/pr51285.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/vect-1.f90  -O   scan-tree-dump-times vect
>> "vectorized 3 loops" 1
>> FAIL: gfortran.dg/vect/vect-1.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>> "Alignment of access forced using peeling" 3
>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>> "Vectorizing an unaligned access" 2
>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>> "vectorized 3 loops" 1
>> FAIL: gfortran.dg/vect/vect-2.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>> "Alignment of access forced using peeling" 1
>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>> "Vectorizing an unaligned access" 1
>> FAIL: gfortran.dg/vect/vect-3.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>> "Alignment of access forced using peeling" 1
>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>> "Vectorizing an unaligned access" 1
>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>> "accesses have the same alignment." 1
>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gfortran.dg/vect/vect-4.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>> "Alignment of access forced using peeling" 1
>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>> "Vectorizing an unaligned access" 1
>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>> "vectorized 1 loops" 1
>> FAIL: gfortran.dg/vect/vect-5.f90  -O  (test for excess errors)
>> FAIL: gfortran.dg/vect/vect-6.f  -O  (test for excess errors)
>>
>> on Linux/x86.
>>
>> --
>> H.J.



-- 
H.J.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 13:52                                                                                   ` H.J. Lu
@ 2012-10-01 13:56                                                                                     ` Sharad Singhai
  2012-10-01 14:00                                                                                       ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-10-01 13:56 UTC (permalink / raw)
  To: H.J. Lu
  Cc: Xinliang David Li, Richard Guenther, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 6:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Oct 1, 2012 at 6:49 AM, Sharad Singhai <singhai@google.com> wrote:
>> I am sorry, I didn't enable all the languages. Will fix the fortran
>> test breakage shortly.
>
> It is not just Fortran.  There are some failures in C testcases.

I checked and those files looked like generator files for Fortran
tests and thus were not exercised in my configuration. I am really
sorry about that. I am fixing it.

UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11a.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11b.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11c.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-2.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-25.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-26.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-28.c
UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-32.c

Thanks,
Sharad

>
>> Thanks,
>> Sharad
>> Sharad
>>
>>
>> On Mon, Oct 1, 2012 at 4:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Sun, Sep 30, 2012 at 11:36 PM, Sharad Singhai <singhai@google.com> wrote:
>>>> Resend to gcc-patches
>>>>
>>>> I have addressed the comments by fixing all the minor issues,
>>>> bootstrapped and tested on x86_64. I did the recommended reshuffling
>>>> by moving non-tree code from tree-dump.c into a new file dumpfile.c.
>>>>
>>>> I committed two successive revisions
>>>> r191883 Main patch with the dump infrastructure changes. However, I
>>>> accidentally left out a new file, dumpfile.c.
>>>> r191884 Added dumpfile.c, and did the renaming of dump_* functions
>>>> from gimple_pretty_print.[ch].
>>>>
>>>> As things stand right now, r191883 is broken because of the missing
>>>> file 'dumpfile.c', which the very next commit fixes. Anyone who got
>>>> broken revision r191883, please svn update. I am really very sorry
>>>> about that.
>>>>
>>>> I have a couple more minor patches which deal with renaming; I plan to
>>>> address those later.
>>>>
>>>
>>> It caused:
>>>
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c scan-tree-dump-times vect
>>> "vectorized 0 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c scan-tree-dump-times vect
>>> "vectorized 0 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c scan-tree-dump-times vect
>>> "vectorized 2 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>>> "Alignment of access forced using peeling" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>>> "Alignment of access forced using peeling" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c (test for excess errors)
>>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gfortran.dg/vect/O3-pr36119.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/O3-pr39595.f (test for excess errors)
>>> FAIL: gfortran.dg/vect/Ofast-pr50414.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/cost-model-pr34445.f (test for excess errors)
>>> FAIL: gfortran.dg/vect/cost-model-pr34445a.f (test for excess errors)
>>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 scan-tree-dump vect
>>> "vectorized 1 loops"
>>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90 (test for
>>> excess errors)
>>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 scan-tree-dump-times vect
>>> "vectorized 2 loops" 1
>>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 (test for excess errors)
>>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 scan-tree-dump-times vect
>>> "vectorized 0 loops" 1
>>> FAIL: gfortran.dg/vect/pr19049.f90  -O   scan-tree-dump-times vect
>>> "complicated access pattern" 1
>>> FAIL: gfortran.dg/vect/pr19049.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr32377.f90  -O   scan-tree-dump-times vect
>>> "vectorized 2 loops" 1
>>> FAIL: gfortran.dg/vect/pr32377.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr32380.f  -O   scan-tree-dump-times vect
>>> "vectorized 6 loops" 1
>>> FAIL: gfortran.dg/vect/pr32380.f  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr33301.f  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr50178.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr50412.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr51058-2.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr51058.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/pr51285.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/vect-1.f90  -O   scan-tree-dump-times vect
>>> "vectorized 3 loops" 1
>>> FAIL: gfortran.dg/vect/vect-1.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>> "Alignment of access forced using peeling" 3
>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>> "Vectorizing an unaligned access" 2
>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>> "vectorized 3 loops" 1
>>> FAIL: gfortran.dg/vect/vect-2.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>>> "Alignment of access forced using peeling" 1
>>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>>> "Vectorizing an unaligned access" 1
>>> FAIL: gfortran.dg/vect/vect-3.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>> "Alignment of access forced using peeling" 1
>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>> "Vectorizing an unaligned access" 1
>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>> "accesses have the same alignment." 1
>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gfortran.dg/vect/vect-4.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>> "Alignment of access forced using peeling" 1
>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>> "Vectorizing an unaligned access" 1
>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>> "vectorized 1 loops" 1
>>> FAIL: gfortran.dg/vect/vect-5.f90  -O  (test for excess errors)
>>> FAIL: gfortran.dg/vect/vect-6.f  -O  (test for excess errors)
>>>
>>> on Linux/x86.
>>>
>>> --
>>> H.J.
>
>
>
> --
> H.J.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 13:56                                                                                     ` Sharad Singhai
@ 2012-10-01 14:00                                                                                       ` Richard Guenther
  2012-10-01 14:07                                                                                         ` Sharad Singhai
  0 siblings, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-10-01 14:00 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: H.J. Lu, Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 3:55 PM, Sharad Singhai <singhai@google.com> wrote:
> On Mon, Oct 1, 2012 at 6:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Oct 1, 2012 at 6:49 AM, Sharad Singhai <singhai@google.com> wrote:
>>> I am sorry, I didn't enable all the languages. Will fix the fortran
>>> test breakage shortly.
>>
>> It is not just Fortran.  There are some failures in C testcases.
>
> I checked and those files looked like generator files for Fortran
> tests and thus were not exercised in my configuration. I am really
> sorry about that. I am fixing it.

As I said, you should not enable/disable anything special but
configure with all default languages enabled (no --enable-languages)
and do toplevel make -k check, preferably also excercising
multilibs with RUNTESTFLAGS="--target_board=unix/\{,-m32\}"

Richard.

> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11a.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11b.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11c.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-2.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-25.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-26.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-28.c
> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-32.c
>
> Thanks,
> Sharad
>
>>
>>> Thanks,
>>> Sharad
>>> Sharad
>>>
>>>
>>> On Mon, Oct 1, 2012 at 4:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>> On Sun, Sep 30, 2012 at 11:36 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>> Resend to gcc-patches
>>>>>
>>>>> I have addressed the comments by fixing all the minor issues,
>>>>> bootstrapped and tested on x86_64. I did the recommended reshuffling
>>>>> by moving non-tree code from tree-dump.c into a new file dumpfile.c.
>>>>>
>>>>> I committed two successive revisions
>>>>> r191883 Main patch with the dump infrastructure changes. However, I
>>>>> accidentally left out a new file, dumpfile.c.
>>>>> r191884 Added dumpfile.c, and did the renaming of dump_* functions
>>>>> from gimple_pretty_print.[ch].
>>>>>
>>>>> As things stand right now, r191883 is broken because of the missing
>>>>> file 'dumpfile.c', which the very next commit fixes. Anyone who got
>>>>> broken revision r191883, please svn update. I am really very sorry
>>>>> about that.
>>>>>
>>>>> I have a couple more minor patches which deal with renaming; I plan to
>>>>> address those later.
>>>>>
>>>>
>>>> It caused:
>>>>
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c scan-tree-dump-times vect
>>>> "vectorized 0 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c scan-tree-dump-times vect
>>>> "vectorized 0 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c scan-tree-dump-times vect
>>>> "vectorized 2 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>>>> "Alignment of access forced using peeling" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>>>> "Alignment of access forced using peeling" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c (test for excess errors)
>>>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gfortran.dg/vect/O3-pr36119.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/O3-pr39595.f (test for excess errors)
>>>> FAIL: gfortran.dg/vect/Ofast-pr50414.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/cost-model-pr34445.f (test for excess errors)
>>>> FAIL: gfortran.dg/vect/cost-model-pr34445a.f (test for excess errors)
>>>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 scan-tree-dump vect
>>>> "vectorized 1 loops"
>>>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90 (test for
>>>> excess errors)
>>>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 scan-tree-dump-times vect
>>>> "vectorized 2 loops" 1
>>>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 (test for excess errors)
>>>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 scan-tree-dump-times vect
>>>> "vectorized 0 loops" 1
>>>> FAIL: gfortran.dg/vect/pr19049.f90  -O   scan-tree-dump-times vect
>>>> "complicated access pattern" 1
>>>> FAIL: gfortran.dg/vect/pr19049.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr32377.f90  -O   scan-tree-dump-times vect
>>>> "vectorized 2 loops" 1
>>>> FAIL: gfortran.dg/vect/pr32377.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr32380.f  -O   scan-tree-dump-times vect
>>>> "vectorized 6 loops" 1
>>>> FAIL: gfortran.dg/vect/pr32380.f  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr33301.f  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr50178.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr50412.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr51058-2.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr51058.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/pr51285.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/vect-1.f90  -O   scan-tree-dump-times vect
>>>> "vectorized 3 loops" 1
>>>> FAIL: gfortran.dg/vect/vect-1.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>>> "Alignment of access forced using peeling" 3
>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>>> "Vectorizing an unaligned access" 2
>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>>> "vectorized 3 loops" 1
>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>>>> "Alignment of access forced using peeling" 1
>>>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>>>> "Vectorizing an unaligned access" 1
>>>> FAIL: gfortran.dg/vect/vect-3.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>> "Alignment of access forced using peeling" 1
>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>> "Vectorizing an unaligned access" 1
>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>> "accesses have the same alignment." 1
>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>>> "Alignment of access forced using peeling" 1
>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>>> "Vectorizing an unaligned access" 1
>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>>> "vectorized 1 loops" 1
>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O  (test for excess errors)
>>>> FAIL: gfortran.dg/vect/vect-6.f  -O  (test for excess errors)
>>>>
>>>> on Linux/x86.
>>>>
>>>> --
>>>> H.J.
>>
>>
>>
>> --
>> H.J.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 14:00                                                                                       ` Richard Guenther
@ 2012-10-01 14:07                                                                                         ` Sharad Singhai
  2012-10-01 18:03                                                                                           ` Michael Meissner
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-10-01 14:07 UTC (permalink / raw)
  To: Richard Guenther
  Cc: H.J. Lu, Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

Okay, I am retesting without any special configs and with multilibs as
you suggested.

Thanks,
Sharad

On Mon, Oct 1, 2012 at 7:00 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Mon, Oct 1, 2012 at 3:55 PM, Sharad Singhai <singhai@google.com> wrote:
>> On Mon, Oct 1, 2012 at 6:52 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>> On Mon, Oct 1, 2012 at 6:49 AM, Sharad Singhai <singhai@google.com> wrote:
>>>> I am sorry, I didn't enable all the languages. Will fix the fortran
>>>> test breakage shortly.
>>>
>>> It is not just Fortran.  There are some failures in C testcases.
>>
>> I checked and those files looked like generator files for Fortran
>> tests and thus were not exercised in my configuration. I am really
>> sorry about that. I am fixing it.
>
> As I said, you should not enable/disable anything special but
> configure with all default languages enabled (no --enable-languages)
> and do toplevel make -k check, preferably also excercising
> multilibs with RUNTESTFLAGS="--target_board=unix/\{,-m32\}"
>
> Richard.
>
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11a.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11b.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-11c.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-2.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-25.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-26.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-28.c
>> UNSUPPORTED: gcc.dg/tree-ssa/gen-vect-32.c
>>
>> Thanks,
>> Sharad
>>
>>>
>>>> Thanks,
>>>> Sharad
>>>> Sharad
>>>>
>>>>
>>>> On Mon, Oct 1, 2012 at 4:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>>> On Sun, Sep 30, 2012 at 11:36 PM, Sharad Singhai <singhai@google.com> wrote:
>>>>>> Resend to gcc-patches
>>>>>>
>>>>>> I have addressed the comments by fixing all the minor issues,
>>>>>> bootstrapped and tested on x86_64. I did the recommended reshuffling
>>>>>> by moving non-tree code from tree-dump.c into a new file dumpfile.c.
>>>>>>
>>>>>> I committed two successive revisions
>>>>>> r191883 Main patch with the dump infrastructure changes. However, I
>>>>>> accidentally left out a new file, dumpfile.c.
>>>>>> r191884 Added dumpfile.c, and did the renaming of dump_* functions
>>>>>> from gimple_pretty_print.[ch].
>>>>>>
>>>>>> As things stand right now, r191883 is broken because of the missing
>>>>>> file 'dumpfile.c', which the very next commit fixes. Anyone who got
>>>>>> broken revision r191883, please svn update. I am really very sorry
>>>>>> about that.
>>>>>>
>>>>>> I have a couple more minor patches which deal with renaming; I plan to
>>>>>> address those later.
>>>>>>
>>>>>
>>>>> It caused:
>>>>>
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11.c scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11a.c scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11b.c scan-tree-dump-times vect
>>>>> "vectorized 0 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-11c.c scan-tree-dump-times vect
>>>>> "vectorized 0 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-2.c scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-25.c scan-tree-dump-times vect
>>>>> "vectorized 2 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>>>>> "Alignment of access forced using peeling" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-26.c scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>>>>> "Alignment of access forced using peeling" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-28.c scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c (test for excess errors)
>>>>> FAIL: gcc.dg/tree-ssa/gen-vect-32.c scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gfortran.dg/vect/O3-pr36119.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/O3-pr39595.f (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/Ofast-pr50414.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/cost-model-pr34445.f (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/cost-model-pr34445a.f (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/fast-math-pr38968.f90 scan-tree-dump vect
>>>>> "vectorized 1 loops"
>>>>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/fast-math-real8-pr40801.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/fast-math-vect-8.f90 scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gfortran.dg/vect/no-fre-no-copy-prop-O3-pr51704.f90 (test for
>>>>> excess errors)
>>>>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/no-vfa-pr32377.f90 scan-tree-dump-times vect
>>>>> "vectorized 2 loops" 1
>>>>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/no-vfa-pr32457.f90 scan-tree-dump-times vect
>>>>> "vectorized 0 loops" 1
>>>>> FAIL: gfortran.dg/vect/pr19049.f90  -O   scan-tree-dump-times vect
>>>>> "complicated access pattern" 1
>>>>> FAIL: gfortran.dg/vect/pr19049.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr32377.f90  -O   scan-tree-dump-times vect
>>>>> "vectorized 2 loops" 1
>>>>> FAIL: gfortran.dg/vect/pr32377.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr32380.f  -O   scan-tree-dump-times vect
>>>>> "vectorized 6 loops" 1
>>>>> FAIL: gfortran.dg/vect/pr32380.f  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr33301.f  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr50178.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr50412.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr51058-2.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr51058.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/pr51285.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/vect-1.f90  -O   scan-tree-dump-times vect
>>>>> "vectorized 3 loops" 1
>>>>> FAIL: gfortran.dg/vect/vect-1.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>>>> "Alignment of access forced using peeling" 3
>>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>>>> "Vectorizing an unaligned access" 2
>>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O   scan-tree-dump-times vect
>>>>> "vectorized 3 loops" 1
>>>>> FAIL: gfortran.dg/vect/vect-2.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>>>>> "Alignment of access forced using peeling" 1
>>>>> FAIL: gfortran.dg/vect/vect-3.f90  -O   scan-tree-dump-times vect
>>>>> "Vectorizing an unaligned access" 1
>>>>> FAIL: gfortran.dg/vect/vect-3.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>>> "Alignment of access forced using peeling" 1
>>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>>> "Vectorizing an unaligned access" 1
>>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>>> "accesses have the same alignment." 1
>>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O   scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gfortran.dg/vect/vect-4.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>>>> "Alignment of access forced using peeling" 1
>>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>>>> "Vectorizing an unaligned access" 1
>>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O   scan-tree-dump-times vect
>>>>> "vectorized 1 loops" 1
>>>>> FAIL: gfortran.dg/vect/vect-5.f90  -O  (test for excess errors)
>>>>> FAIL: gfortran.dg/vect/vect-6.f  -O  (test for excess errors)
>>>>>
>>>>> on Linux/x86.
>>>>>
>>>>> --
>>>>> H.J.
>>>
>>>
>>>
>>> --
>>> H.J.

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 14:07                                                                                         ` Sharad Singhai
@ 2012-10-01 18:03                                                                                           ` Michael Meissner
  2012-10-01 18:32                                                                                             ` Michael Meissner
  0 siblings, 1 reply; 71+ messages in thread
From: Michael Meissner @ 2012-10-01 18:03 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Richard Guenther, H.J. Lu, Xinliang David Li, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

Your change on September 30th, breaks the powerpc port because the
REPORT_DETAILS value in the enumeration is no longer there, and the
rs6000_density_test function was using that.  Please in the future, when you
are making global changes, grep for uses of enum values in all of the machine
dependent directories so we can avoid breakage like this.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com	fax +1 (978) 399-6899

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 18:03                                                                                           ` Michael Meissner
@ 2012-10-01 18:32                                                                                             ` Michael Meissner
  2012-10-01 18:39                                                                                               ` Gabriel Dos Reis
  2012-10-01 21:37                                                                                               ` [PATCH] Fix powerpc breakage, was: " Michael Meissner
  0 siblings, 2 replies; 71+ messages in thread
From: Michael Meissner @ 2012-10-01 18:32 UTC (permalink / raw)
  To: Michael Meissner, Sharad Singhai, Richard Guenther, H.J. Lu,
	Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Mon, Oct 01, 2012 at 02:02:26PM -0400, Michael Meissner wrote:
> Your change on September 30th, breaks the powerpc port because the
> REPORT_DETAILS value in the enumeration is no longer there, and the
> rs6000_density_test function was using that.  Please in the future, when you
> are making global changes, grep for uses of enum values in all of the machine
> dependent directories so we can avoid breakage like this.

Also, in looking at the changes, given we are already up to 28 TDF_ flags, I
would recommend immediately adding a new type that is the TDF flagword type.
Thus it will be a lot simpler when we add 4 more TDF flags and have to change
the type from int to HOST_WIDE_INT.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com	fax +1 (978) 399-6899

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 18:32                                                                                             ` Michael Meissner
@ 2012-10-01 18:39                                                                                               ` Gabriel Dos Reis
  2012-10-02  5:42                                                                                                 ` Sharad Singhai
  2012-10-02  9:31                                                                                                 ` Richard Guenther
  2012-10-01 21:37                                                                                               ` [PATCH] Fix powerpc breakage, was: " Michael Meissner
  1 sibling, 2 replies; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-10-01 18:39 UTC (permalink / raw)
  To: Michael Meissner, Sharad Singhai, Richard Guenther, H.J. Lu,
	Xinliang David Li, Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 1:27 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> On Mon, Oct 01, 2012 at 02:02:26PM -0400, Michael Meissner wrote:
>> Your change on September 30th, breaks the powerpc port because the
>> REPORT_DETAILS value in the enumeration is no longer there, and the
>> rs6000_density_test function was using that.  Please in the future, when you
>> are making global changes, grep for uses of enum values in all of the machine
>> dependent directories so we can avoid breakage like this.
>
> Also, in looking at the changes, given we are already up to 28 TDF_ flags, I
> would recommend immediately adding a new type that is the TDF flagword type.
> Thus it will be a lot simpler when we add 4 more TDF flags and have to change
> the type from int to HOST_WIDE_INT.

Agreed that we need an abstraction here.
-- Gaby

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

* [PATCH] Fix powerpc breakage, was: Add option for dumping to stderr (issue6190057)
  2012-10-01 18:32                                                                                             ` Michael Meissner
  2012-10-01 18:39                                                                                               ` Gabriel Dos Reis
@ 2012-10-01 21:37                                                                                               ` Michael Meissner
  2012-10-01 21:42                                                                                                 ` Gabriel Dos Reis
  2012-10-01 22:45                                                                                                 ` Xinliang David Li
  1 sibling, 2 replies; 71+ messages in thread
From: Michael Meissner @ 2012-10-01 21:37 UTC (permalink / raw)
  To: David Edelsohn, Michael Meissner, Sharad Singhai,
	Richard Guenther, H.J. Lu, Xinliang David Li, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

I tracked down some of the other code that previously used REPORT_DETAILS, and
MSG_NOTE is the new way to do the same thing.  This bootstraps and no
unexpected errors occur during make check.  Is it ok to install?

2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>

	* config/rs6000/rs6000.c (toplevel): Include dumpfile.h.
	(rs6000_density_test): Rework to accomidate 09-30 change by Sharad
	Singhai.

	* config/rs6000/t-rs6000 (rs6000.o): Add dumpfile.h dependency.

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 191932)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -58,6 +58,7 @@
 #include "tm-constrs.h"
 #include "opts.h"
 #include "tree-vectorizer.h"
+#include "dumpfile.h"
 #if TARGET_XCOFF
 #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
 #endif
@@ -3518,11 +3519,11 @@ rs6000_density_test (rs6000_cost_data *d
       && vec_cost + not_vec_cost > DENSITY_SIZE_THRESHOLD)
     {
       data->cost[vect_body] = vec_cost * (100 + DENSITY_PENALTY) / 100;
-      if (vect_print_dump_info (REPORT_DETAILS))
-	fprintf (vect_dump,
-		 "density %d%%, cost %d exceeds threshold, penalizing "
-		 "loop body cost by %d%%", density_pct, 
-		 vec_cost + not_vec_cost, DENSITY_PENALTY);
+      if (dump_kind_p (MSG_NOTE))
+	dump_printf_loc (MSG_NOTE, vect_location,
+			 "density %d%%, cost %d exceeds threshold, penalizing "
+			 "loop body cost by %d%%", density_pct,
+			 vec_cost + not_vec_cost, DENSITY_PENALTY);
     }
 }
 
Index: gcc/config/rs6000/t-rs6000
===================================================================
--- gcc/config/rs6000/t-rs6000	(revision 191932)
+++ gcc/config/rs6000/t-rs6000	(working copy)
@@ -26,7 +26,7 @@ rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
   $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
   output.h dbxout.h $(BASIC_BLOCK_H) toplev.h $(GGC_H) $(HASHTAB_H) \
   $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
-  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H)
+  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H) dumpfile.h
 
 rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
     $(srcdir)/config/rs6000/rs6000-protos.h \

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meissner@linux.vnet.ibm.com	fax +1 (978) 399-6899

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

* Re: [PATCH] Fix powerpc breakage, was: Add option for dumping to stderr (issue6190057)
  2012-10-01 21:37                                                                                               ` [PATCH] Fix powerpc breakage, was: " Michael Meissner
@ 2012-10-01 21:42                                                                                                 ` Gabriel Dos Reis
  2012-10-01 22:45                                                                                                 ` Xinliang David Li
  1 sibling, 0 replies; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-10-01 21:42 UTC (permalink / raw)
  To: Michael Meissner, David Edelsohn, Sharad Singhai,
	Richard Guenther, H.J. Lu, Xinliang David Li, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 4:37 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> I tracked down some of the other code that previously used REPORT_DETAILS, and
> MSG_NOTE is the new way to do the same thing.  This bootstraps and no
> unexpected errors occur during make check.  Is it ok to install?

yes -- qualifies as "obvious".  Thanks!


>
> 2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         * config/rs6000/rs6000.c (toplevel): Include dumpfile.h.
>         (rs6000_density_test): Rework to accomidate 09-30 change by Sharad
>         Singhai.
>
>         * config/rs6000/t-rs6000 (rs6000.o): Add dumpfile.h dependency.
>
> Index: gcc/config/rs6000/rs6000.c
> ===================================================================
> --- gcc/config/rs6000/rs6000.c  (revision 191932)
> +++ gcc/config/rs6000/rs6000.c  (working copy)
> @@ -58,6 +58,7 @@
>  #include "tm-constrs.h"
>  #include "opts.h"
>  #include "tree-vectorizer.h"
> +#include "dumpfile.h"
>  #if TARGET_XCOFF
>  #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
>  #endif
> @@ -3518,11 +3519,11 @@ rs6000_density_test (rs6000_cost_data *d
>        && vec_cost + not_vec_cost > DENSITY_SIZE_THRESHOLD)
>      {
>        data->cost[vect_body] = vec_cost * (100 + DENSITY_PENALTY) / 100;
> -      if (vect_print_dump_info (REPORT_DETAILS))
> -       fprintf (vect_dump,
> -                "density %d%%, cost %d exceeds threshold, penalizing "
> -                "loop body cost by %d%%", density_pct,
> -                vec_cost + not_vec_cost, DENSITY_PENALTY);
> +      if (dump_kind_p (MSG_NOTE))
> +       dump_printf_loc (MSG_NOTE, vect_location,
> +                        "density %d%%, cost %d exceeds threshold, penalizing "
> +                        "loop body cost by %d%%", density_pct,
> +                        vec_cost + not_vec_cost, DENSITY_PENALTY);
>      }
>  }
>
> Index: gcc/config/rs6000/t-rs6000
> ===================================================================
> --- gcc/config/rs6000/t-rs6000  (revision 191932)
> +++ gcc/config/rs6000/t-rs6000  (working copy)
> @@ -26,7 +26,7 @@ rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
>    $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
>    output.h dbxout.h $(BASIC_BLOCK_H) toplev.h $(GGC_H) $(HASHTAB_H) \
>    $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
> -  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H)
> +  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H) dumpfile.h
>
>  rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
>      $(srcdir)/config/rs6000/rs6000-protos.h \
>
> --
> Michael Meissner, IBM
> 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
> meissner@linux.vnet.ibm.com     fax +1 (978) 399-6899
>

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

* Re: [PATCH] Fix powerpc breakage, was: Add option for dumping to stderr (issue6190057)
  2012-10-01 21:37                                                                                               ` [PATCH] Fix powerpc breakage, was: " Michael Meissner
  2012-10-01 21:42                                                                                                 ` Gabriel Dos Reis
@ 2012-10-01 22:45                                                                                                 ` Xinliang David Li
  2012-10-01 23:06                                                                                                   ` Sharad Singhai
  1 sibling, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-10-01 22:45 UTC (permalink / raw)
  To: Michael Meissner, David Edelsohn, Sharad Singhai,
	Richard Guenther, H.J. Lu, Xinliang David Li, Gabriel Dos Reis,
	gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 2:37 PM, Michael Meissner
<meissner@linux.vnet.ibm.com> wrote:
> I tracked down some of the other code that previously used REPORT_DETAILS, and
> MSG_NOTE is the new way to do the same thing.  This bootstraps and no
> unexpected errors occur during make check.  Is it ok to install?
>
> 2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
>
>         * config/rs6000/rs6000.c (toplevel): Include dumpfile.h.
>         (rs6000_density_test): Rework to accomidate 09-30 change by Sharad
>         Singhai.
>
>         * config/rs6000/t-rs6000 (rs6000.o): Add dumpfile.h dependency.
>
> Index: gcc/config/rs6000/rs6000.c
> ===================================================================
> --- gcc/config/rs6000/rs6000.c  (revision 191932)
> +++ gcc/config/rs6000/rs6000.c  (working copy)
> @@ -58,6 +58,7 @@
>  #include "tm-constrs.h"
>  #include "opts.h"
>  #include "tree-vectorizer.h"
> +#include "dumpfile.h"
>  #if TARGET_XCOFF
>  #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
>  #endif
> @@ -3518,11 +3519,11 @@ rs6000_density_test (rs6000_cost_data *d
>        && vec_cost + not_vec_cost > DENSITY_SIZE_THRESHOLD)
>      {
>        data->cost[vect_body] = vec_cost * (100 + DENSITY_PENALTY) / 100;
> -      if (vect_print_dump_info (REPORT_DETAILS))
> -       fprintf (vect_dump,
> -                "density %d%%, cost %d exceeds threshold, penalizing "
> -                "loop body cost by %d%%", density_pct,
> -                vec_cost + not_vec_cost, DENSITY_PENALTY);
> +      if (dump_kind_p (MSG_NOTE))

Is this check needed? Seems redundant.

David


> +       dump_printf_loc (MSG_NOTE, vect_location,
> +                        "density %d%%, cost %d exceeds threshold, penalizing "
> +                        "loop body cost by %d%%", density_pct,
> +                        vec_cost + not_vec_cost, DENSITY_PENALTY);
>      }
>  }
>
> Index: gcc/config/rs6000/t-rs6000
> ===================================================================
> --- gcc/config/rs6000/t-rs6000  (revision 191932)
> +++ gcc/config/rs6000/t-rs6000  (working copy)
> @@ -26,7 +26,7 @@ rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
>    $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
>    output.h dbxout.h $(BASIC_BLOCK_H) toplev.h $(GGC_H) $(HASHTAB_H) \
>    $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
> -  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H)
> +  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H) dumpfile.h
>
>  rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
>      $(srcdir)/config/rs6000/rs6000-protos.h \
>
> --
> Michael Meissner, IBM
> 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
> meissner@linux.vnet.ibm.com     fax +1 (978) 399-6899
>

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

* Re: [PATCH] Fix powerpc breakage, was: Add option for dumping to stderr (issue6190057)
  2012-10-01 22:45                                                                                                 ` Xinliang David Li
@ 2012-10-01 23:06                                                                                                   ` Sharad Singhai
  2012-10-01 23:11                                                                                                     ` Xinliang David Li
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-10-01 23:06 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Michael Meissner, David Edelsohn, Richard Guenther, H.J. Lu,
	Gabriel Dos Reis, gcc-patches, Andrew Pinski

Thanks for tracking down and fixing the powerpc port.

The "dump_kind_p ()" check is redundant but canonical form here. I
think blocks of dump code guarded by "if dump_kind_p (...)" might be
easier to read/maintain.

Sharad
Sharad


On Mon, Oct 1, 2012 at 3:45 PM, Xinliang David Li <davidxl@google.com> wrote:
> On Mon, Oct 1, 2012 at 2:37 PM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
>> I tracked down some of the other code that previously used REPORT_DETAILS, and
>> MSG_NOTE is the new way to do the same thing.  This bootstraps and no
>> unexpected errors occur during make check.  Is it ok to install?
>>
>> 2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
>>
>>         * config/rs6000/rs6000.c (toplevel): Include dumpfile.h.
>>         (rs6000_density_test): Rework to accomidate 09-30 change by Sharad
>>         Singhai.
>>
>>         * config/rs6000/t-rs6000 (rs6000.o): Add dumpfile.h dependency.
>>
>> Index: gcc/config/rs6000/rs6000.c
>> ===================================================================
>> --- gcc/config/rs6000/rs6000.c  (revision 191932)
>> +++ gcc/config/rs6000/rs6000.c  (working copy)
>> @@ -58,6 +58,7 @@
>>  #include "tm-constrs.h"
>>  #include "opts.h"
>>  #include "tree-vectorizer.h"
>> +#include "dumpfile.h"
>>  #if TARGET_XCOFF
>>  #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
>>  #endif
>> @@ -3518,11 +3519,11 @@ rs6000_density_test (rs6000_cost_data *d
>>        && vec_cost + not_vec_cost > DENSITY_SIZE_THRESHOLD)
>>      {
>>        data->cost[vect_body] = vec_cost * (100 + DENSITY_PENALTY) / 100;
>> -      if (vect_print_dump_info (REPORT_DETAILS))
>> -       fprintf (vect_dump,
>> -                "density %d%%, cost %d exceeds threshold, penalizing "
>> -                "loop body cost by %d%%", density_pct,
>> -                vec_cost + not_vec_cost, DENSITY_PENALTY);
>> +      if (dump_kind_p (MSG_NOTE))
>
> Is this check needed? Seems redundant.
>
> David
>
>
>> +       dump_printf_loc (MSG_NOTE, vect_location,
>> +                        "density %d%%, cost %d exceeds threshold, penalizing "
>> +                        "loop body cost by %d%%", density_pct,
>> +                        vec_cost + not_vec_cost, DENSITY_PENALTY);
>>      }
>>  }
>>
>> Index: gcc/config/rs6000/t-rs6000
>> ===================================================================
>> --- gcc/config/rs6000/t-rs6000  (revision 191932)
>> +++ gcc/config/rs6000/t-rs6000  (working copy)
>> @@ -26,7 +26,7 @@ rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
>>    $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
>>    output.h dbxout.h $(BASIC_BLOCK_H) toplev.h $(GGC_H) $(HASHTAB_H) \
>>    $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
>> -  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H)
>> +  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H) dumpfile.h
>>
>>  rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
>>      $(srcdir)/config/rs6000/rs6000-protos.h \
>>
>> --
>> Michael Meissner, IBM
>> 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
>> meissner@linux.vnet.ibm.com     fax +1 (978) 399-6899
>>

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

* Re: [PATCH] Fix powerpc breakage, was: Add option for dumping to stderr (issue6190057)
  2012-10-01 23:06                                                                                                   ` Sharad Singhai
@ 2012-10-01 23:11                                                                                                     ` Xinliang David Li
  2012-10-02  9:25                                                                                                       ` Richard Guenther
  0 siblings, 1 reply; 71+ messages in thread
From: Xinliang David Li @ 2012-10-01 23:11 UTC (permalink / raw)
  To: Sharad Singhai
  Cc: Michael Meissner, David Edelsohn, Richard Guenther, H.J. Lu,
	Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 4:05 PM, Sharad Singhai <singhai@google.com> wrote:
> Thanks for tracking down and fixing the powerpc port.
>
> The "dump_kind_p ()" check is redundant but canonical form here. I
> think blocks of dump code guarded by "if dump_kind_p (...)" might be
> easier to read/maintain.
>

I find it confusing to be honest. The redundant check serves no purpose.

David

> Sharad
> Sharad
>
>
> On Mon, Oct 1, 2012 at 3:45 PM, Xinliang David Li <davidxl@google.com> wrote:
>> On Mon, Oct 1, 2012 at 2:37 PM, Michael Meissner
>> <meissner@linux.vnet.ibm.com> wrote:
>>> I tracked down some of the other code that previously used REPORT_DETAILS, and
>>> MSG_NOTE is the new way to do the same thing.  This bootstraps and no
>>> unexpected errors occur during make check.  Is it ok to install?
>>>
>>> 2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
>>>
>>>         * config/rs6000/rs6000.c (toplevel): Include dumpfile.h.
>>>         (rs6000_density_test): Rework to accomidate 09-30 change by Sharad
>>>         Singhai.
>>>
>>>         * config/rs6000/t-rs6000 (rs6000.o): Add dumpfile.h dependency.
>>>
>>> Index: gcc/config/rs6000/rs6000.c
>>> ===================================================================
>>> --- gcc/config/rs6000/rs6000.c  (revision 191932)
>>> +++ gcc/config/rs6000/rs6000.c  (working copy)
>>> @@ -58,6 +58,7 @@
>>>  #include "tm-constrs.h"
>>>  #include "opts.h"
>>>  #include "tree-vectorizer.h"
>>> +#include "dumpfile.h"
>>>  #if TARGET_XCOFF
>>>  #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
>>>  #endif
>>> @@ -3518,11 +3519,11 @@ rs6000_density_test (rs6000_cost_data *d
>>>        && vec_cost + not_vec_cost > DENSITY_SIZE_THRESHOLD)
>>>      {
>>>        data->cost[vect_body] = vec_cost * (100 + DENSITY_PENALTY) / 100;
>>> -      if (vect_print_dump_info (REPORT_DETAILS))
>>> -       fprintf (vect_dump,
>>> -                "density %d%%, cost %d exceeds threshold, penalizing "
>>> -                "loop body cost by %d%%", density_pct,
>>> -                vec_cost + not_vec_cost, DENSITY_PENALTY);
>>> +      if (dump_kind_p (MSG_NOTE))
>>
>> Is this check needed? Seems redundant.
>>
>> David
>>
>>
>>> +       dump_printf_loc (MSG_NOTE, vect_location,
>>> +                        "density %d%%, cost %d exceeds threshold, penalizing "
>>> +                        "loop body cost by %d%%", density_pct,
>>> +                        vec_cost + not_vec_cost, DENSITY_PENALTY);
>>>      }
>>>  }
>>>
>>> Index: gcc/config/rs6000/t-rs6000
>>> ===================================================================
>>> --- gcc/config/rs6000/t-rs6000  (revision 191932)
>>> +++ gcc/config/rs6000/t-rs6000  (working copy)
>>> @@ -26,7 +26,7 @@ rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
>>>    $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
>>>    output.h dbxout.h $(BASIC_BLOCK_H) toplev.h $(GGC_H) $(HASHTAB_H) \
>>>    $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
>>> -  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H)
>>> +  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H) dumpfile.h
>>>
>>>  rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
>>>      $(srcdir)/config/rs6000/rs6000-protos.h \
>>>
>>> --
>>> Michael Meissner, IBM
>>> 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
>>> meissner@linux.vnet.ibm.com     fax +1 (978) 399-6899
>>>

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 18:39                                                                                               ` Gabriel Dos Reis
@ 2012-10-02  5:42                                                                                                 ` Sharad Singhai
  2012-10-02  9:31                                                                                                 ` Richard Guenther
  1 sibling, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-10-02  5:42 UTC (permalink / raw)
  To: Gabriel Dos Reis
  Cc: Michael Meissner, Richard Guenther, H.J. Lu, Xinliang David Li,
	gcc-patches, Andrew Pinski

I have mailed a patch to fix test failures caused by r191884. Waiting
for an okay.

http://gcc.gnu.org/ml/gcc-patches/2012-10/msg00109.html

Thanks,
Sharad
Sharad


On Mon, Oct 1, 2012 at 11:39 AM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Mon, Oct 1, 2012 at 1:27 PM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
>> On Mon, Oct 01, 2012 at 02:02:26PM -0400, Michael Meissner wrote:
>>> Your change on September 30th, breaks the powerpc port because the
>>> REPORT_DETAILS value in the enumeration is no longer there, and the
>>> rs6000_density_test function was using that.  Please in the future, when you
>>> are making global changes, grep for uses of enum values in all of the machine
>>> dependent directories so we can avoid breakage like this.
>>
>> Also, in looking at the changes, given we are already up to 28 TDF_ flags, I
>> would recommend immediately adding a new type that is the TDF flagword type.
>> Thus it will be a lot simpler when we add 4 more TDF flags and have to change
>> the type from int to HOST_WIDE_INT.
>
> Agreed that we need an abstraction here.
> -- Gaby

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

* Re: [PATCH] Fix powerpc breakage, was: Add option for dumping to stderr (issue6190057)
  2012-10-01 23:11                                                                                                     ` Xinliang David Li
@ 2012-10-02  9:25                                                                                                       ` Richard Guenther
  0 siblings, 0 replies; 71+ messages in thread
From: Richard Guenther @ 2012-10-02  9:25 UTC (permalink / raw)
  To: Xinliang David Li
  Cc: Sharad Singhai, Michael Meissner, David Edelsohn, H.J. Lu,
	Gabriel Dos Reis, gcc-patches, Andrew Pinski

On Tue, Oct 2, 2012 at 1:11 AM, Xinliang David Li <davidxl@google.com> wrote:
> On Mon, Oct 1, 2012 at 4:05 PM, Sharad Singhai <singhai@google.com> wrote:
>> Thanks for tracking down and fixing the powerpc port.
>>
>> The "dump_kind_p ()" check is redundant but canonical form here. I
>> think blocks of dump code guarded by "if dump_kind_p (...)" might be
>> easier to read/maintain.
>>
>
> I find it confusing to be honest. The redundant check serves no purpose.

The check should be inlined and avoid the call to the diagnostic routine,
thus speed up compile-time.  We should use this pattern, especially
if it guards multiple calls.

Richard.

> David
>
>> Sharad
>> Sharad
>>
>>
>> On Mon, Oct 1, 2012 at 3:45 PM, Xinliang David Li <davidxl@google.com> wrote:
>>> On Mon, Oct 1, 2012 at 2:37 PM, Michael Meissner
>>> <meissner@linux.vnet.ibm.com> wrote:
>>>> I tracked down some of the other code that previously used REPORT_DETAILS, and
>>>> MSG_NOTE is the new way to do the same thing.  This bootstraps and no
>>>> unexpected errors occur during make check.  Is it ok to install?
>>>>
>>>> 2012-10-01  Michael Meissner  <meissner@linux.vnet.ibm.com>
>>>>
>>>>         * config/rs6000/rs6000.c (toplevel): Include dumpfile.h.
>>>>         (rs6000_density_test): Rework to accomidate 09-30 change by Sharad
>>>>         Singhai.
>>>>
>>>>         * config/rs6000/t-rs6000 (rs6000.o): Add dumpfile.h dependency.
>>>>
>>>> Index: gcc/config/rs6000/rs6000.c
>>>> ===================================================================
>>>> --- gcc/config/rs6000/rs6000.c  (revision 191932)
>>>> +++ gcc/config/rs6000/rs6000.c  (working copy)
>>>> @@ -58,6 +58,7 @@
>>>>  #include "tm-constrs.h"
>>>>  #include "opts.h"
>>>>  #include "tree-vectorizer.h"
>>>> +#include "dumpfile.h"
>>>>  #if TARGET_XCOFF
>>>>  #include "xcoffout.h"  /* get declarations of xcoff_*_section_name */
>>>>  #endif
>>>> @@ -3518,11 +3519,11 @@ rs6000_density_test (rs6000_cost_data *d
>>>>        && vec_cost + not_vec_cost > DENSITY_SIZE_THRESHOLD)
>>>>      {
>>>>        data->cost[vect_body] = vec_cost * (100 + DENSITY_PENALTY) / 100;
>>>> -      if (vect_print_dump_info (REPORT_DETAILS))
>>>> -       fprintf (vect_dump,
>>>> -                "density %d%%, cost %d exceeds threshold, penalizing "
>>>> -                "loop body cost by %d%%", density_pct,
>>>> -                vec_cost + not_vec_cost, DENSITY_PENALTY);
>>>> +      if (dump_kind_p (MSG_NOTE))
>>>
>>> Is this check needed? Seems redundant.
>>>
>>> David
>>>
>>>
>>>> +       dump_printf_loc (MSG_NOTE, vect_location,
>>>> +                        "density %d%%, cost %d exceeds threshold, penalizing "
>>>> +                        "loop body cost by %d%%", density_pct,
>>>> +                        vec_cost + not_vec_cost, DENSITY_PENALTY);
>>>>      }
>>>>  }
>>>>
>>>> Index: gcc/config/rs6000/t-rs6000
>>>> ===================================================================
>>>> --- gcc/config/rs6000/t-rs6000  (revision 191932)
>>>> +++ gcc/config/rs6000/t-rs6000  (working copy)
>>>> @@ -26,7 +26,7 @@ rs6000.o: $(CONFIG_H) $(SYSTEM_H) corety
>>>>    $(OBSTACK_H) $(TREE_H) $(EXPR_H) $(OPTABS_H) except.h function.h \
>>>>    output.h dbxout.h $(BASIC_BLOCK_H) toplev.h $(GGC_H) $(HASHTAB_H) \
>>>>    $(TM_P_H) $(TARGET_H) $(TARGET_DEF_H) langhooks.h reload.h gt-rs6000.h \
>>>> -  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H)
>>>> +  cfgloop.h $(OPTS_H) $(COMMON_TARGET_H) dumpfile.h
>>>>
>>>>  rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c \
>>>>      $(srcdir)/config/rs6000/rs6000-protos.h \
>>>>
>>>> --
>>>> Michael Meissner, IBM
>>>> 5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
>>>> meissner@linux.vnet.ibm.com     fax +1 (978) 399-6899
>>>>

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-01 18:39                                                                                               ` Gabriel Dos Reis
  2012-10-02  5:42                                                                                                 ` Sharad Singhai
@ 2012-10-02  9:31                                                                                                 ` Richard Guenther
  2012-10-02  9:36                                                                                                   ` Gabriel Dos Reis
  1 sibling, 1 reply; 71+ messages in thread
From: Richard Guenther @ 2012-10-02  9:31 UTC (permalink / raw)
  To: Gabriel Dos Reis
  Cc: Michael Meissner, Sharad Singhai, H.J. Lu, Xinliang David Li,
	gcc-patches, Andrew Pinski

On Mon, Oct 1, 2012 at 8:39 PM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Mon, Oct 1, 2012 at 1:27 PM, Michael Meissner
> <meissner@linux.vnet.ibm.com> wrote:
>> On Mon, Oct 01, 2012 at 02:02:26PM -0400, Michael Meissner wrote:
>>> Your change on September 30th, breaks the powerpc port because the
>>> REPORT_DETAILS value in the enumeration is no longer there, and the
>>> rs6000_density_test function was using that.  Please in the future, when you
>>> are making global changes, grep for uses of enum values in all of the machine
>>> dependent directories so we can avoid breakage like this.
>>
>> Also, in looking at the changes, given we are already up to 28 TDF_ flags, I
>> would recommend immediately adding a new type that is the TDF flagword type.
>> Thus it will be a lot simpler when we add 4 more TDF flags and have to change
>> the type from int to HOST_WIDE_INT.
>
> Agreed that we need an abstraction here.

Some TLC as well - the flags have various meanings (some control dumping,
some, like TDF_TREE, seem to be unrelated - the MSG ones probably don't
need the same number-space as well, not all flags are used anymore -
TDF_MEMSYMS?).

But yes, an abstraction is needed.  But I wouldn't suggest HOST_WIDE_INT
but int -> uint32_t instead (possibly going uint64_t).

Richard.

> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-10-02  9:31                                                                                                 ` Richard Guenther
@ 2012-10-02  9:36                                                                                                   ` Gabriel Dos Reis
  0 siblings, 0 replies; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-10-02  9:36 UTC (permalink / raw)
  To: Richard Guenther
  Cc: Michael Meissner, Sharad Singhai, H.J. Lu, Xinliang David Li,
	gcc-patches, Andrew Pinski

On Tue, Oct 2, 2012 at 4:31 AM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Mon, Oct 1, 2012 at 8:39 PM, Gabriel Dos Reis
> <gdr@integrable-solutions.net> wrote:
>> On Mon, Oct 1, 2012 at 1:27 PM, Michael Meissner
>> <meissner@linux.vnet.ibm.com> wrote:
>>> On Mon, Oct 01, 2012 at 02:02:26PM -0400, Michael Meissner wrote:
>>>> Your change on September 30th, breaks the powerpc port because the
>>>> REPORT_DETAILS value in the enumeration is no longer there, and the
>>>> rs6000_density_test function was using that.  Please in the future, when you
>>>> are making global changes, grep for uses of enum values in all of the machine
>>>> dependent directories so we can avoid breakage like this.
>>>
>>> Also, in looking at the changes, given we are already up to 28 TDF_ flags, I
>>> would recommend immediately adding a new type that is the TDF flagword type.
>>> Thus it will be a lot simpler when we add 4 more TDF flags and have to change
>>> the type from int to HOST_WIDE_INT.
>>
>> Agreed that we need an abstraction here.
>
> Some TLC as well - the flags have various meanings (some control dumping,
> some, like TDF_TREE, seem to be unrelated - the MSG ones probably don't
> need the same number-space as well, not all flags are used anymore -
> TDF_MEMSYMS?).

TDF_* flags weren't originally designed for those :-/

>
> But yes, an abstraction is needed.  But I wouldn't suggest HOST_WIDE_INT
> but int -> uint32_t instead (possibly going uint64_t).

That makes sense.

-- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
@ 2012-10-10 12:03 Dominique Dhumieres
  0 siblings, 0 replies; 71+ messages in thread
From: Dominique Dhumieres @ 2012-10-10 12:03 UTC (permalink / raw)
  To: gcc-patches; +Cc: meissner, singhai

Hi,

The tests gcc.dg/vect/vect-82_64.c and gcc.dg/vect/vect-83_64.c are
failing on powerpc*-*-* (see for instance
http://gcc.gnu.org/ml/gcc-testresults/2012-10/msg01054.html ).
This is fixed with the following patch

diff -up gcc/testsuite/gcc.dg/vect/vect-82_64.c ../work/gcc/testsuite/gcc.dg/vect/vect-82_64.c
--- gcc/testsuite/gcc.dg/vect/vect-82_64.c	2007-11-21 20:18:48.000000000 +0100
+++ ../work/gcc/testsuite/gcc.dg/vect/vect-82_64.c	2012-10-08 13:52:25.000000000 +0200
@@ -1,6 +1,6 @@
 /* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */
 /* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */
-/* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-stats -maltivec" } */
+/* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-details -maltivec" } */
 
 #include <stdarg.h>
 #include "tree-vect.h"
diff -up gcc/testsuite/gcc.dg/vect/vect-83_64.c ../work/gcc/testsuite/gcc.dg/vect/vect-83_64.c
--- gcc/testsuite/gcc.dg/vect/vect-83_64.c	2007-11-21 20:18:48.000000000 +0100
+++ ../work/gcc/testsuite/gcc.dg/vect/vect-83_64.c	2012-10-08 13:52:42.000000000 +0200
@@ -1,6 +1,6 @@
 /* { dg-do run { target { { powerpc*-*-* && lp64 } && powerpc_altivec_ok } } } */
 /* { dg-do compile { target { { powerpc*-*-* && ilp32 } && powerpc_altivec_ok } } } */
-/* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-stats -maltivec" } */
+/* { dg-options "-O2 -ftree-vectorize -mpowerpc64 -fdump-tree-vect-details -maltivec" } */
 
 #include <stdarg.h>
 #include "tree-vect.h"

(tested on powerpc-apple-darwin9).

TIA

Dominique

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-07 22:03 ` Gabriel Dos Reis
  2012-05-08  7:06   ` Sharad Singhai
@ 2012-05-08  8:53   ` Richard Guenther
  1 sibling, 0 replies; 71+ messages in thread
From: Richard Guenther @ 2012-05-08  8:53 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: Sharad Singhai, davidxl, gcc-patches

On Tue, May 8, 2012 at 12:02 AM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Mon, May 7, 2012 at 4:58 PM, Sharad Singhai <singhai@google.com> wrote:
>> This is the first patch for planned improvements to dump
>> infrastructure.  Please reference the discussion in
>> http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02088.html.
>>
>> The following small patch allows selective tree and rtl dumps on
>> stderr instead of named files.  Later -fopt-info can be implemented in
>> form of -fdump-xxx-stderr.
>
> Instead of -fdump-xxx-stderr, it will be better to have
>
>    -fdump-xxx=yyy
>
> where yyy is a path to a file, with "stderr" and "stdout" having
> special meaning.

Yeah, that looks better.

Thanks,
Richard.

> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-07 22:03 ` Gabriel Dos Reis
@ 2012-05-08  7:06   ` Sharad Singhai
  2012-05-08  8:53   ` Richard Guenther
  1 sibling, 0 replies; 71+ messages in thread
From: Sharad Singhai @ 2012-05-08  7:06 UTC (permalink / raw)
  To: Gabriel Dos Reis; +Cc: richard.guenther, davidxl, gcc-patches

That is certainly a possibility. The original motivation was to
implement -fopt-info correctly. If there are other use cases, then I
can enhance the patch.

Thanks,
Sharad


On Mon, May 7, 2012 at 3:02 PM, Gabriel Dos Reis
<gdr@integrable-solutions.net> wrote:
> On Mon, May 7, 2012 at 4:58 PM, Sharad Singhai <singhai@google.com> wrote:
>> This is the first patch for planned improvements to dump
>> infrastructure.  Please reference the discussion in
>> http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02088.html.
>>
>> The following small patch allows selective tree and rtl dumps on
>> stderr instead of named files.  Later -fopt-info can be implemented in
>> form of -fdump-xxx-stderr.
>
> Instead of -fdump-xxx-stderr, it will be better to have
>
>    -fdump-xxx=yyy
>
> where yyy is a path to a file, with "stderr" and "stdout" having
> special meaning.
>
> -- Gaby

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

* Re: [PATCH] Add option for dumping to stderr (issue6190057)
  2012-05-07 21:59 Sharad Singhai
@ 2012-05-07 22:03 ` Gabriel Dos Reis
  2012-05-08  7:06   ` Sharad Singhai
  2012-05-08  8:53   ` Richard Guenther
  0 siblings, 2 replies; 71+ messages in thread
From: Gabriel Dos Reis @ 2012-05-07 22:03 UTC (permalink / raw)
  To: Sharad Singhai; +Cc: richard.guenther, davidxl, gcc-patches

On Mon, May 7, 2012 at 4:58 PM, Sharad Singhai <singhai@google.com> wrote:
> This is the first patch for planned improvements to dump
> infrastructure.  Please reference the discussion in
> http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02088.html.
>
> The following small patch allows selective tree and rtl dumps on
> stderr instead of named files.  Later -fopt-info can be implemented in
> form of -fdump-xxx-stderr.

Instead of -fdump-xxx-stderr, it will be better to have

    -fdump-xxx=yyy

where yyy is a path to a file, with "stderr" and "stdout" having
special meaning.

-- Gaby

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

* [PATCH] Add option for dumping to stderr (issue6190057)
@ 2012-05-07 21:59 Sharad Singhai
  2012-05-07 22:03 ` Gabriel Dos Reis
  0 siblings, 1 reply; 71+ messages in thread
From: Sharad Singhai @ 2012-05-07 21:59 UTC (permalink / raw)
  To: reply, richard.guenther, davidxl, gcc-patches

This is the first patch for planned improvements to dump
infrastructure.  Please reference the discussion in
http://gcc.gnu.org/ml/gcc-patches/2011-10/msg02088.html.

The following small patch allows selective tree and rtl dumps on
stderr instead of named files.  Later -fopt-info can be implemented in
form of -fdump-xxx-stderr.

Bootstrapped and tested on x86_64 with one added testcase.  Okay for
trunk?

Thanks,
Sharad

2012-05-07   Sharad Singhai  <singhai@google.com>

	* doc/invoke.texi: Add documentation for new option.
	* tree-dump.c (dump_begin): Handle stderr appropriately.
	(dump_end): Likewise.
	(dump_switch_p_1): Likewise.
	* tree-pass.h (enum tree_dump_index): Add new constant.
	* testsuite/g++.dg/other/dump-stderr-1.C: New test.

Index: doc/invoke.texi
===================================================================
--- doc/invoke.texi	(revision 187265)
+++ doc/invoke.texi	(working copy)
@@ -5322,20 +5322,23 @@ Here are some examples showing uses of these optio
 
 @item -d@var{letters}
 @itemx -fdump-rtl-@var{pass}
+@itemx -fdump-rtl-@var{pass-stderr}
 @opindex d
 Says to make debugging dumps during compilation at times specified by
 @var{letters}.  This is used for debugging the RTL-based passes of the
 compiler.  The file names for most of the dumps are made by appending
 a pass number and a word to the @var{dumpname}, and the files are
-created in the directory of the output file.  Note that the pass
-number is computed statically as passes get registered into the pass
-manager.  Thus the numbering is not related to the dynamic order of
-execution of passes.  In particular, a pass installed by a plugin
-could have a number over 200 even if it executed quite early.
-@var{dumpname} is generated from the name of the output file, if
-explicitly specified and it is not an executable, otherwise it is the
-basename of the source file. These switches may have different effects
-when @option{-E} is used for preprocessing.
+created in the directory of the output file. If the @option{-stderr} is
+appended to the longer form of the dump option then the dump is
+done on stderr instead of named files. Note that the pass number is
+computed statically as passes get registered into the pass manager.
+Thus the numbering is not related to the dynamic order of execution of
+passes.  In particular, a pass installed by a plugin could have a
+number over 200 even if it executed quite early.  @var{dumpname} is
+generated from the name of the output file, if explicitly specified
+and it is not an executable, otherwise it is the basename of the
+source file. These switches may have different effects when
+@option{-E} is used for preprocessing.
 
 Debug dumps can be enabled with a @option{-fdump-rtl} switch or some
 @option{-d} option @var{letters}.  Here are the possible
@@ -5599,6 +5602,10 @@ These dumps are defined but always produce empty f
 @opindex fdump-rtl-all
 Produce all the dumps listed above.
 
+@item -fdump-rtl-all-stderr
+@opindex fdump-rtl-all-stderr
+Produce all the dumps on stderr.
+
 @item -dA
 @opindex dA
 Annotate the assembler output with miscellaneous debugging information.
@@ -5723,11 +5730,13 @@ counters for each function compiled.
 Control the dumping at various stages of processing the intermediate
 language tree to a file.  The file name is generated by appending a
 switch specific suffix to the source file name, and the file is
-created in the same directory as the output file.  If the
-@samp{-@var{options}} form is used, @var{options} is a list of
-@samp{-} separated options which control the details of the dump.  Not
-all options are applicable to all dumps; those that are not
-meaningful are ignored.  The following options are available
+created in the same directory as the output file unless the option
+@option{stderr} is given.  In case of @option{stderr}, the dump output is on
+the stderr. If the @samp{-@var{options}} form is used, @var{options}
+is a list of @samp{-} separated options which control the details or
+location of the dump.  Not all options are applicable to all dumps;
+those that are not meaningful are ignored.  The following options are
+available
 
 @table @samp
 @item address
@@ -5765,9 +5774,42 @@ Enable showing the tree dump for each statement.
 Enable showing the EH region number holding each statement.
 @item scev
 Enable showing scalar evolution analysis details.
+@item slim
+Inhibit dumping of members of a scope or body of a function merely
+because that scope has been reached.  Only dump such items when they
+are directly reachable by some other path.  When dumping pretty-printed
+trees, this option inhibits dumping the bodies of control structures.
+@item stderr
+Instead of dumping into a named file, dump on to stderr. However, note
+that the @option{stderr} is considered weak, so in case of two
+conflicting dump options, the option to dump into file takes
+precedence regardless of the command line ordering. For instance,
+
+@smallexample
+gcc -fdump-tree-pre-stderr -fdump-tree-pre ...
+gcc -fdump-tree-pre -fdump-tree-pre-stderr ...
+@end smallexample
+
+Both produce the PRE dump in a file. Similarly, for the following
+
+@smallexample
+gcc -fdump-tree-all-stderr -fdump-tree-pre ...
+@end smallexample
+
+The PRE dump goes into a file while all other dumps are on the
+stderr. In the following example,
+
+@smallexample
+gcc -fdump-tree-all -fdump-tree-pre-stderr ...
+@end smallexample
+
+all the dumps are written into named files. The PRE dump is not dumped
+on to stderr, because @option{-fdump-tree-pre-stderr} is overridden by
+the @option{-fdump-tree-all} on the command line.
+
 @item all
-Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
-and @option{lineno}.
+Turn on all options, except @option{raw}, @option{slim}, @option{verbose},
+@option{lineno}, and @option{stderr}.
 @end table
 
 The following tree dumps are possible:
@@ -5913,6 +5955,10 @@ is made by appending @file{.vrp} to the source fil
 @item all
 @opindex fdump-tree-all
 Enable all the available tree dumps with the flags provided in this option.
+
+@item all-stderr
+@opindex fdump-tree-all-stderr
+Enable all the available tree dumps on the stderr.
 @end table
 
 @item -ftree-vectorizer-verbose=@var{n}
Index: tree-dump.c
===================================================================
--- tree-dump.c	(revision 187265)
+++ tree-dump.c	(working copy)
@@ -802,7 +802,7 @@ struct dump_option_value_info
 };
 
 /* Table of dump options. This must be consistent with the TDF_* flags
-   in tree.h */
+   in tree-dump.h */
 static const struct dump_option_value_info dump_options[] =
 {
   {"address", TDF_ADDRESS},
@@ -825,6 +825,7 @@ static const struct dump_option_value_info dump_op
   {"nouid", TDF_NOUID},
   {"enumerate_locals", TDF_ENUMERATE_LOCALS},
   {"scev", TDF_SCEV},
+  {"stderr", TDF_STDERR},
   {"all", ~(TDF_RAW | TDF_SLIM | TDF_LINENO | TDF_TREE | TDF_RTL | TDF_IPA
 	    | TDF_STMTADDR | TDF_GRAPH | TDF_DIAGNOSTIC | TDF_VERBOSE
 	    | TDF_RHS_ONLY | TDF_NOUID | TDF_ENUMERATE_LOCALS | TDF_SCEV)},
@@ -926,15 +927,25 @@ dump_begin (int phase, int *flag_ptr)
   if (phase == TDI_none || !dump_enabled_p (phase))
     return NULL;
 
-  name = get_dump_file_name (phase);
   dfi = get_dump_file_info (phase);
-  stream = fopen (name, dfi->state < 0 ? "w" : "a");
-  if (!stream)
-    error ("could not open dump file %qs: %m", name);
+
+  if (dfi->flags & TDF_STDERR)
+    {
+      stream = stderr;
+      dfi->state = 1;
+    }
   else
-    dfi->state = 1;
-  free (name);
+    {
+      name = get_dump_file_name (phase);
+      stream = fopen (name, dfi->state < 0 ? "w" : "a");
 
+      if (!stream)
+        error ("could not open dump file %qs: %m", name);
+      else
+        dfi->state = 1;
+      free (name);
+    }
+
   if (flag_ptr)
     *flag_ptr = dfi->flags;
 
@@ -989,7 +1000,8 @@ dump_flag_name (int phase)
 void
 dump_end (int phase ATTRIBUTE_UNUSED, FILE *stream)
 {
-  fclose (stream);
+  if (stream != stderr)
+    fclose (stream);
 }
 
 /* Enable all tree dumps.  Return number of enabled tree dumps.  */
@@ -1060,7 +1072,10 @@ dump_switch_p_1 (const char *arg, struct dump_file
 	if (strlen (option_ptr->name) == length
 	    && !memcmp (option_ptr->name, ptr, length))
 	  {
-	    flags |= option_ptr->value;
+            /* Consider TDF_STDERR weak and use it only if the state
+               is uninitialized. */
+            if (!((option_ptr->value & TDF_STDERR) && dfi->state))
+              flags |= option_ptr->value;
 	    goto found;
 	  }
       warning (0, "ignoring unknown option %q.*s in %<-fdump-%s%>",
@@ -1069,6 +1084,10 @@ dump_switch_p_1 (const char *arg, struct dump_file
       ptr = end_ptr;
     }
 
+  /* Clear TDF_STDERR in case of same dump without stderr option.  */
+  if ((dfi->flags & TDF_STDERR) && !(flags & TDF_STDERR))
+    dfi->flags &= ~TDF_STDERR;
+
   dfi->state = -1;
   dfi->flags |= flags;
 
Index: tree-pass.h
===================================================================
--- tree-pass.h	(revision 187265)
+++ tree-pass.h	(working copy)
@@ -84,6 +84,7 @@ enum tree_dump_index
 #define TDF_ENUMERATE_LOCALS (1 << 22)	/* Enumerate locals by uid.  */
 #define TDF_CSELIB	(1 << 23)	/* Dump cselib details.  */
 #define TDF_SCEV	(1 << 24)	/* Dump SCEV details.  */
+#define TDF_STDERR	(1 << 25)	/* Dump on stderr.  */
 
 
 /* In tree-dump.c */
Index: testsuite/g++.dg/other/dump-stderr-1.C
===================================================================
--- testsuite/g++.dg/other/dump-stderr-1.C	(revision 0)
+++ testsuite/g++.dg/other/dump-stderr-1.C	(revision 0)
@@ -0,0 +1,12 @@
+// Test that if we specify both dump to stderr and to a file, there is
+// no output on the stderr but a dump file is still produced.
+/* { dg-options "-O2 -fdump-tree-pre -fdump-tree-pre-stderr" } */
+
+void test (int *b, int *e, int stride)
+  {
+    for (int *p = b; p != e; p += stride)
+      *p = 1;
+  }
+
+/* { dg-final { scan-tree-dump-times ";; Function void test" 1 "pre"  } } */
+/* { dg-final { cleanup-tree-dump "pre" } } */

--
This patch is available for review at http://codereview.appspot.com/6190057

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

end of thread, other threads:[~2012-10-10 11:41 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-09  6:46 [PATCH] Add option for dumping to stderr (issue6190057) Sharad Singhai
2012-05-09  6:52 ` Andrew Pinski
2012-05-09  6:55   ` Gabriel Dos Reis
2012-05-09  7:22 ` Gabriel Dos Reis
2012-05-09 23:58   ` Sharad Singhai
2012-05-10  0:31     ` Xinliang David Li
2012-05-10  8:18       ` Richard Guenther
2012-05-10 16:28         ` Xinliang David Li
2012-05-11  8:49           ` Richard Guenther
2012-05-11 16:07             ` Xinliang David Li
2012-05-11 18:12               ` Xinliang David Li
2012-05-12 10:31                 ` Richard Guenther
2012-05-12 16:06                   ` Xinliang David Li
2012-05-12 16:26                     ` Gabriel Dos Reis
2012-05-12 16:39                       ` Xinliang David Li
2012-05-14  7:26                         ` Richard Guenther
2012-06-07  6:16                           ` Sharad Singhai
2012-06-07  8:08                             ` Xinliang David Li
2012-06-08  6:59                               ` Sharad Singhai
2012-06-13  6:28                                 ` Sharad Singhai
2012-06-13 11:49                                 ` Richard Guenther
2012-06-14  8:17                                   ` Sharad Singhai
2012-06-14  9:13                                     ` Richard Guenther
2012-06-15  8:13                                   ` Sharad Singhai
2012-06-15  8:40                                     ` Richard Guenther
2012-07-03 21:08                                       ` Sharad Singhai
2012-07-04 13:33                                         ` Richard Guenther
2012-08-24  8:07                                           ` Sharad Singhai
     [not found]                                             ` <CAKxPW67Nn9YSwH_xwFXBM7=y=32s_HpQ4fUAE+E8GoRSsVjxbA@mail.gmail.com>
2012-09-10 18:21                                               ` Sharad Singhai
2012-09-11 20:16                                                 ` Xinliang David Li
2012-09-12  8:15                                                   ` Sharad Singhai
     [not found]                                                     ` <CAFiYyc3AJ1C92QhZHTk83rZPgLSqwk+=qgYDeY9HG-p4UPRrMA@mail.gmail.com>
2012-09-12 10:40                                                       ` Richard Guenther
2012-09-12 16:47                                                       ` Xinliang David Li
2012-09-13 11:08                                                         ` Richard Guenther
2012-09-13 15:02                                                           ` Sharad Singhai
2012-09-13 16:10                                                           ` Xinliang David Li
2012-09-18  8:49                                                             ` Sharad Singhai
2012-09-18 15:43                                                               ` Xinliang David Li
2012-09-18 16:26                                                                 ` Sharad Singhai
2012-09-19 12:02                                                               ` Richard Guenther
2012-09-20  7:15                                                                 ` Sharad Singhai
2012-09-24 20:38                                                                   ` Sharad Singhai
2012-09-26 14:13                                                                     ` Richard Guenther
2012-09-27 12:27                                                                       ` Sharad Singhai
2012-09-27 17:06                                                                         ` Xinliang David Li
     [not found]                                                                           ` <CAKxPW65ohN989RuyK+XqJDjOJ4gFVF9hB4+qfP0LfU_6q4i8yw@mail.gmail.com>
2012-10-01  6:37                                                                             ` Sharad Singhai
2012-10-01 11:51                                                                               ` H.J. Lu
2012-10-01 13:50                                                                                 ` Sharad Singhai
2012-10-01 13:52                                                                                   ` H.J. Lu
2012-10-01 13:56                                                                                     ` Sharad Singhai
2012-10-01 14:00                                                                                       ` Richard Guenther
2012-10-01 14:07                                                                                         ` Sharad Singhai
2012-10-01 18:03                                                                                           ` Michael Meissner
2012-10-01 18:32                                                                                             ` Michael Meissner
2012-10-01 18:39                                                                                               ` Gabriel Dos Reis
2012-10-02  5:42                                                                                                 ` Sharad Singhai
2012-10-02  9:31                                                                                                 ` Richard Guenther
2012-10-02  9:36                                                                                                   ` Gabriel Dos Reis
2012-10-01 21:37                                                                                               ` [PATCH] Fix powerpc breakage, was: " Michael Meissner
2012-10-01 21:42                                                                                                 ` Gabriel Dos Reis
2012-10-01 22:45                                                                                                 ` Xinliang David Li
2012-10-01 23:06                                                                                                   ` Sharad Singhai
2012-10-01 23:11                                                                                                     ` Xinliang David Li
2012-10-02  9:25                                                                                                       ` Richard Guenther
     [not found]                                                     ` <CAAe5K+WvHvnmT8QvKbs9+kxNwO1xdm=RxqqGU3T=z7tcRzQVZg@mail.gmail.com>
2012-09-13 15:10                                                       ` [PATCH] " Sharad Singhai
2012-05-10  8:19       ` Sharad Singhai
  -- strict thread matches above, loose matches on Subject: below --
2012-10-10 12:03 Dominique Dhumieres
2012-05-07 21:59 Sharad Singhai
2012-05-07 22:03 ` Gabriel Dos Reis
2012-05-08  7:06   ` Sharad Singhai
2012-05-08  8:53   ` Richard Guenther

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).