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

Re: optimizers for C (and C++)


> I've looked in the info documents for gcc and g++, and I cant find where it
> describes which specific -f option goes with
> the -O, -O2, -O3, etc.
> 
> How high does -O go? -O6?  What -f option does that include?

In general, -O can't be replaced with -f options; a lot of code tests
the setting of optimize directly. Most places only care whether
optimize>0; it would be rather boring to list them all: Use the source
if you need to find out.

As for options controlled: This happens in toplev.c. Currently, we have

  if (optimize >= 1)
    {
      flag_defer_pop = 1;
      flag_thread_jumps = 1;
#ifdef DELAY_SLOTS
      flag_delayed_branch = 1;
#endif
#ifdef CAN_DEBUG_WITHOUT_FP
      flag_omit_frame_pointer = 1;
#endif
    }

  if (optimize >= 2)
    {
      flag_cse_follow_jumps = 1;
      flag_cse_skip_blocks = 1;
      flag_gcse = 1;
      flag_expensive_optimizations = 1;
      flag_strength_reduce = 1;
      flag_rerun_cse_after_loop = 1;
      flag_rerun_loop_opt = 1;
      flag_caller_saves = 1;
      flag_force_mem = 1;
#ifdef INSN_SCHEDULING
      flag_schedule_insns = 1;
      flag_schedule_insns_after_reload = 1;
#endif
      flag_regmove = 1;
      flag_strict_aliasing = 1;
    }

  if (optimize >= 3)
    {
      flag_inline_functions = 1;
    }

Additional flags are target specific:

PDP11: flag_omit_frame_pointer, flag_inline_functions (isn't this all
       unecessary?)  

i960:  if ((LEVEL) >= 2)				\
    {						\
      target_flags |= TARGET_FLAG_LEAFPROC;	\
      target_flags |= TARGET_FLAG_TAILCALL;	\
    }						\

i386:   if (level > 1)
    flag_schedule_insns = 0;

c4x, rs6000:  
   if (level >= 1)
    flag_branch_on_count_reg = 1;

I could not find a place where gcc checks for -O4 or higher.

Regards,
Martin


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