public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: DJ Delorie <dj@redhat.com>
To: gcc@gcc.gnu.org
Subject: -Os is weak...
Date: Thu, 09 Sep 2010 16:43:00 -0000	[thread overview]
Message-ID: <201009091643.o89Gh16l009805@greed.delorie.com> (raw)


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))

             reply	other threads:[~2010-09-09 16:43 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-09 16:43 DJ Delorie [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201009091643.o89Gh16l009805@greed.delorie.com \
    --to=dj@redhat.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).