Compilers usually have some internal normalization rules, such as "constants on the left." This means that a + 3 will be converted to 3 + a , but not vice versa.
In your example, (3+100*A*B+100)*3+100 will be normalized to (3+100+(100*A*B))*3+100 . Now you can optimize 3+100 .
Another conversion may be a*C1+C2 to (a+(C2/C1))*C1 , provided that C1 and C2 are constants. Intuitively, this normalizes "add to multiplication."
These normalizations are not optimizations. The goal is to group constants together, so constant bending is more efficient.
qznc
source share