CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Optomisation levels

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Morgano
Guest







Optomisation levels
PostPosted: Mon Aug 13, 2007 4:50 am     Reply with quote

Hi

We use the compiler PCWH 4.049 on a PIC18F66J15.

Is there any information on what is optimised in different optimisation levels?

Can we select prority for what to optimise for? (speed, codesize, RAM size)

It seems setting optimisation levels 10 or 11 give same result as level 0, without warnings? This is a PIC18. Maybe it is because the compiler still can not utilise the enhanced instruction set?

I am reading the generated assembler code, this is a part of what is generated in optimisation level 0, 10 and 11:

Code:
....................         printf(Maxputc, "Chain_IsToBeTrusted: %u,
potShadow: %u, keyShadow: %u, PHDTemp: %u\n\r", Chain_IsToBeTrusted,
potShadow, keysShadow, PHDTemp);
004400:  MOVLB  1
004402:  CLRF   x8C
004404:  MOVLB  0
004406:  MOVLB  1
004408:  MOVF   x8C,W


Note the really weird bank switching, the last two MOVLB are just plain unnecessayr! I would not call this unoptimised code, i would call it bloatisized code...

Using optimisation level 9 there seem not to be unnecessary bank swithing.

The header of the list file:
Code:
CCS PCH C Compiler, Version 4.049, 40082               13-aug-07 11:29

               Filename: main.lst

               ROM used: 26294 bytes (1%)
                         Largest free fragment is 65536
               RAM used: 394 (10%) at main() level
                         488 (13%) worst case
               Stack:    9 worst case (6 in main + 3 for interrupts)


Command line:
Code:
+DF +LN +T -A +M +Z +Y11 +EA I="C:\Program\PICC\Drivers;
C:\Program\PICC\Devices; c:\mplab\project_libs"
RossJ



Joined: 25 Aug 2004
Posts: 66

View user's profile Send private message

PostPosted: Mon Aug 27, 2007 11:31 pm     Reply with quote

Hello Morano,

I don't know if there is a list of optimisations, but I have found a definite improvement in ROM usage with optimisation levels above 9.

One thing I have found which might be tricking you is that the +Y command line option only accepts one digit (i.e. +Y9 is level 9, whereas +Y10 is level 1!). You can avoid this problem by using the #opt preprocessor directive.

To be sure which level is actually being used, check the 'Opt Level:' at the end of the .SYM file.

/Ross.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group