This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: __attribute__((optimize("-O2"))) doesn't work


Shouldnât it be optimized to:

 0x0000000000400530 <+0>:	mov    $0x2,%eax
 0x0000000000400535 <+5>:	retq   

just like I compiled it with "gcc -O2 t.câ?

Anyway, I just want to say that the __attribute__((optimize(âxxâ))) doesnât seem to work. I tried to use __attribute__((optimize(0))) to turn off optimization on certain functions, but also failed.

Thanks,
Chaoran

> On Dec 22, 2014, at 3:48 PM, Oleg Endo <oleg.endo@t-online.de> wrote:
> 
> On Mon, 2014-12-22 at 15:43 -0600, Chaoran Yang wrote:
>> Iâve tried __attribute__((optimize(âO2â))) and __attribute__((optimize((2))). All didnât work.
> 
> What do you expect to be optimized away in your example function?
> 
> int foo() __attribute__((optimize("O2")));
> int foo()
> {
>  return 2;
> }
> 
> Cheers,
> Oleg
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]