This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: __attribute__((optimize("-O2"))) doesn't work
- From: Chaoran Yang <chaoran at rice dot edu>
- To: Oleg Endo <oleg dot endo at t-online dot de>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 22 Dec 2014 15:43:29 -0600
- Subject: Re: __attribute__((optimize("-O2"))) doesn't work
- Authentication-results: sourceware.org; auth=none
- References: <127B0179-8F1C-4CE6-8318-33E8AA76E7A6 at rice dot edu> <1419284351 dot 8915 dot 89 dot camel at yam-132-YW-E178-FTW>
Iâve tried __attribute__((optimize(âO2â))) and __attribute__((optimize((2))). All didnât work.
Chaoran
> On Dec 22, 2014, at 3:39 PM, Oleg Endo <oleg.endo@t-online.de> wrote:
>
> On Mon, 2014-12-22 at 15:33 -0600, Chaoran Yang wrote:
>> Hi all,
>>
>> Iâm trying to use the __attribute__((optimize(â-O2â))) to mark a
>> function that should always be optimized. But it doesnât seem to work.
>> Iâve tested both GCC 4.9.2 and 4.8.3, they both silently ignored the
>> attribute. Iâm wondering if Iâm something super stupid that Iâm not
>> aware of.
>
> Try __attribute__((optimize("O2"))
>
> i.e. remove the leading '-'.
>
> See also:
> https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html#Function-Attributes
>
> "Strings that begin with O are assumed to be an optimization option,
> while other options are assumed to be used with a -f prefix. "
>
> Cheers,
> Oleg
>
>