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.

Can use of __builtin_expect() increase if-else-performance?

Hi all,

I've been trying to use the compiler extension __builtin_expect() with CCS4, to increase performance, but after trying several if-else-combinations it appears to have no effect, at least on the DM648 target. Does anyone have a code sample that indicates increased performance using __builtin_expect()?

Many thanks,
Fredrik

  • Until recently, __builtin_expect was ignored by the compiler.  This bug is fixed as of versions 7.0.5, 7.2.3, and 7.3.0.  Please make sure your compiler is one of those versions, or later.

    If you are using the correct compiler version ... Improvements due to __builtin_expect are best seen when looking at the performance of individual functions.  The improvement comes a few cycles at a time, and only along the execution path indicated by the __builtin_expect(s).  

    Thanks and regards,

    -George