Can loops like this one be algorithmically transformed into multiplication
The name for this optimization seems to be induction variable elimination, there are some nice slides explaining the idea here.