This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: Disable sched1 when optimizing for size


As I mentioned previously, I was somewhat surprised on Saturday to find
that instruction scheduling before register allocation was enabled when
optimizing for size.  I thought initially this might have been turned on
at some point, but having done some more archaeology, I can't find any
evidence of it ever being otherwise.  I think it must have been a
local-hack in the ARM back-end.

Nevertheless, for both ARM and Thumb-2 there's a significant penalty to
running this pass in terms of code size (0.3% and 1.3% respectively); so
it seems quite bizarre to me that we run this pass -- it can almost
never be good for code size unless there's significant work done on it
to control register pressure.  Even machines with large numbers of
registers and thus unlikely to spill will still have to save more
registers in the prologue.

This patch disables the pass entirely when -Os is used (we could
re-visit this at a later date if the scheduler is reworked again).

Tested on an arm-elf cross.

Ok for mainline?

R.

16-11-2009  Richard Earnshaw  <rearnsha@arm.com>

	* opts.c (decode_options): Don't enable flag_schedule_insns 
	when optimizing for size.
	* doc/invoke.texi: Document change.
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 9d79d33..2265115 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -6295,7 +6295,7 @@ helps machines that have slow floating point or memory load instructions
 by allowing other instructions to be issued until the result of the load
 or floating point instruction is required.
 
-Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
+Enabled at levels @option{-O2}, @option{-O3}.
 
 @item -fschedule-insns2
 @opindex fschedule-insns2
diff --git a/gcc/opts.c b/gcc/opts.c
index b2b6c44..4e8fdcc 100644
--- a/gcc/opts.c
+++ b/gcc/opts.c
@@ -884,7 +884,8 @@ decode_options (unsigned int argc, const char **argv)
   flag_caller_saves = opt2;
   flag_peephole2 = opt2;
 #ifdef INSN_SCHEDULING
-  flag_schedule_insns = opt2;
+  /* Only run the pre-regalloc scheduling pass if optimizing for speed.  */
+  flag_schedule_insns = opt2 && ! optimize_size;
   flag_schedule_insns_after_reload = opt2;
 #endif
   flag_regmove = opt2;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]