]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
invoke.texi (align-threshold, [...]): Document.
authorJan Hubicka <jh@suse.cz>
Tue, 9 Oct 2007 07:07:15 +0000 (09:07 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Tue, 9 Oct 2007 07:07:15 +0000 (07:07 +0000)
* invoke.texi (align-threshold, align-loop-iterations): Document.
* final.c: Include cfgloop.h, params.h
(compute_alignments): Dump decisions and compare them with loop
structure; honor given parameters.
(pass_compute_alignments): New dump file.
* params.def (PARAM_ALIGN_THRESHOLD, PARAM_ALIGN_LOOP_ITERATIONS): New.
* Makefile.in (final.o): Add dependency on cfgloop.h and params.h

From-SVN: r129162

gcc/ChangeLog
gcc/Makefile.in
gcc/doc/invoke.texi
gcc/final.c
gcc/params.def

index 03230d1eebe396acc3b5b7f0abd8500fe32d1954..4717ca8a4b0e382d811991f5b6a691eb3e0ee552 100644 (file)
@@ -1,3 +1,13 @@
+2007-10-09  Jan Hubicka  <jh@suse.cz>
+
+       * invoke.texi (align-threshold, align-loop-iterations): Document.
+       * final.c: Include cfgloop.h, params.h
+       (compute_alignments): Dump decisions and compare them with loop
+       structure; honor given parameters.
+       (pass_compute_alignments): New dump file.
+       * params.def (PARAM_ALIGN_THRESHOLD, PARAM_ALIGN_LOOP_ITERATIONS): New.
+       * Makefile.in (final.o): Add dependency on cfgloop.h and params.h
+
 2007-10-09  James E. Wilson  <wilson@specifix.com>
 
        PR tree-optimization/33655
index c31b25916a78deac1bff2dcd054d13af4e91c90f..5aee30e42baaabde0d569efdf76e9fb0c6a8a9a0 100644 (file)
@@ -2803,7 +2803,8 @@ final.o : final.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    insn-config.h $(INSN_ATTR_H) $(FUNCTION_H) output.h hard-reg-set.h \
    except.h debug.h xcoffout.h toplev.h reload.h dwarf2out.h tree-pass.h \
    $(BASIC_BLOCK_H) $(TM_P_H) $(TARGET_H) $(EXPR_H) $(CFGLAYOUT_H) dbxout.h \
-   $(TIMEVAR_H) $(CGRAPH_H) $(COVERAGE_H) $(REAL_H) $(DF_H) vecprim.h $(GGC_H)
+   $(TIMEVAR_H) $(CGRAPH_H) $(COVERAGE_H) $(REAL_H) $(DF_H) vecprim.h $(GGC_H) \
+   $(CFGLOOP_H) $(PARAMS_H)
 recog.o : recog.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) \
    $(FUNCTION_H) $(BASIC_BLOCK_H) $(REGS_H) $(RECOG_H) $(EXPR_H) \
    $(FLAGS_H) insn-config.h $(INSN_ATTR_H) toplev.h output.h reload.h \
index ab7da0fd167008be1a970588315e68a5c9840c33..e5318eb2f260cd85ca22cfcdaf8c1e0a58b1edf5 100644 (file)
@@ -6873,6 +6873,16 @@ with unknown.  We predict the known number of iterations correctly, while
 the unknown number of iterations average to roughly 10.  This means that the
 loop without bounds would appear artificially cold relative to the other one.
 
+@item align-threshold
+
+Select fraction of the maximal frequency of executions of basic block in
+function given basic block will get aligned.
+
+@item align-loop-iterations
+
+A loop expected to iterate at lest the selected number of iterations will get
+aligned.
+
 @item tracer-dynamic-coverage
 @itemx tracer-dynamic-coverage-feedback
 
index b59a222001130f3a7d331329f445184f9a1a7509..654f847c5e30bafe013e4dfa1b8a83ddaef75ffb 100644 (file)
@@ -78,6 +78,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "df.h"
 #include "vecprim.h"
 #include "ggc.h"
+#include "cfgloop.h"
+#include "params.h"
 
 #ifdef XCOFF_DEBUGGING_INFO
 #include "xcoffout.h"          /* Needed for external data
@@ -673,6 +675,8 @@ compute_alignments (void)
 {
   int log, max_skip, max_log;
   basic_block bb;
+  int freq_max = 0;
+  int freq_threshold = 0;
 
   if (label_align)
     {
@@ -688,6 +692,19 @@ compute_alignments (void)
   if (! optimize || optimize_size)
     return 0;
 
+  if (dump_file)
+    {
+      dump_flow_info (dump_file, TDF_DETAILS);
+      flow_loops_dump (dump_file, NULL, 1);
+      loop_optimizer_init (AVOID_CFG_MODIFICATIONS);
+    }
+  FOR_EACH_BB (bb)
+    if (bb->frequency > freq_max)
+      freq_max = bb->frequency;
+  freq_threshold = freq_max / PARAM_VALUE (PARAM_ALIGN_THRESHOLD);
+
+  if (dump_file)
+    fprintf(dump_file, "freq_max: %i\n",freq_max);
   FOR_EACH_BB (bb)
     {
       rtx label = BB_HEAD (bb);
@@ -697,7 +714,12 @@ compute_alignments (void)
 
       if (!LABEL_P (label)
          || probably_never_executed_bb_p (bb))
-       continue;
+       {
+         if (dump_file)
+           fprintf(dump_file, "BB %4i freq %4i loop %2i loop_depth %2i skipped.\n",
+                   bb->index, bb->frequency, bb->loop_father->num, bb->loop_depth);
+         continue;
+       }
       max_log = LABEL_ALIGN (label);
       max_skip = LABEL_ALIGN_MAX_SKIP;
 
@@ -708,6 +730,18 @@ compute_alignments (void)
          else
            branch_frequency += EDGE_FREQUENCY (e);
        }
+      if (dump_file)
+       {
+         fprintf(dump_file, "BB %4i freq %4i loop %2i loop_depth %2i fall %4i branch %4i",
+                 bb->index, bb->frequency, bb->loop_father->num,
+                 bb->loop_depth,
+                 fallthru_frequency, branch_frequency);
+         if (!bb->loop_father->inner && bb->loop_father->num)
+           fprintf (dump_file, " inner_loop");
+         if (bb->loop_father->header == bb)
+           fprintf (dump_file, " loop_header");
+         fprintf (dump_file, "\n");
+       }
 
       /* There are two purposes to align block with no fallthru incoming edge:
         1) to avoid fetch stalls when branch destination is near cache boundary
@@ -720,12 +754,14 @@ compute_alignments (void)
         when function is called.  */
 
       if (!has_fallthru
-         && (branch_frequency > BB_FREQ_MAX / 10
+         && (branch_frequency > freq_threshold
              || (bb->frequency > bb->prev_bb->frequency * 10
                  && (bb->prev_bb->frequency
                      <= ENTRY_BLOCK_PTR->frequency / 2))))
        {
          log = JUMP_ALIGN (label);
+         if (dump_file)
+           fprintf(dump_file, "  jump alignment added.\n");
          if (max_log < log)
            {
              max_log = log;
@@ -736,10 +772,13 @@ compute_alignments (void)
         align it.  It is most likely a first block of loop.  */
       if (has_fallthru
          && maybe_hot_bb_p (bb)
-         && branch_frequency + fallthru_frequency > BB_FREQ_MAX / 10
-         && branch_frequency > fallthru_frequency * 2)
+         && branch_frequency + fallthru_frequency > freq_threshold
+         && (branch_frequency
+             > fallthru_frequency * PARAM_VALUE (PARAM_ALIGN_LOOP_ITERATIONS)))
        {
          log = LOOP_ALIGN (label);
+         if (dump_file)
+           fprintf(dump_file, "  internal loop alignment added.\n");
          if (max_log < log)
            {
              max_log = log;
@@ -749,12 +788,15 @@ compute_alignments (void)
       LABEL_TO_ALIGNMENT (label) = max_log;
       LABEL_TO_MAX_SKIP (label) = max_skip;
     }
+
+  if (dump_file)
+    loop_optimizer_finalize ();
   return 0;
 }
 
 struct tree_opt_pass pass_compute_alignments =
 {
-  NULL,                                 /* name */
+  "alignments",                         /* name */
   NULL,                                 /* gate */
   compute_alignments,                   /* execute */
   NULL,                                 /* sub */
@@ -765,7 +807,8 @@ struct tree_opt_pass pass_compute_alignments =
   0,                                    /* properties_provided */
   0,                                    /* properties_destroyed */
   0,                                    /* todo_flags_start */
-  0,                                    /* todo_flags_finish */
+  TODO_dump_func | TODO_verify_rtl_sharing
+  | TODO_ggc_collect,                   /* todo_flags_finish */
   0                                     /* letter */
 };
 
index c9ae99bd6880e13642796d1f405ae5a08f93f3dc..5cb1f6da7c2dee3dec7670421d7de1ce341b3af3 100644 (file)
@@ -334,6 +334,16 @@ DEFPARAM(HOT_BB_FREQUENCY_FRACTION,
         "Select fraction of the maximal frequency of executions of basic block in function given basic block needs to have to be considered hot",
         1000, 0, 0)
 
+DEFPARAM (PARAM_ALIGN_THRESHOLD,
+         "align-threshold",
+         "Select fraction of the maximal frequency of executions of basic block in function given basic block get alignment",
+         100, 0, 0)
+
+DEFPARAM (PARAM_ALIGN_LOOP_ITERATIONS,
+         "align-loop-iterations",
+         "Loops iterating at least selected number of iterations will get loop alignement.",
+         4, 0, 0)
+
 /* For guessed profiles, the loops having unknown number of iterations
    are predicted to iterate relatively few (10) times at average.
    For functions containing one loop with large known number of iterations