This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Is "optimize" attribute on fndecl handled differently?
- From: FX <fxcoudert at gmail dot com>
- To: Steven Bosscher <stevenb dot gcc at gmail dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Sun, 28 Sep 2014 22:28:55 +0200
- Subject: Re: Is "optimize" attribute on fndecl handled differently?
- Authentication-results: sourceware.org; auth=none
- References: <240301BA-258A-417D-832E-24605247BCB2 at gmail dot com> <CABu31nM74GDqUdn1txoG2OeC=HB2JpmQ+pYP9P_oZyr9XC1wCw at mail dot gmail dot com>
> It looks like parse_optimize_options has nothing c-family specific in
> it, so it could be moved to attribs.c. Then you'd use
> build_optimization_node to set DECL_FUNCTION_SPECIFIC_OPTIMIZATION, as
> done in c-common.c:handle_optimize_attribute.
Yep, Iâve done it that way, it works fine.
Thereâs one surprise: a few flags (flag_finite_math_only, flag_signed_zeros, flag_trapping_math, flag_unsafe_math_optimizations) seem to appear or disappear when I set specific flags for a function. What I do is this:
--------------------
static void
add_ieee_options (tree fndecl)
{
struct cl_optimization cur_opts;
/* Save current options. */
cl_optimization_save (&cur_opts, &global_options);
/* Parse options, and update the vector. */
/* parse_optimize_options (opts, true);*/
DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)
= build_optimization_node (&global_options);
debug_tree (optimization_current_node);
debug_tree (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl));
/* Restore current options. */
cl_optimization_restore (&global_options, &cur_opts);
}
--------------------
So, even if I donât change anything to the local options (global is: -O3 -ffast-math), I see some differences between âoptimization_current_nodeâ and "DECL_FUNCTION_SPECIFIC_OPTIMIZATION (fndecl)â:
> 1,3d0
> < align_functions (0x10)
> < align_jumps (0x10)
> < align_loops (0x10)
> 26d22
> < flag_finite_math_only (0x1)
> 71a68
> > flag_signed_zeros (0x1)
> 78a76
> > flag_trapping_math (0x1)
> 113d110
> < flag_unsafe_math_optimizations (0x1)
Is that a bug in optimization handling, or am I missing something?
FX