At 11:02 AM 12/8/00 +0100, you wrote:
>That said I remember reading somewhere that there are _some_
>optimizations that GNU C employs at higher (like -O6)
>optimization level that tries to be _too_ clever and thereby
>causing it to generate wrong code for some strange cases.
-O6 has no meaning. If you browse the source of 2.95.2 with a
grep -i optimize <gcc directory>, you'll find that there is only
3 levels of optimization (file toplevel.c) :
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;
}
As explained in the source, higher optimizations are enabled
on a case by case basis.
So the one and only type of optimization not done by leaving the
optmization level at -O2 (like Wine is doing), is the 'flag_inline_functions'
- from the only piece of code using it, it seems that flag_inline_functions
is making the compiler trying to inline a function even if the programmer
has not asked for it.
I don't know if this optimisation is dangerous; such knowledge could
only be acquired by reading and understanding the gcc code. There is
always the quick solution for the slow-witted; I have not much choice
in the matter so I have hitten www.deja.com with 'bug gcc inline' and
got 32 pages and about 800 results. Feel free to do the same and
actually read them :-)
Gerard