Ensure that dump calls are guarded with dump_enabled_p
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 13 Nov 2018 16:10:13 +0000 (16:10 +0000)
committerDavid Malcolm <dmalcolm@gcc.gnu.org>
Tue, 13 Nov 2018 16:10:13 +0000 (16:10 +0000)
If called when !dump_enabled_p, the dump_* functions effectively do
nothing, but as of r263178 this doing "nothing" involves non-trivial
work internally.

I wasn't sure whether the dump_* functions should assert that
  dump_enabled_p ()
is true when they're called, or if they should bail out immediately
for this case, so in this patch I implemented both, so that we get
an assertion failure, and otherwise bail out for the case where
!dump_enabled_p when assertions are disabled.

The patch also fixes all of the places I found during testing
(on x86_64-pc-linux-gnu) that call into dump_* but which
weren't guarded by
  if (dump_enabled_p ())

gcc/ChangeLog:
* dumpfile.c (VERIFY_DUMP_ENABLED_P): New macro.
(dump_gimple_stmt): Use it.
(dump_gimple_stmt_loc): Likewise.
(dump_gimple_expr): Likewise.
(dump_gimple_expr_loc): Likewise.
(dump_generic_expr): Likewise.
(dump_generic_expr_loc): Likewise.
(dump_printf): Likewise.
(dump_printf_loc): Likewise.
(dump_dec): Likewise.
(dump_dec): Likewise.
(dump_hex): Likewise.
(dump_symtab_node): Likewise.

gcc/ChangeLog:
* gimple-loop-interchange.cc (tree_loop_interchange::interchange):
Guard dump call with dump_enabled_p.
* graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Likewise.
* graphite-optimize-isl.c (optimize_isl): Likewise.
* graphite.c (graphite_transform_loops): Likewise.
* tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
* tree-parloops.c (parallelize_loops): Likewise.
* tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise.
* tree-vect-data-refs.c (vect_analyze_group_access_1): Likewise.
(vect_prune_runtime_alias_test_list): Likewise.
* tree-vect-loop.c (vect_update_vf_for_slp): Likewise.
(vect_estimate_min_profitable_iters): Likewise.
* tree-vect-slp.c (vect_record_max_nunits): Likewise.
(vect_build_slp_tree_2): Likewise.
(vect_supported_load_permutation_p): Likewise.
(vect_slp_analyze_operations): Likewise.
(vect_slp_analyze_bb_1): Likewise.
(vect_slp_bb): Likewise.
* tree-vect-stmts.c (vect_analyze_stmt): Likewise.
* tree-vectorizer.c (try_vectorize_loop_1): Likewise.
(pass_slp_vectorize::execute): Likewise.
(increase_alignment): Likewise.

From-SVN: r266080

15 files changed:
gcc/ChangeLog
gcc/dumpfile.c
gcc/gimple-loop-interchange.cc
gcc/graphite-isl-ast-to-gimple.c
gcc/graphite-optimize-isl.c
gcc/graphite.c
gcc/testsuite/ChangeLog
gcc/tree-loop-distribution.c
gcc/tree-parloops.c
gcc/tree-ssa-loop-niter.c
gcc/tree-vect-data-refs.c
gcc/tree-vect-loop.c
gcc/tree-vect-slp.c
gcc/tree-vect-stmts.c
gcc/tree-vectorizer.c

index ddc99e3102f9dcb59b599901966cb211a9711332..2389f1cda8f9dc9788f4717e4c3f9315597c3625 100644 (file)
@@ -1,3 +1,19 @@
+2018-11-13  David Malcolm  <dmalcolm@redhat.com>
+
+       * dumpfile.c (VERIFY_DUMP_ENABLED_P): New macro.
+       (dump_gimple_stmt): Use it.
+       (dump_gimple_stmt_loc): Likewise.
+       (dump_gimple_expr): Likewise.
+       (dump_gimple_expr_loc): Likewise.
+       (dump_generic_expr): Likewise.
+       (dump_generic_expr_loc): Likewise.
+       (dump_printf): Likewise.
+       (dump_printf_loc): Likewise.
+       (dump_dec): Likewise.
+       (dump_dec): Likewise.
+       (dump_hex): Likewise.
+       (dump_symtab_node): Likewise.
+
 2018-11-13  David Malcolm  <dmalcolm@redhat.com>
 
        PR ipa/87955
index 09c24905f52a76afee56d50dc63a1e8c22ae51c4..a1ab20531db9cc1774679980679d8d03f15b0f25 100644 (file)
@@ -1184,6 +1184,19 @@ dump_context dump_context::s_default;
 /* Implementation of dump_* API calls, calling into dump_context
    member functions.  */
 
+/* Calls to the dump_* functions do non-trivial work, so they ought
+   to be guarded by:
+     if (dump_enabled_p ())
+   Assert that they are guarded, and, if assertions are disabled,
+   bail out if the calls weren't properly guarded.  */
+
+#define VERIFY_DUMP_ENABLED_P \
+  do {                                 \
+    gcc_assert (dump_enabled_p ());    \
+    if (!dump_enabled_p ())            \
+      return;                          \
+  } while (0)
+
 /* Dump gimple statement GS with SPC indentation spaces and
    EXTRA_DUMP_FLAGS on the dump streams if DUMP_KIND is enabled.  */
 
@@ -1191,6 +1204,7 @@ void
 dump_gimple_stmt (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
                  gimple *gs, int spc)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_gimple_stmt (dump_kind, extra_dump_flags, gs, spc);
 }
 
@@ -1200,6 +1214,7 @@ void
 dump_gimple_stmt_loc (dump_flags_t dump_kind, const dump_location_t &loc,
                      dump_flags_t extra_dump_flags, gimple *gs, int spc)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_gimple_stmt_loc (dump_kind, loc, extra_dump_flags,
                                             gs, spc);
 }
@@ -1212,6 +1227,7 @@ void
 dump_gimple_expr (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
                  gimple *gs, int spc)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_gimple_expr (dump_kind, extra_dump_flags, gs, spc);
 }
 
@@ -1221,6 +1237,7 @@ void
 dump_gimple_expr_loc (dump_flags_t dump_kind, const dump_location_t &loc,
                      dump_flags_t extra_dump_flags, gimple *gs, int spc)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_gimple_expr_loc (dump_kind, loc, extra_dump_flags,
                                             gs, spc);
 }
@@ -1232,6 +1249,7 @@ void
 dump_generic_expr (dump_flags_t dump_kind, dump_flags_t extra_dump_flags,
                   tree t)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_generic_expr (dump_kind, extra_dump_flags, t);
 }
 
@@ -1242,6 +1260,7 @@ void
 dump_generic_expr_loc (dump_flags_t dump_kind, const dump_location_t &loc,
                       dump_flags_t extra_dump_flags, tree t)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_generic_expr_loc (dump_kind, loc, extra_dump_flags,
                                              t);
 }
@@ -1251,6 +1270,7 @@ dump_generic_expr_loc (dump_flags_t dump_kind, const dump_location_t &loc,
 void
 dump_printf (dump_flags_t dump_kind, const char *format, ...)
 {
+  VERIFY_DUMP_ENABLED_P;
   va_list ap;
   va_start (ap, format);
   dump_context::get ().dump_printf_va (dump_kind, format, &ap);
@@ -1264,6 +1284,7 @@ void
 dump_printf_loc (dump_flags_t dump_kind, const dump_location_t &loc,
                 const char *format, ...)
 {
+  VERIFY_DUMP_ENABLED_P;
   va_list ap;
   va_start (ap, format);
   dump_context::get ().dump_printf_loc_va (dump_kind, loc, format, &ap);
@@ -1276,6 +1297,7 @@ template<unsigned int N, typename C>
 void
 dump_dec (dump_flags_t dump_kind, const poly_int<N, C> &value)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_dec (dump_kind, value);
 }
 
@@ -1288,6 +1310,7 @@ template void dump_dec (dump_flags_t, const poly_widest_int &);
 void
 dump_dec (dump_flags_t dump_kind, const poly_wide_int &value, signop sgn)
 {
+  VERIFY_DUMP_ENABLED_P;
   if (dump_file
       && dump_context::get ().apply_dump_filter_p (dump_kind, pflags))
     print_dec (value, dump_file, sgn);
@@ -1302,6 +1325,7 @@ dump_dec (dump_flags_t dump_kind, const poly_wide_int &value, signop sgn)
 void
 dump_hex (dump_flags_t dump_kind, const poly_wide_int &value)
 {
+  VERIFY_DUMP_ENABLED_P;
   if (dump_file
       && dump_context::get ().apply_dump_filter_p (dump_kind, pflags))
     print_hex (value, dump_file);
@@ -1325,6 +1349,7 @@ dumpfile_ensure_any_optinfo_are_flushed ()
 void
 dump_symtab_node (dump_flags_t dump_kind, symtab_node *node)
 {
+  VERIFY_DUMP_ENABLED_P;
   dump_context::get ().dump_symtab_node (dump_kind, node);
 }
 
index 08aeb8eba9df232c549d07d5b289abad902498ca..9145b1217da4c4cb7a976f30a5d4ad5389e55551 100644 (file)
@@ -1645,7 +1645,7 @@ tree_loop_interchange::interchange (vec<data_reference_p> datarefs,
     }
   simple_dce_from_worklist (m_dce_seeds);
 
-  if (changed_p)
+  if (changed_p && dump_enabled_p ())
     dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
                     "loops interchanged in loop nest\n");
 
index 9e78465ea9cdacdcbc930003768ada3cf542e855..0d8960c6bb2341f1e9b7040f931087c7b21280ce 100644 (file)
@@ -1518,10 +1518,13 @@ graphite_regenerate_ast_isl (scop_p scop)
 
   if (t.codegen_error_p ())
     {
-      dump_user_location_t loc = find_loop_location
-       (scop->scop_info->region.entry->dest->loop_father);
-      dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                      "loop nest not optimized, code generation error\n");
+      if (dump_enabled_p ())
+       {
+         dump_user_location_t loc = find_loop_location
+           (scop->scop_info->region.entry->dest->loop_father);
+         dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                          "loop nest not optimized, code generation error\n");
+       }
 
       /* Remove the unreachable region.  */
       remove_edge_and_dominated_blocks (if_region->true_region->region.entry);
index 35e9ac00ec295751eb8487a51cd2d2d2147e9cf4..8ceaa495a360c4e7d45b342b136c7239d7456299 100644 (file)
@@ -160,16 +160,19 @@ optimize_isl (scop_p scop)
   if (!scop->transformed_schedule
       || isl_ctx_last_error (scop->isl_context) != isl_error_none)
     {
-      dump_user_location_t loc = find_loop_location
-       (scop->scop_info->region.entry->dest->loop_father);
-      if (isl_ctx_last_error (scop->isl_context) == isl_error_quota)
-       dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                        "loop nest not optimized, optimization timed out "
-                        "after %d operations [--param max-isl-operations]\n",
-                        max_operations);
-      else
-       dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                        "loop nest not optimized, ISL signalled an error\n");
+      if (dump_enabled_p ())
+       {
+         dump_user_location_t loc = find_loop_location
+           (scop->scop_info->region.entry->dest->loop_father);
+         if (isl_ctx_last_error (scop->isl_context) == isl_error_quota)
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                            "loop nest not optimized, optimization timed out "
+                            "after %d operations [--param max-isl-operations]\n",
+                            max_operations);
+         else
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                            "loop nest not optimized, ISL signalled an error\n");
+       }
       return false;
     }
 
@@ -182,11 +185,14 @@ optimize_isl (scop_p scop)
 
   if (same_schedule)
     {
-      dump_user_location_t loc = find_loop_location
-       (scop->scop_info->region.entry->dest->loop_father);
-      dump_printf_loc (MSG_NOTE, loc,
-                      "loop nest not optimized, optimized schedule is "
-                      "identical to original schedule\n");
+      if (dump_enabled_p ())
+       {
+         dump_user_location_t loc = find_loop_location
+           (scop->scop_info->region.entry->dest->loop_father);
+         dump_printf_loc (MSG_NOTE, loc,
+                          "loop nest not optimized, optimized schedule is "
+                          "identical to original schedule\n");
+       }
       if (dump_file)
        print_schedule_ast (dump_file, scop->original_schedule, scop);
       isl_schedule_free (scop->transformed_schedule);
index ddf16a827d061ad7cf091af82d1b2dbfed5c90e3..f49eef606f6cded25e08e72c66f8fc590729e731 100644 (file)
@@ -410,7 +410,8 @@ graphite_transform_loops (void)
          continue;
 
        changed = true;
-       if (graphite_regenerate_ast_isl (scop))
+       if (graphite_regenerate_ast_isl (scop)
+           && dump_enabled_p ())
          {
            dump_user_location_t loc = find_loop_location
              (scops[i]->scop_info->region.entry->dest->loop_father);
index d2f0fd3adc53d0210cc68e7a7126fddbd260857b..9afb5f2702cb818e02aa978afc325598a7c3f9fb 100644 (file)
@@ -1,3 +1,28 @@
+2018-11-13  David Malcolm  <dmalcolm@redhat.com>
+
+       * gimple-loop-interchange.cc (tree_loop_interchange::interchange):
+       Guard dump call with dump_enabled_p.
+       * graphite-isl-ast-to-gimple.c (graphite_regenerate_ast_isl): Likewise.
+       * graphite-optimize-isl.c (optimize_isl): Likewise.
+       * graphite.c (graphite_transform_loops): Likewise.
+       * tree-loop-distribution.c (pass_loop_distribution::execute): Likewise.
+       * tree-parloops.c (parallelize_loops): Likewise.
+       * tree-ssa-loop-niter.c (number_of_iterations_exit): Likewise.
+       * tree-vect-data-refs.c (vect_analyze_group_access_1): Likewise.
+       (vect_prune_runtime_alias_test_list): Likewise.
+       * tree-vect-loop.c (vect_update_vf_for_slp): Likewise.
+       (vect_estimate_min_profitable_iters): Likewise.
+       * tree-vect-slp.c (vect_record_max_nunits): Likewise.
+       (vect_build_slp_tree_2): Likewise.
+       (vect_supported_load_permutation_p): Likewise.
+       (vect_slp_analyze_operations): Likewise.
+       (vect_slp_analyze_bb_1): Likewise.
+       (vect_slp_bb): Likewise.
+       * tree-vect-stmts.c (vect_analyze_stmt): Likewise.
+       * tree-vectorizer.c (try_vectorize_loop_1): Likewise.
+       (pass_slp_vectorize::execute): Likewise.
+       (increase_alignment): Likewise.
+
 2018-11-13  David Malcolm  <dmalcolm@redhat.com>
 
        PR ipa/87955
index 1e8a9f0991be608d6d43c2368b61d66f526d80ec..8f61a35e5b1291b2795c660b0a3b405081f06235 100644 (file)
@@ -3139,10 +3139,11 @@ pass_loop_distribution::execute (function *fun)
          if (nb_generated_loops + nb_generated_calls > 0)
            {
              changed = true;
-             dump_printf_loc (MSG_OPTIMIZED_LOCATIONS,
-                              loc, "Loop%s %d distributed: split to %d loops "
-                              "and %d library calls.\n", str, loop->num,
-                              nb_generated_loops, nb_generated_calls);
+             if (dump_enabled_p ())
+               dump_printf_loc (MSG_OPTIMIZED_LOCATIONS,
+                                loc, "Loop%s %d distributed: split to %d loops "
+                                "and %d library calls.\n", str, loop->num,
+                                nb_generated_loops, nb_generated_calls);
 
              break;
            }
index 94824a0236f0dd2a3ff546ef6b2a6aff39e15478..4e22898268f9e0b128ab63cab7af6a346e283fa6 100644 (file)
@@ -3409,13 +3409,16 @@ parallelize_loops (bool oacc_kernels_p)
       changed = true;
       skip_loop = loop->inner;
 
-      dump_user_location_t loop_loc = find_loop_location (loop);
-      if (loop->inner)
-       dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
-                        "parallelizing outer loop %d\n", loop->num);
-      else
-       dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
-                        "parallelizing inner loop %d\n", loop->num);
+      if (dump_enabled_p ())
+       {
+         dump_user_location_t loop_loc = find_loop_location (loop);
+         if (loop->inner)
+           dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
+                            "parallelizing outer loop %d\n", loop->num);
+         else
+           dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loop_loc,
+                            "parallelizing inner loop %d\n", loop->num);
+       }
 
       gen_parallel_loop (loop, &reduction_list,
                         n_threads, &niter_desc, oacc_kernels_p);
index e763b35ee844ae187760f9ff8a62ec51a22cd290..9bcd66449fa2bdca8df205299d4b972dd0e8d359 100644 (file)
@@ -2630,7 +2630,7 @@ number_of_iterations_exit (struct loop *loop, edge exit,
   if (integer_nonzerop (niter->assumptions))
     return true;
 
-  if (warn)
+  if (warn && dump_enabled_p ())
     dump_printf_loc (MSG_MISSED_OPTIMIZATION, stmt,
                     "missed loop optimization: niters analysis ends up "
                     "with assumptions.\n");
index 8d9acd84f09551d59bda9f328b2907d7f16b6c82..1cc0320f00d3c43d4fe44da5a61bd65f3a4ad952 100644 (file)
@@ -2458,7 +2458,8 @@ vect_analyze_group_access_1 (dr_vec_info *dr_info)
          return true;
        }
 
-      dump_printf_loc (MSG_NOTE, vect_location, "using strided accesses\n");
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location, "using strided accesses\n");
       STMT_VINFO_STRIDED_P (stmt_info) = true;
       return true;
     }
@@ -3558,9 +3559,10 @@ vect_prune_runtime_alias_test_list (loop_vec_info loop_vinfo)
   unsigned int count = (comp_alias_ddrs.length ()
                        + check_unequal_addrs.length ());
 
-  dump_printf_loc (MSG_NOTE, vect_location,
-                  "improved number of alias checks from %d to %d\n",
-                  may_alias_ddrs.length (), count);
+  if (dump_enabled_p ())
+    dump_printf_loc (MSG_NOTE, vect_location,
+                    "improved number of alias checks from %d to %d\n",
+                    may_alias_ddrs.length (), count);
   if ((int) count > PARAM_VALUE (PARAM_VECT_MAX_VERSION_FOR_ALIAS_CHECKS))
     return opt_result::failure_at
       (vect_location,
index 1a39b3bb4e99585766b8f16fd0fefe8df83a5598..5baf87b926cf74e748a9d6392057dd43df1a4f06 100644 (file)
@@ -1399,14 +1399,16 @@ vect_update_vf_for_slp (loop_vec_info loop_vinfo)
 
   if (only_slp_in_loop)
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-                      "Loop contains only SLP stmts\n");
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "Loop contains only SLP stmts\n");
       vectorization_factor = LOOP_VINFO_SLP_UNROLLING_FACTOR (loop_vinfo);
     }
   else
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-                      "Loop contains SLP and non-SLP stmts\n");
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "Loop contains SLP and non-SLP stmts\n");
       /* Both the vectorization factor and unroll factor have the form
         current_vector_size * X for some rational X, so they must have
         a common multiple.  */
@@ -3337,7 +3339,8 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
   /* Cost model disabled.  */
   if (unlimited_cost_model (LOOP_VINFO_LOOP (loop_vinfo)))
     {
-      dump_printf_loc (MSG_NOTE, vect_location, "cost model disabled.\n");
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location, "cost model disabled.\n");
       *ret_min_profitable_niters = 0;
       *ret_min_profitable_estimate = 0;
       return;
@@ -3350,9 +3353,10 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
       unsigned len = LOOP_VINFO_MAY_MISALIGN_STMTS (loop_vinfo).length ();
       (void) add_stmt_cost (target_cost_data, len, vector_stmt, NULL, 0,
                            vect_prologue);
-      dump_printf (MSG_NOTE,
-                   "cost model: Adding cost of checks for loop "
-                   "versioning to treat misalignment.\n");
+      if (dump_enabled_p ())
+       dump_printf (MSG_NOTE,
+                    "cost model: Adding cost of checks for loop "
+                    "versioning to treat misalignment.\n");
     }
 
   /* Requires loop versioning with alias checks.  */
@@ -3379,9 +3383,10 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
          (void) add_stmt_cost (target_cost_data, nstmts, scalar_stmt,
                                NULL, 0, vect_prologue);
        }
-      dump_printf (MSG_NOTE,
-                   "cost model: Adding cost of checks for loop "
-                   "versioning aliasing.\n");
+      if (dump_enabled_p ())
+       dump_printf (MSG_NOTE,
+                    "cost model: Adding cost of checks for loop "
+                    "versioning aliasing.\n");
     }
 
   /* Requires loop versioning with niter checks.  */
@@ -3390,9 +3395,10 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
       /*  FIXME: Make cost depend on complexity of individual check.  */
       (void) add_stmt_cost (target_cost_data, 1, vector_stmt, NULL, 0,
                            vect_prologue);
-      dump_printf (MSG_NOTE,
-                  "cost model: Adding cost of checks for loop "
-                  "versioning niters.\n");
+      if (dump_enabled_p ())
+       dump_printf (MSG_NOTE,
+                    "cost model: Adding cost of checks for loop "
+                    "versioning niters.\n");
     }
 
   if (LOOP_REQUIRES_VERSIONING (loop_vinfo))
@@ -3440,15 +3446,17 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
   else if (npeel < 0)
     {
       peel_iters_prologue = assumed_vf / 2;
-      dump_printf (MSG_NOTE, "cost model: "
-                   "prologue peel iters set to vf/2.\n");
+      if (dump_enabled_p ())
+       dump_printf (MSG_NOTE, "cost model: "
+                    "prologue peel iters set to vf/2.\n");
 
       /* If peeling for alignment is unknown, loop bound of main loop becomes
          unknown.  */
       peel_iters_epilogue = assumed_vf / 2;
-      dump_printf (MSG_NOTE, "cost model: "
-                   "epilogue peel iters set to vf/2 because "
-                   "peeling for alignment is unknown.\n");
+      if (dump_enabled_p ())
+       dump_printf (MSG_NOTE, "cost model: "
+                    "epilogue peel iters set to vf/2 because "
+                    "peeling for alignment is unknown.\n");
 
       /* If peeled iterations are unknown, count a taken branch and a not taken
          branch per peeled loop. Even if scalar loop iterations are known,
@@ -3653,9 +3661,10 @@ vect_estimate_min_profitable_iters (loop_vec_info loop_vinfo,
       return;
     }
 
-  dump_printf (MSG_NOTE,
-              "  Calculated minimum iters for profitability: %d\n",
-              min_profitable_iters);
+  if (dump_enabled_p ())
+    dump_printf (MSG_NOTE,
+                "  Calculated minimum iters for profitability: %d\n",
+                min_profitable_iters);
 
   if (!LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)
       && min_profitable_iters < (assumed_vf + peel_iters_prologue))
index f802b004bef70d6166903eb7bed449f5ff6869e1..f2bb8da9de29480ac8483c81c6689864b33bfd32 100644 (file)
@@ -575,9 +575,10 @@ vect_record_max_nunits (stmt_vec_info stmt_info, unsigned int group_size,
       && (!nunits.is_constant (&const_nunits)
          || const_nunits > group_size))
     {
-      dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                      "Build SLP failed: unrolling required "
-                      "in basic block SLP\n");
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "Build SLP failed: unrolling required "
+                        "in basic block SLP\n");
       /* Fatal mismatch.  */
       return false;
     }
@@ -1231,9 +1232,10 @@ vect_build_slp_tree_2 (vec_info *vinfo,
                    vect_free_slp_tree (grandchild, false);
                  SLP_TREE_CHILDREN (child).truncate (0);
 
-                 dump_printf_loc (MSG_NOTE, vect_location,
-                                  "Building parent vector operands from "
-                                  "scalars instead\n");
+                 if (dump_enabled_p ())
+                   dump_printf_loc (MSG_NOTE, vect_location,
+                                    "Building parent vector operands from "
+                                    "scalars instead\n");
                  oprnd_info->def_stmts = vNULL;
                  SLP_TREE_DEF_TYPE (child) = vect_external_def;
                  children.safe_push (child);
@@ -1261,8 +1263,9 @@ vect_build_slp_tree_2 (vec_info *vinfo,
             scalar version.  */
          && !is_pattern_stmt_p (stmt_info))
        {
-         dump_printf_loc (MSG_NOTE, vect_location,
-                          "Building vector operands from scalars\n");
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "Building vector operands from scalars\n");
          child = vect_create_new_slp_node (oprnd_info->def_stmts);
          SLP_TREE_DEF_TYPE (child) = vect_external_def;
          children.safe_push (child);
@@ -1334,16 +1337,19 @@ vect_build_slp_tree_2 (vec_info *vinfo,
          while (j != group_size);
 
          /* Swap mismatched definition stmts.  */
-         dump_printf_loc (MSG_NOTE, vect_location,
-                          "Re-trying with swapped operands of stmts ");
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "Re-trying with swapped operands of stmts ");
          for (j = 0; j < group_size; ++j)
            if (matches[j] == !swap_not_matching)
              {
                std::swap (oprnds_info[0]->def_stmts[j],
                           oprnds_info[1]->def_stmts[j]);
-               dump_printf (MSG_NOTE, "%d ", j);
+               if (dump_enabled_p ())
+                 dump_printf (MSG_NOTE, "%d ", j);
              }
-         dump_printf (MSG_NOTE, "\n");
+         if (dump_enabled_p ())
+           dump_printf (MSG_NOTE, "\n");
          /* And try again with scratch 'matches' ... */
          bool *tem = XALLOCAVEC (bool, group_size);
          if ((child = vect_build_slp_tree (vinfo, oprnd_info->def_stmts,
@@ -1399,9 +1405,10 @@ vect_build_slp_tree_2 (vec_info *vinfo,
                        vect_free_slp_tree (grandchild, false);
                      SLP_TREE_CHILDREN (child).truncate (0);
 
-                     dump_printf_loc (MSG_NOTE, vect_location,
-                                      "Building parent vector operands from "
-                                      "scalars instead\n");
+                     if (dump_enabled_p ())
+                       dump_printf_loc (MSG_NOTE, vect_location,
+                                        "Building parent vector operands from "
+                                        "scalars instead\n");
                      oprnd_info->def_stmts = vNULL;
                      SLP_TREE_DEF_TYPE (child) = vect_external_def;
                      children.safe_push (child);
@@ -1757,9 +1764,10 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
              if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant (&nunits)
                  || maxk >= (DR_GROUP_SIZE (group_info) & ~(nunits - 1)))
                {
-                 dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                  "BB vectorization with gaps at the end of "
-                                  "a load is not supported\n");
+                 if (dump_enabled_p ())
+                   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                    "BB vectorization with gaps at the end of "
+                                    "a load is not supported\n");
                  return false;
                }
 
@@ -1769,9 +1777,10 @@ vect_supported_load_permutation_p (slp_instance slp_instn)
              if (!vect_transform_slp_perm_load (node, tem, NULL,
                                                 1, slp_instn, true, &n_perms))
                {
-                 dump_printf_loc (MSG_MISSED_OPTIMIZATION,
-                                  vect_location,
-                                  "unsupported load permutation\n");
+                 if (dump_enabled_p ())
+                   dump_printf_loc (MSG_MISSED_OPTIMIZATION,
+                                    vect_location,
+                                    "unsupported load permutation\n");
                  return false;
                }
            }
@@ -2592,9 +2601,10 @@ vect_slp_analyze_operations (vec_info *vinfo)
         {
          slp_tree node = SLP_INSTANCE_TREE (instance);
          stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0];
-         dump_printf_loc (MSG_NOTE, vect_location,
-                          "removing SLP instance operations starting from: %G",
-                          stmt_info->stmt);
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "removing SLP instance operations starting from: %G",
+                            stmt_info->stmt);
          vect_free_slp_instance (instance, false);
           vinfo->slp_instances.ordered_remove (i);
          cost_vec.release ();
@@ -2888,9 +2898,10 @@ vect_slp_analyze_bb_1 (gimple_stmt_iterator region_begin,
        {
          slp_tree node = SLP_INSTANCE_TREE (instance);
          stmt_vec_info stmt_info = SLP_TREE_SCALAR_STMTS (node)[0];
-         dump_printf_loc (MSG_NOTE, vect_location,
-                          "removing SLP instance operations starting from: %G",
-                          stmt_info->stmt);
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_NOTE, vect_location,
+                            "removing SLP instance operations starting from: %G",
+                            stmt_info->stmt);
          vect_free_slp_instance (instance, false);
          BB_VINFO_SLP_INSTANCES (bb_vinfo).ordered_remove (i);
          continue;
@@ -3006,14 +3017,17 @@ vect_slp_bb (basic_block bb)
          vect_schedule_slp (bb_vinfo);
 
          unsigned HOST_WIDE_INT bytes;
-         if (current_vector_size.is_constant (&bytes))
-           dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                            "basic block part vectorized using %wu byte "
-                            "vectors\n", bytes);
-         else
-           dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                            "basic block part vectorized using variable "
-                            "length vectors\n");
+         if (dump_enabled_p ())
+           {
+             if (current_vector_size.is_constant (&bytes))
+               dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                                "basic block part vectorized using %wu byte "
+                                "vectors\n", bytes);
+             else
+               dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                                "basic block part vectorized using variable "
+                                "length vectors\n");
+           }
 
          vectorized = true;
        }
index 51088cb0ba91e83c03f707e5cef9e126398733ab..74646570e2a3b6963cb9e1bf5b332024c2c77173 100644 (file)
@@ -9530,8 +9530,9 @@ vect_analyze_stmt (stmt_vec_info stmt_info, bool *need_to_vectorize,
 
   if (PURE_SLP_STMT (stmt_info) && !node)
     {
-      dump_printf_loc (MSG_NOTE, vect_location,
-                      "handled only by SLP analysis\n");
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_NOTE, vect_location,
+                        "handled only by SLP analysis\n");
       return opt_result::success ();
     }
 
index 12bf0fcd5bde4b889fb74342c4e7dd52327efa57..0a4eca51ad7b93b32ba136372589eac50de9ac79 100644 (file)
@@ -925,8 +925,9 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
            }
          if (!require_loop_vectorize && vect_slp_bb (bb))
            {
-             dump_printf_loc (MSG_NOTE, vect_location,
-                              "basic block vectorized\n");
+             if (dump_enabled_p ())
+               dump_printf_loc (MSG_NOTE, vect_location,
+                                "basic block vectorized\n");
              fold_loop_internal_call (loop_vectorized_call,
                                       boolean_true_node);
              loop_vectorized_call = NULL;
@@ -955,12 +956,15 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
     set_uid_loop_bbs (loop_vinfo, loop_vectorized_call);
 
   unsigned HOST_WIDE_INT bytes;
-  if (current_vector_size.is_constant (&bytes))
-    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                    "loop vectorized using %wu byte vectors\n", bytes);
-  else
-    dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
-                    "loop vectorized using variable length vectors\n");
+  if (dump_enabled_p ())
+    {
+      if (current_vector_size.is_constant (&bytes))
+       dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                        "loop vectorized using %wu byte vectors\n", bytes);
+      else
+       dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                        "loop vectorized using variable length vectors\n");
+    }
 
   loop_p new_loop = vect_transform_loop (loop_vinfo);
   (*num_vectorized_loops)++;
@@ -1289,7 +1293,8 @@ pass_slp_vectorize::execute (function *fun)
   FOR_EACH_BB_FN (bb, fun)
     {
       if (vect_slp_bb (bb))
-       dump_printf_loc (MSG_NOTE, vect_location, "basic block vectorized\n");
+       if (dump_enabled_p ())
+         dump_printf_loc (MSG_NOTE, vect_location, "basic block vectorized\n");
     }
 
   if (!in_loop_pipeline)
@@ -1447,7 +1452,8 @@ increase_alignment (void)
       if (alignment && vect_can_force_dr_alignment_p (decl, alignment))
         {
          vnode->increase_alignment (alignment);
-          dump_printf (MSG_NOTE, "Increasing alignment of decl: %T\n", decl);
+         if (dump_enabled_p ())
+           dump_printf (MSG_NOTE, "Increasing alignment of decl: %T\n", decl);
         }
     }