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: Steven Bosscher <stevenb dot gcc at gmail dot com>
- To: FX <fxcoudert at gmail dot com>, "Joseph S. Myers" <joseph at codesourcery dot com>
- Cc: GCC Development <gcc at gcc dot gnu dot org>, Michael Meissner <gnu at the-meissners dot org>, karthikkumar at gmail dot com
- Date: Mon, 29 Sep 2014 09:11:09 +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> <B8231714-1383-4397-99E1-45AD11233624 at gmail dot com> <CABu31nOa4aVP5TMkgNg+EL2-KTKTJxYD8eN4cmTWRCowLt213Q at mail dot gmail dot com> <8369EC80-32F0-4E5B-B2DF-B886A04B30EE at gmail dot com> <380DAACD-2925-4F73-BDCE-E7E1516CD210 at gmail dot com>
On Mon, Sep 29, 2014 at 12:09 AM, FX wrote:
> Filed as PR63401: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63401
>
>
>> This is easy to see with a simple C test case:
>>
>> //__attribute__ ((optimize("strength-reduce")))
>> int foo (float x) { return __builtin_isnan(x); }
>>
>> Compiled with -O3 -ffast-math, the isnan is simplified out (fast math means no NaNs). If you uncomment the attribute (chosen because itâs actually useless), and compile again with -O3 -ffast-math: the isnan test is not simplified any more. This is because the codepath through default_options_optimization() has overwritten the value of the flags handled in set_fast_math_flags(): flag_finite_math_only, flag_signed_zeros, flag_trapping_math and flag_unsafe_math_optimizations.
>>
>> Iâm CCâing the maintainers who added the optimize attribute in the first place, as they might have an idea how to fix this. This is way beyond my league!
Perhaps Joseph can help, in his position as maintainer of the option
handling subsystem.
Ciao!
Steven