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 16:14:55 -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> <C854C95C-19C9-476A-80CD-7C4E123758F2 at rice dot edu> <1419284923 dot 8915 dot 91 dot camel at yam-132-YW-E178-FTW>
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
>
>