Re: About g++ optimization

2006-04-01 Thread Andre Poenitz
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > If your f() returns a constant, your best bet is to do: > > for (int i =0, j = f(n); i < j; ++i) { > } Or if it doen't matter in what order the iteration is performed, even for (int i = f(n); i--; ) might do. (Note the i-- is post-decrement and i

Re: About g++ optimization

2006-04-01 Thread rmansfi...@gmail.com
If you're doing more powerful optimizations, such as IPA based, its likely you will be doing loop unrolling as well. And after loop unrolling, they should generate code identical code. > Saves usually a register and replaces a check against an 'arbitrary' > number with a check for zero (which is f