toplev.c (flag_sched2_use_superblocks, [...]): New global variables.
authorJan Hubicka <jh@suse.cz>
Thu, 20 Feb 2003 20:56:53 +0000 (21:56 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Thu, 20 Feb 2003 20:56:53 +0000 (20:56 +0000)
* toplev.c (flag_sched2_use_superblocks, flag_sched2_use_traces):  New global variables.
(lang_independent_options):  Add -fsched2-use-superblocks -fsced2-use-traces.
(rest_of_compilation): Deal with it.
* invoke.texi (-fsched2-use-traces, fsched2-use-superblocks):  Declare.
* flags.h (flag_sched2_use_superblocks, flag_sched2_use_traces): Declare.
* rtl.h (reg_to_stack):  Update prototype.
* reg-stack.c (reg_to_stack): Return when something has changed;
update liveness when executing after superblock scheduling.

* combine.c (simplify_shift_const):  Simplify few special cases
into constants.

From-SVN: r63183

gcc/ChangeLog
gcc/combine.c
gcc/doc/invoke.texi
gcc/flags.h
gcc/reg-stack.c
gcc/rtl.h
gcc/toplev.c

index 98fce0af17810d58a59f2c5f1b8f7886d843f2fb..4d708ef4bdf9f31a73ed27d173b4323d1b1f4fbf 100644 (file)
@@ -1,3 +1,17 @@
+Thu Feb 20 21:41:19 CET 2003  Jan Hubicka  <jh@suse.cz>
+
+       * toplev.c (flag_sched2_use_superblocks, flag_sched2_use_traces):  New global variables.
+       (lang_independent_options):  Add -fsched2-use-superblocks -fsced2-use-traces.
+       (rest_of_compilation): Deal with it.
+       * invoke.texi (-fsched2-use-traces, fsched2-use-superblocks):  Declare.
+       * flags.h (flag_sched2_use_superblocks, flag_sched2_use_traces): Declare.
+       * rtl.h (reg_to_stack):  Update prototype.
+       * reg-stack.c (reg_to_stack): Return when something has changed;
+       update liveness when executing after superblock scheduling.
+
+       * combine.c (simplify_shift_const):  Simplify few special cases
+       into constants.
+
 2003-02-20  David Edelsohn  <edelsohn@gnu.org>
 
        * config/rs6000/rs6000.md: (attr "type"): Add fast_compare.
index ce4d3aa35dcb852897c22997f176951019954b52..7792537d34b4e35e50099c4f4cb096fe163a18ba 100644 (file)
@@ -9431,6 +9431,16 @@ simplify_shift_const (x, code, result_mode, varop, orig_count)
              == 0))
        code = LSHIFTRT;
 
+      if (code == LSHIFTRT
+         && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
+         && !(nonzero_bits (varop, shift_mode) >> count))
+       return const0_rtx;
+      if (code == ASHIFT
+         && GET_MODE_BITSIZE (shift_mode) <= HOST_BITS_PER_WIDE_INT
+         && !((nonzero_bits (varop, shift_mode) << count)
+              & GET_MODE_MASK (shift_mode)))
+       return const0_rtx;
+
       switch (GET_CODE (varop))
        {
        case SIGN_EXTEND:
index c4828d6176df2bdc21caa4d6bebef4ce6646df0b..f47c51ec6661f06c498404e04a120305b7b3e32c 100644 (file)
@@ -287,7 +287,8 @@ in the following sections.
 -frerun-cse-after-loop  -frerun-loop-opt @gol
 -fschedule-insns  -fschedule-insns2 @gol
 -fno-sched-interblock  -fno-sched-spec  -fsched-spec-load @gol
--fsched-spec-load-dangerous  -fsignaling-nans @gol
+-fsched-spec-load-dangerous  -fsched2-use-superblocks @gol
+-fsched2-use-traces  -fsignaling-nans @gol
 -fsingle-precision-constant  -fssa -fssa-ccp -fssa-dce @gol
 -fstrength-reduce  -fstrict-aliasing  -ftracer -fthread-jumps @gol
 -funit-at-a-time -funroll-all-loops  -funroll-loops  -funswitch-loops @gol
@@ -3895,6 +3896,30 @@ Allow speculative motion of more load instructions.  This only makes
 sense when scheduling before register allocation, i.e.@: with
 @option{-fschedule-insns} or at @option{-O2} or higher.
 
+@item -fsched2-use-superblocks
+@opindex fsched2-use-superblocks
+When schedulilng after register allocation, do use superblock scheduling
+algorithm.  Superblock scheduling allows motion acress basic block boundaries
+resulting on faster schedules.  This option is experimental, as not all machine
+descriptions used by GCC model the CPU closely enought to avoid unreliable
+results from the algorithm. 
+
+This only makes sense when scheduling after register allocation, i.e.@: with
+@option{-fschedule-insns2} or at @option{-O2} or higher.
+
+@item -fsched2-use-traces
+@opindex fsched2-use-traces
+Use @option{-fsched2-use-superblocks} algorithm when scheduling after register
+allocation and additionally perform code duplication in order to increase the
+size of superblocks using tracer pass.  See @option{-ftracer} for details on
+trace formation.
+
+This mode should produce faster but singificantly longer programs.  Also
+without @code{-fbranch-probabilities} the traces constructed may not match the
+reality and hurt the performance.  This only makes
+sense when scheduling after register allocation, i.e.@: with
+@option{-fschedule-insns2} or at @option{-O2} or higher.
+
 @item -fcaller-saves
 @opindex fcaller-saves
 Enable values to be allocated in registers that will be clobbered by
index 18cffaa479bbcb27dcae2cfe35c4d8990b4c25c1..559f70fd6b84a56ec4a18e0d4ee2a9b5ae35a030 100644 (file)
@@ -416,6 +416,8 @@ extern int flag_shared_data;
 
 extern int flag_schedule_insns;
 extern int flag_schedule_insns_after_reload;
+extern int flag_sched2_use_superblocks;
+extern int flag_sched2_use_traces;
 
 /* The following flags have effect only for scheduling before register
    allocation:
index 965aad0b24dae2d85d7f5fc157432a834e81270c..f8f4b3144bfe836f8dfe08e47902df601564feac 100644 (file)
@@ -416,7 +416,7 @@ pop_stack (regstack, regno)
    code duplication created when the converter inserts pop insns on
    the edges.  */
 
-void
+bool
 reg_to_stack (first, file)
      rtx first;
      FILE *file;
@@ -437,11 +437,15 @@ reg_to_stack (first, file)
     if (regs_ever_live[i])
       break;
   if (i > LAST_STACK_REG)
-    return;
+    return false;
 
   /* Ok, floating point instructions exist.  If not optimizing,
-     build the CFG and run life analysis.  */
-  if (!optimize)
+     build the CFG and run life analysis.  
+     Also need to rebuild life when superblock scheduling is done
+     as it don't update liveness yet.  */
+  if (!optimize
+      || (flag_sched2_use_superblocks
+         && flag_schedule_insns_after_reload))
     {
       count_or_remove_death_notes (NULL, 1);
       life_analysis (first, file, PROP_DEATH_NOTES);
@@ -498,6 +502,7 @@ reg_to_stack (first, file)
   convert_regs (file);
 
   free_aux_for_blocks ();
+  return true;
 }
 \f
 /* Check PAT, which is in INSN, for LABEL_REFs.  Add INSN to the
index 680550a65205d40610e5c1c596d5846c990c88ef..ff6c581023231a30574d54f7940cae7be88247fd 100644 (file)
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -2167,7 +2167,7 @@ extern void create_profiler               PARAMS ((void));
 
 /* In reg-stack.c */
 #ifdef BUFSIZ
-extern void reg_to_stack               PARAMS ((rtx, FILE *));
+extern bool reg_to_stack               PARAMS ((rtx, FILE *));
 #endif
 
 /* In fold-const.c */
index 9322f4fecf35d94e24d3356eef1ee520b8b6a0d8..ffd3760a6a687ddd90042bec1e483d72d652ba5c 100644 (file)
@@ -254,9 +254,9 @@ enum dump_file_index
   DFI_peephole2,
   DFI_rnreg,
   DFI_ce3,
+  DFI_bbro,
   DFI_sched2,
   DFI_stack,
-  DFI_bbro,
   DFI_mach,
   DFI_dbr,
   DFI_MAX
@@ -305,9 +305,9 @@ static struct dump_file_info dump_file[DFI_MAX] =
   { "peephole2", 'z', 1, 0, 0 },
   { "rnreg",   'n', 1, 0, 0 },
   { "ce3",     'E', 1, 0, 0 },
+  { "bbro",    'B', 1, 0, 0 },
   { "sched2",  'R', 1, 0, 0 },
   { "stack",   'k', 1, 0, 0 },
-  { "bbro",    'B', 1, 0, 0 },
   { "mach",    'M', 1, 0, 0 },
   { "dbr",     'd', 0, 0, 0 },
 };
@@ -745,6 +745,13 @@ int flag_pedantic_errors = 0;
 int flag_schedule_insns = 0;
 int flag_schedule_insns_after_reload = 0;
 
+/* When flag_schedule_insns_after_reload is set, use EBB scheduler.  */
+int flag_sched2_use_superblocks = 0;
+
+/* When flag_schedule_insns_after_reload is set, construct traces and EBB
+   scheduler.  */
+int flag_sched2_use_traces = 0;
+
 /* The following flags have effect only for scheduling before register
    allocation:
 
@@ -1079,6 +1086,10 @@ static const lang_independent_options f_options[] =
    N_("Allow speculative motion of some loads") },
   {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1,
    N_("Allow speculative motion of more loads") },
+  {"sched2-use-superblocks", &flag_sched2_use_superblocks, 1,
+   N_("If scheduling post reload, do superblock sheduling") },
+  {"sched2-use-traces", &flag_sched2_use_traces, 1,
+   N_("If scheduling post reload, do trace sheduling") },
   {"branch-count-reg",&flag_branch_on_count_reg, 1,
    N_("Replace add,compare,branch with branch on count reg") },
   {"pic", &flag_pic, 1,
@@ -3490,6 +3501,28 @@ rest_of_compilation (decl)
     split_all_insns (1);
 #endif
 
+  if (optimize > 0)
+    {
+      timevar_push (TV_REORDER_BLOCKS);
+      open_dump_file (DFI_bbro, decl);
+
+      /* Last attempt to optimize CFG, as scheduling, peepholing and insn
+        splitting possibly introduced more crossjumping opportunities. */
+      cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE
+                  | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0));
+
+      if (flag_sched2_use_traces && flag_schedule_insns_after_reload)
+        tracer ();
+      if (flag_reorder_blocks)
+       reorder_basic_blocks ();
+      if (flag_reorder_blocks
+         || (flag_sched2_use_traces && flag_schedule_insns_after_reload))
+         cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_UPDATE_LIFE);
+
+      close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
+      timevar_pop (TV_REORDER_BLOCKS);
+    }
+
 #ifdef INSN_SCHEDULING
   if (optimize > 0 && flag_schedule_insns_after_reload)
     {
@@ -3501,7 +3534,16 @@ rest_of_compilation (decl)
 
       split_all_insns (1);
 
-      schedule_insns (rtl_dump_file);
+      if (flag_sched2_use_superblocks || flag_sched2_use_traces)
+       {
+         schedule_ebbs (rtl_dump_file);
+         /* No liveness updating code yet, but it should be easy to do.
+            reg-stack recompute the liveness when needed for now.  */
+         count_or_remove_death_notes (NULL, 1);
+         cleanup_cfg (CLEANUP_EXPENSIVE);
+       }
+      else
+        schedule_insns (rtl_dump_file);
 
       close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
       timevar_pop (TV_SCHED2);
@@ -3519,7 +3561,16 @@ rest_of_compilation (decl)
   timevar_push (TV_REG_STACK);
   open_dump_file (DFI_stack, decl);
 
-  reg_to_stack (insns, rtl_dump_file);
+  if (reg_to_stack (insns, rtl_dump_file) && optimize)
+    {
+      if (cleanup_cfg (CLEANUP_EXPENSIVE | CLEANUP_POST_REGSTACK
+                      | (flag_crossjumping ? CLEANUP_CROSSJUMP : 0))
+         && flag_reorder_blocks)
+       {
+         reorder_basic_blocks ();
+         cleanup_cfg (CLEANUP_EXPENSIVE);
+       }
+    }
 
   close_dump_file (DFI_stack, print_rtl_with_bb, insns);
   timevar_pop (TV_REG_STACK);
@@ -4904,6 +4955,7 @@ parse_options_and_default_flags (argc, argv)
       flag_cse_skip_blocks = 1;
       flag_gcse = 1;
       flag_expensive_optimizations = 1;
+      flag_unit_at_a_time = 1;
       flag_strength_reduce = 1;
       flag_rerun_cse_after_loop = 1;
       flag_rerun_loop_opt = 1;