Constant folding for repeated integer operation of unknown value
While looking at D3197 I noticed that currently there is nothing to turn an expression of the form
n*m. It seems like some rules like,
forall x. x +# x = 2*x forall n x. n*x + x = (n+1) * x forall n x. x + n*x = (n+1) * x
Might fix this. Of course, it's quite possible that a string of additions **is** sometimes faster than a multiplication, but it seems to me that we should (for integer types) perform the rewrite to multiplication and then teach the code generator to lower to addition if it deems it advantageous.
Naturally, this also applies to other integer operators as well. Regardless, I doubt that this is hurting anyone too badly.