Keil Logo

Optimization level not working

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
Surekha Burkul
Posted
5-Jun-2018 07:09 GMT
Toolset
ARM
New! Optimization level not working

Hi , I am working on LPC1788 with RTX , my code size is much bigger , so i want to optimize my code, after sarching through internet , there is optimization level(-O1 to -O3) specified by keil , but when i am using that optimization level(tried each level)in my code,but it is not working , not in debug mode also , why is this happened , please help or suggest.

Author
Westonsupermare Pier
Posted
5-Jun-2018 20:48 GMT
Toolset
ARM
New! RE: Optimization level not working

Ok, so most likely a bug in your code, or some unsafe coding style/practices.

Make sure to use volatile variables where appropriate, this would be variables that change outside normal programming flow, and hardware peripheral registers that can read different values each time you read them.

Check also for uninitialized variables, and anything flagging warnings in your current code. Use #include files for all the library routines you use so it can check/verify the prototypes and calling routines.

The optimizer can change code order and fold code it perceives as doing nothing in the context it is used. Code may be moved out of loops, load constants instead of using math, etc.

Author
Surekha Burkul
Posted
6-Jun-2018 12:14 GMT
Toolset
ARM
New! RE: Optimization level not working

Thanks for your reply,
but my code is finely working without optimization , i just want to apply optimization level
I am using keil5.23 and arm CC compiler version of 5.06 with FLASH FS but only after applying optimization level ,my code is not working, i have added necessary files ,still you think if any need to be add ,tell me that specific name for optimization level working.

Author
Westonsupermare Pier
Posted
6-Jun-2018 15:39 GMT
Toolset
ARM
New! RE: Optimization level not working

>>but my code is finely working without optimization

Yes it might appear to, but I'm willing to believe there is a latent issue with your code over a bug in the compiler. The optimizer will not be tolerant of sloppy coding practices.

The compiler outputs "errors" where there are issues with syntax, it does not make a judgement about functional correctness.

>> i just want to apply optimization level
Ok, then you might need to apply function level attributes or pragmas to control optimization, until you identify the code at issue. Use bisection to isolate the issue.

Author
Surekha Burkul
Posted
9-Jun-2018 08:34 GMT
Toolset
ARM
New! RE: Optimization level not working

Thanks for reply,

>> Ok, then you might need to apply function level attributes or pragmas to control optimization, until you identify the code at issue. Use bisection to isolate the issue.
I have used #pragma in my code but still it shows error like unrecognized variable(directive)#Pragma
Now you tell me where i am wrong?

Author
Andrew Neil
Posted
9-Jun-2018 09:47 GMT
Toolset
None
New! RE: it shows error like (sic) unrecognized variable(directive)#Pragma

What do you mean, "like" ?

The compiler is telling you that it does not recognise what you've written - so go back to the documentation and check carefully for the correct usage, spelling, etc ...

Remember that 'C' is case-sensitive - so "pragma" is not the same as "Pragma" ...

If you still can't figure it out, post the complete message: copy and paste it; do not manually re-type it.

Also show the source line(s) to which it relates.

Follow the instructions for posting source code - they are immediately above the box where you type your message.

Author
Surekha Burkul
Posted
11-Jun-2018 05:58 GMT
Toolset
None
New! RE: it shows error like (sic) unrecognized variable(directive)#Pragma

Thanks ,ok my mistake(spelling)nexttime onwards i will be carefull while posting error.

but i have used the same syntax as follows
#pragma push
#pragma OT(9)
void function(void)
{}
#pragma pop

but still shows error below

error:TEST_REPORT_FILE_GENERATE_EXTRACT\test_report_file_generate_extract.c(477): warning: #161-D: unrecognized #pragma

Author
Westonsupermare Pier
Posted
9-Jun-2018 20:01 GMT
Toolset
ARM
New! RE: Optimization level not working

Why must everything be so laboured? I provide hints so I don't have to walk you down the path of discovery, or provide a check-list or script to follow.

http://www.keil.com/support/man/docs/armcc/armcc_chr1359124988971.htm
http://www.keil.com/support/docs/3704.htm
http://www.keil.com/support/man/docs/armcc/armcc_chr1359124989673.htm

What you're ultimately trying to determine is what part of your code is unsafe, where it is not sufficiently specific about the start conditions, or usage, where the optimizer applies the rules of C more rigorously, where you expect specific behaviour but have provided non-specific instructions or coded unspecified behaviour.

Author
Surekha Burkul
Posted
11-Jun-2018 06:04 GMT
Toolset
ARM
New! RE: Optimization level not working

Thanks for the link,but i have already gone through this link and only then i have used optimization function in my code.

now i dont understand where i am wrong thats why i posted my error ,if something i didn't trace ,where should i find the solution? ,thats why i am seeking guidance from you all.

thats why i have also share my working platform with you

Thanks much.

Author
Andrew Neil
Posted
11-Jun-2018 07:50 GMT
Toolset
None
New! RE: Follow the instructions for posting source code

Follow the instructions for posting source code - they are immediately above the box where you type your message."

You didn't do that - did you?

Look at this picture to help you: http://www.danlhenry.com/caps/keil_code.png

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.