Originally Posted by
laserlight
A compiler's static analysis can handle the low hanging fruit of constant folding, constant propagation, replacing multiplication or division by powers of two with bit shifting, or replacing the common x % 2 == 0 with x & 1 == 0. A compiler could even rearrange expressions so as to allow for non-obvious constant folding and/or to reduce the number/cost of operations. It sounds like the latter is especially what ccafe was looking for with some kind of tool that preprocesses C++ code (so no proxy objects in the code as the result is the optimised C++ source code as if a human had hand-optimised it, hence "source-to-source"), but yeah, I have never heard of anyone attempting to do that in a manner that could handle third party libraries, and ccafe did note that "it wouldn't be able to do so unless it knew the time cost for each operator"... which in a bignum library is probably complicated further by the size of the operands possibly only being known at run time and yet impacting the time cost significantly.