help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: About g++ optimization


From: address@hidden
Subject: Re: About g++ optimization
Date: 30 Mar 2006 19:03:49 -0800
User-agent: G2/0.2

Peng,

The space between the ++ and i is fine. Some find ++i more readable,
that is all.

It is difficult to optimize away the repeated f(n) calls because f()
could have side effects and there is no guarantee it will always return
a constant. If f() always returns a constant, this could potentially be
optimized by interprocedural constant propagation(IPCP)

IPCP work is being done on the ipa branch but I don't think it is safe
to assume whether it will be optimized.

If your f() returns a constant, your best bet is to do:

 for (int i =0,  j = f(n); i < j; ++i) {
}

Regards,

Ryan Mansfield



reply via email to

[Prev in Thread] Current Thread [Next in Thread]