Subject: Re: CFLAGS and lfs
To: Todd Vierling <tv@wasabisystems.com>
From: Sean Doran <smd@ebone.net>
List: current-users
Date: 10/17/2000 20:42:21
Todd Vierling <tv@wasabisystems.com> writes:

> I don't know offhand whether gcc 2.95.2, which I'm working to switch to in
> -current, has differences between -O[3456].

The code in question is in .../gcc/toplev.c, and note that
unless the OPTIMIZATION_OPTIONS macro does something, -Ox
where x > 3 is equivalent to -O3.   OPTIMIZATION_OPTIONS
doesn't seem to do much in most cases; on -i386 it turns
off flag_schedule_insns for -O2 and beyond (.../gcc/config/i386/i386.c),
because it "make[s] the problem with not enough registers
even worse".

It's interesting that -Os forces optimize to 2.

Cool that you're working on 2.95.2.  I use it exclusively
now on my i386es (current, current+sommerfeld_i386mp_1).

        Sean.

  /* Scan to see what optimization level has been specified.  That will
     determine the default value of many flags.  */
  for (i = 1; i < argc; i++)
    {
      if (!strcmp (argv[i], "-O"))
        {
          optimize = 1;
          optimize_size = 0;
        }
      else if (argv[i][0] == '-' && argv[i][1] == 'O')
        {
          /* Handle -Os, -O2, -O3, -O69, ...  */
          char *p = &argv[i][2];
          
          if ((p[0] == 's') && (p[1] == 0))
            {
              optimize_size = 1;
              
              /* Optimizing for size forces optimize to be 2. */
              optimize = 2;
            }
          else
            {       
              const int optimize_val = read_integral_parameter (p, p - 2, -1);
              if (optimize_val != -1)
                {
                  optimize = optimize_val;
                  optimize_size = 0;
                }
            }
        }
    }
  obey_regdecls = (optimize == 0);

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

  if (optimize >= 3)
    {
      flag_inline_functions = 1;
    }
#ifdef OPTIMIZATION_OPTIONS
  /* Allow default optimizations to be specified on a per-machine basis.  */
  OPTIMIZATION_OPTIONS (optimize, optimize_size);
#endif