public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* -Os is weak...
@ 2010-09-09 16:43 DJ Delorie
  2010-09-09 17:16 ` Ian Lance Taylor
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: DJ Delorie @ 2010-09-09 16:43 UTC (permalink / raw)
  To: gcc


The docs say...

@item -Os
@opindex Os
Optimize for size.  @option{-Os} enables all @option{-O2} optimizations that
do not typically increase code size.  It also performs further
optimizations designed to reduce code size.

@option{-Os} disables the following optimization flags:
@gccoptlist{-falign-functions  -falign-jumps  -falign-loops @gol
-falign-labels  -freorder-blocks  -freorder-blocks-and-partition @gol
-fprefetch-loop-arrays  -ftree-vect-loop-version}

But in reality, the only thing -Os does beyond -O2, aside from a few
niche special cases, is enable inlining, and maybe scheduling, which
for some cases may be the wrong thing to do.

Is this what we want?





  flag_schedule_insns = opt2 && ! optimize_size;

  if (optimize_size)
    {
      /* Inlining of functions reducing size is a good idea regardless of them
	 being declared inline.  */
      flag_inline_functions = 1;

      /* Basic optimization options.  */
      optimize_size = 1;
      if (optimize > 2)
	optimize = 2;

      /* We want to crossjump as much as possible.  */
      set_param_value ("min-crossjump-insns", 1);
    }
  else
    set_param_value ("min-crossjump-insns", initial_min_crossjump_insns);


$ grep optimize_size *.c
genconditions.c:   { "! optimize_size && ! TARGET_READ_MODIFY_WRITE",
genconditions.c:     __builtin_constant_p (! optimize_size && ! TARGET_READ_MODIFY_WRITE)
genconditions.c:     ? (int) (! optimize_size && ! TARGET_READ_MODIFY_WRITE)
opts.c:       optimize_size = 0;
opts.c:           optimize_size = 0;
opts.c:   optimize_size = 1;
opts.c:   optimize_size = 0;
opts.c:  flag_schedule_insns = opt2 && ! optimize_size;
opts.c:  if (optimize_size)
opts.c:      optimize_size = 1;
opts.c:  OPTIMIZATION_OPTIONS (optimize, optimize_size);
predict.c:  if (optimize_size)
predict.c:  return (optimize_size
toplev.c:   The only valid values are zero and nonzero. When optimize_size is
toplev.c:int optimize_size = 0;
toplev.c:  if (flag_prefetch_loop_arrays > 0 && optimize_size)
tree-inline.c:  if (size < 0 || size > MOVE_MAX_PIECES * MOVE_RATIO (!optimize_size))
tree-inline.c:    || (caller_opt->optimize_size != callee_opt->optimize_size))

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2010-09-26 12:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-09 16:43 -Os is weak DJ Delorie
2010-09-09 17:16 ` Ian Lance Taylor
2010-09-09 17:20   ` Andrew Pinski
2010-09-09 17:38   ` DJ Delorie
2010-09-09 19:42 ` Steven Bosscher
2010-09-09 20:00 ` Steven Bosscher
2010-09-10  8:44 ` Steven Bosscher
2010-09-10 16:49   ` DJ Delorie
2010-09-16 17:13   ` Yao Qi
2010-09-16 22:06     ` Andi Kleen
2010-09-18 13:31       ` Jakub Jelinek
2010-09-16 22:15     ` Steven Bosscher
2010-09-27  3:50   ` Gerald Pfeifer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).