This is the mail archive of the 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]

-Os is weak...

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

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