This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: CFG merge part 7 - superblock/trace scheduling
> On Wed, Feb 19, 2003 at 06:48:33PM +0100, Jan Hubicka wrote:
> > In case we happen to do crossjumping, it does.
>
> Oh, right. I was somehow thinking of the cleanup to fix
> the cfg after sched-ebb.
I am attaching updated patch. At the moment I don't do crossjumping
after trace scheduling. I am not quite sure whehter this is good idea
and how important it is, so we can experiment with that later.
Otherwise I've moved bb-reorder before scheduler and do just normal
cfgcleanup after that (that one should not need re-running bb-reorder).
I am also killing the liveness after sched2 when done on superblocks and
recomputing it fromt he scratch in reg-stack when needed.
Honza
Thu Feb 20 15:22:56 CET 2003 Jan Hubicka <jh at suse dot 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.
Index: flags.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flags.h,v
retrieving revision 1.98
diff -c -3 -p -r1.98 flags.h
*** flags.h 12 Feb 2003 21:48:57 -0000 1.98
--- flags.h 20 Feb 2003 14:21:37 -0000
*************** extern int flag_shared_data;
*** 416,421 ****
--- 416,423 ----
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: reg-stack.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/reg-stack.c,v
retrieving revision 1.121
diff -c -3 -p -r1.121 reg-stack.c
*** reg-stack.c 13 Feb 2003 03:09:44 -0000 1.121
--- reg-stack.c 20 Feb 2003 14:21:38 -0000
*************** pop_stack (regstack, regno)
*** 416,422 ****
code duplication created when the converter inserts pop insns on
the edges. */
! void
reg_to_stack (first, file)
rtx first;
FILE *file;
--- 416,422 ----
code duplication created when the converter inserts pop insns on
the edges. */
! bool
reg_to_stack (first, file)
rtx first;
FILE *file;
*************** reg_to_stack (first, file)
*** 437,447 ****
if (regs_ever_live[i])
break;
if (i > LAST_STACK_REG)
! return;
/* Ok, floating point instructions exist. If not optimizing,
! build the CFG and run life analysis. */
! if (!optimize)
{
count_or_remove_death_notes (NULL, 1);
life_analysis (first, file, PROP_DEATH_NOTES);
--- 437,451 ----
if (regs_ever_live[i])
break;
if (i > LAST_STACK_REG)
! return false;
/* Ok, floating point instructions exist. If not optimizing,
! 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);
*************** reg_to_stack (first, file)
*** 498,503 ****
--- 502,508 ----
convert_regs (file);
free_aux_for_blocks ();
+ return true;
}
/* Check PAT, which is in INSN, for LABEL_REFs. Add INSN to the
Index: rtl.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/rtl.h,v
retrieving revision 1.383
diff -c -3 -p -r1.383 rtl.h
*** rtl.h 5 Feb 2003 00:56:40 -0000 1.383
--- rtl.h 20 Feb 2003 14:21:38 -0000
*************** extern void create_profiler PARAMS ((vo
*** 2172,2178 ****
/* In reg-stack.c */
#ifdef BUFSIZ
! extern void reg_to_stack PARAMS ((rtx, FILE *));
#endif
/* In fold-const.c */
--- 2172,2178 ----
/* In reg-stack.c */
#ifdef BUFSIZ
! extern bool reg_to_stack PARAMS ((rtx, FILE *));
#endif
/* In fold-const.c */
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.712
diff -c -3 -p -r1.712 toplev.c
*** toplev.c 19 Feb 2003 05:39:06 -0000 1.712
--- toplev.c 20 Feb 2003 14:21:38 -0000
*************** enum dump_file_index
*** 254,262 ****
DFI_peephole2,
DFI_rnreg,
DFI_ce3,
DFI_sched2,
DFI_stack,
- DFI_bbro,
DFI_mach,
DFI_dbr,
DFI_MAX
--- 254,262 ----
DFI_peephole2,
DFI_rnreg,
DFI_ce3,
+ DFI_bbro,
DFI_sched2,
DFI_stack,
DFI_mach,
DFI_dbr,
DFI_MAX
*************** static struct dump_file_info dump_file[D
*** 305,313 ****
{ "peephole2", 'z', 1, 0, 0 },
{ "rnreg", 'n', 1, 0, 0 },
{ "ce3", 'E', 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 },
};
--- 305,313 ----
{ "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 },
{ "mach", 'M', 1, 0, 0 },
{ "dbr", 'd', 0, 0, 0 },
};
*************** int flag_pedantic_errors = 0;
*** 745,750 ****
--- 745,757 ----
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:
*************** static const lang_independent_options f_
*** 1079,1084 ****
--- 1086,1095 ----
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,
*************** rest_of_compilation (decl)
*** 3490,3495 ****
--- 3501,3528 ----
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)
{
*************** rest_of_compilation (decl)
*** 3501,3507 ****
split_all_insns (1);
! schedule_insns (rtl_dump_file);
close_dump_file (DFI_sched2, print_rtl_with_bb, insns);
timevar_pop (TV_SCHED2);
--- 3534,3549 ----
split_all_insns (1);
! 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);
*************** rest_of_compilation (decl)
*** 3519,3525 ****
timevar_push (TV_REG_STACK);
open_dump_file (DFI_stack, decl);
! reg_to_stack (insns, rtl_dump_file);
close_dump_file (DFI_stack, print_rtl_with_bb, insns);
timevar_pop (TV_REG_STACK);
--- 3561,3576 ----
timevar_push (TV_REG_STACK);
open_dump_file (DFI_stack, decl);
! 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);
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.242
diff -c -3 -p -r1.242 invoke.texi
*** doc/invoke.texi 16 Feb 2003 01:11:41 -0000 1.242
--- doc/invoke.texi 20 Feb 2003 14:21:41 -0000
*************** in the following sections.
*** 287,293 ****
-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
-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
--- 287,294 ----
-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 -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
*************** sense when scheduling before register al
*** 3894,3899 ****
--- 3895,3924 ----
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