On 06/01/2012 02:13 PM, Jim Meyering wrote: > Odd... that seems like a transformation that gcc should be able to perform. > If gcc someday learns to recognize and optimize this sort of code, > is it really worth making this change?
I doubt that GCC will be able to do that optimization any time in the forseeable future, since the function in question is an external function. It'd require whole-program optimization. The problem is that GCC can't tell whether mbtolower has squirreled away the address of the size somewhere, and whether some other function is therefore modifying the size, so it constantly has to reload the size from memory. This adds a few hundred bytes to the code and can't be helping performance any.
