Tag Archives: gcc

C Optimization Tips – Dealing with Aliasing

Though in general it is true that you should simply leave C code optimization to the compiler, it sometimes is useful to provide hints to the compiler. This is because when optimizing the compiler has to make a few basic global assumptions so as to generate correct code in all situations, but these assumptions may [...]

  • Share/Bookmark
Posted in Uncategorized | Also tagged , | Leave a comment

C if-else Optimization

When doing some maintenance work on C code (refactoring!), I wondered if I should code C if-else clauses in some particular way to take advantage of modern processor pipelines and caching. It seems obvious that if you have multiple else-if clauses, then putting the most likely to execute code in the first if clause would [...]

  • Share/Bookmark
Posted in Uncategorized | Also tagged , | 2 Comments