Chapter 14 is twenty-four carat gold. Would love to see optimize.com as a dedicated site with Rosetta Code-style ports of optimization recipes across languages, platforms ;) Quick link to grab all five manuals: http://www.agner.org/optimize/optimization_manuals.zip
> Chapter 14 is twenty-four carat gold Maybe, but the bounds-checking optimisation [14.2] just looks dangerous. If you end up with an erroneous 'int' index of -1 then the original code will error out, whereas the new code will interpret it as 2^32 - 1. This is a perfectly valid index in an array of 2^32 values. This optimisation just isn't equivalent if INT_MAX Am I missing something?
Optimizing Software in C++ [pdf]
11–13 of 13 posts
Re: Optimizing Software in C++ [pdf]
#12Earlier quoted context omitted.
> Chapter 14 is twenty-four carat gold Maybe, but the bounds-checking optimisation [14.2] just looks dangerous. If you end up with an erroneous 'int' index of -1 then the original code will error out, whereas the new code will interpret it as 2^32 - 1. This is a perfectly valid index in an array of 2^32 values. This optimisation just isn't equivalent if INT_MAX Am I missing something?
size is a const int that holds a positive value so you won't ever have INT_MAX < size.
My point is, if size is dynamic, this is a dangerous optimisation.
Re: Optimizing Software in C++ [pdf]
#13there is another article "What Every Programmer Should Know About Memory" by Ulrich Drepper http://www.akkadia.org/drepper/cpumemory.pdf ; it has a section on how to optimize memory access / tools that help in the process.
I put up my notes/summary on this article (more like a book with a 100+ pages) http://mosermichael.github.io/cstuff/all/blog/2015/12/11/wep...