Patchwork Add option for dumping to stderr (issue6190057)

login
register
mail settings
Submitter Sharad Singhai
Date Sept. 12, 2012, 8:12 a.m.
Message ID <CAKxPW656sVbeVewS6dZL_d7X+02be16JRZ-4mrXkRLzwyuUxkw@mail.gmail.com>
Download mbox | patch
Permalink /patch/183261/
State New
Headers show

Comments

Sharad Singhai - Sept. 12, 2012, 8:12 a.m.
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.
Richard Guenther - Sept. 12, 2012, 10:39 a.m.
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.
Xinliang David Li - Sept. 12, 2012, 4:46 p.m.
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]
Richard Guenther - Sept. 13, 2012, 11:08 a.m.
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.
Sharad Singhai - Sept. 13, 2012, 3:01 p.m.
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.
Sharad Singhai - Sept. 13, 2012, 3:10 p.m.
> 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
Xinliang David Li - Sept. 13, 2012, 4:10 p.m.
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.
Sharad Singhai - Sept. 18, 2012, 8:48 a.m.
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
Xinliang David Li - Sept. 18, 2012, 3:43 p.m.
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
Sharad Singhai - Sept. 18, 2012, 4:25 p.m.
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
Richard Guenther - Sept. 19, 2012, 12:01 p.m.
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
Sharad Singhai - Sept. 20, 2012, 6:59 a.m.
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
Sharad Singhai - Sept. 24, 2012, 8:10 p.m.
Ping.

Patch

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 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);
 }
 
+/* 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