We are using our own developed RTOS, Our developed software is working fine up to optimization level 6, but when we change the level to 8, the software was not working. We observed that the stack pointer is not same as we level 6. In level 6 when we are calling a function SP was going incremented with 2. Again from the function if we are calling another function than again SP is incrementing by 2. But in level 8 we observed that in above case SP is incrementing by 2 and not by 4. So we made necessary corrections in our RTOS related software and it worked. After working with level 8 we changed the level to 9. But this time also the software having problems. So please give information about stack Pointers. How it is working (SP) with different optimization levels.