Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jul 2003 21:34:17 -0400
From:      Chuck Swiger <cswiger@mac.com>
To:        freebsd Questions <freebsd-questions@FreeBSD.ORG>
Subject:   Re: buggy optimization levels...
Message-ID:  <3F29C399.6070108@mac.com>
In-Reply-To: <20030731225137.GA15353@rot13.obsecurity.org>
References:  <3F1322A9.8080805@mac.com> <20030731225137.GA15353@rot13.obsecurity.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Kris Kennaway wrote:
> On Mon, Jul 14, 2003 at 05:37:45PM -0400, Chuck Swiger wrote:
>> The "known bugs" section of the GCC info documentation lists 5 issues; "man 
>> gcc" lists none.  Can someone provide a test case for a bug involving "cc 
>> -O" versus "cc -O3" under FreeBSD 4-STABLE for the x86 architecture?
> 
> Probably not, or it would have already been fixed.

Hopefully so, as the compiler toolchain is important.  :-)

> The warning against using FreeBSD with settings higher than -O1 (==
> -O) is because it often causes bugs that are difficult to track down
> (e.g. some aspect of the kernel just doesn't work properly).

OK.  Can the existence of such problems be confirmed reliably, say by regression 
testing?  /usr/src/contrib/gcc/toplev.c is clear enough which specific 
optimizations are involved at the different number levels:

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

Couldn't one compile with "cc -O -finline-functions", and then iterate through 
"-fcse-follow-jumps", "-fgcse", etc and see which optimizations are safe?

-- 
-Chuck




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3F29C399.6070108>