'Expensive' expressions in loop limits (was: Implementation of D3DXSHScale)

Michael Stefaniuc mstefani at redhat.com
Tue Jun 19 05:07:51 CDT 2012


On 06/19/2012 10:47 AM, Dan Kegel wrote:
> Nozomi wrote:
> +    for (i = 0; i < order * order; i++)
> 
> I might have written
>      int n = order * order;
>      for (i=0; i < n; i++)
> to avoid repeating the multiplication every time around the loop,
> even though multiplication is cheap nowadays, and -O1 will optimize
> it out anyway.   Staying in the habit of avoiding 'expensive'
> operations in loop limits might still be a good idea, since the
> optimizer can't always save you.
> 
> Or is that considered ugly these days?
Of course as always a definitive "It depends". The safe approach is to
*first* optimize for the human reader; the compilers this days are
better at optimizing than the average programmer.

bye
	michael



More information about the wine-devel mailing list