5 ms·
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,
by fitzwatermellow 11y ago
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 http://www.agner.org/optimize/optimization_manuals.zip
- nly 11y ago> 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 < size <= UINT_MAX. Am I missing something?
- deleted 11y ago[deleted]
- VodkaInferno 11y agosize is a const int that holds a positive value so you won't ever have INT_MAX < size.
- nly 11y agoYes, and the compiler knows that as well. GCC even merges the two versions because they're equivalent[0] My point is, if size is dynamic, this is a dangerous optimisation. [0] http://goo.gl/4Ev8as http://goo.gl/4Ev8as