This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1233H6PGE: Performance Issue with Register Optimization

Part Number: TM4C1233H6PGE


Hi everyone,

I'm experiencing an unexpected performance issue with the TM4C1233H6PGE board related to code execution time and optimization levels.

The Code:
void GPIO_SetMasterPin(bool high)
{
GPIOPinTypeGPIOOutput(GPIO_PORTM_BASE, GPIO_PIN_5);
if(high) GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_5, GPIO_PIN_5);
else GPIOPinWrite(GPIO_PORTM_BASE, GPIO_PIN_5, 0x0);
}

My observations:

-With optimization turned off, the code executes in approximately 4 seconds.
-When I enable optimization level 0 (Register Optimization), the execution time increases to around 7 seconds.
-Increasing the optimization to levels 1 and 2 brings the execution time down to 4 seconds.

It's puzzling that optimization level 0 results in slower performance compared to having no optimization at all. Can anyone provide insights or suggestions as to why this might be happening?
Is there a specific aspect of optimization level 0 that could be causing this slowdown?

Any help or guidance would be greatly appreciated.

Thank you!
  • Hi,

    With optimization turned off, the code executes in approximately 4 seconds.

      First of all, your measured time does not make sense. You are talking about real time 4 seconds? The M4F processor has about 150MIPS at 120Mhz. To put in perspective, in 4 seconds, a 120Mhz processor can potential execute hundreds of million instructions. Your GPIO_SetMasterPin should take just a few cycles to complete. You can use the disassembly window to view the assembly code and I expect it to take tens of CPU cycles which should complete less than uS, not seconds.

      As far as optimization level between off vs 0, I can have our compiler expert provide feedback. But I will suggest you compare the disassembly between the off and 0 first to see what is the difference. 

  • Sorry for not clarifying earlier, until the point where this code is executed, the total running time of my program is approximately 4 seconds. However, when I enable optimizer level 0, it increases to 7 seconds. I measure this difference in time by monitoring the voltage change for PM5. Also, it would be great to get help from your compiler expert.
    I've never done a disassembly comparison before. Should I be looking for extra operations that could  increase the execution  time?

  • Add the compiler option --src_interlist.  This causes the compiler to keep the auto-generated assembly file.  It has the same name as the source file, but the extension is changed to .asm.  Build the file with different levels of optimization, then inspect the assembly file.  I suspect you will understand the difference at that point.  If you don't, then post here again.

    Thanks and regards,

    -George