Loop unrolling tends to produce chains of %x1 = add %x0, 1; %x2 = add %x1, 1; ... with one add per unrolled iteration. This patch proposed to simplify these adds to %xN = add %x0, N directly during unrolling, rather than waiting for InstCombine to do so.
The motivation for this is that having a single add (rather than an add chain) on the induction variable makes it a simple recurrence, which we specially recognize in a number of places. This allows InstCombine to directly perform folds with that knowledge, instead of first folding the add chains, and then doing other folds in another InstCombine iteration.
Due to the reduced number of InstCombine iterations, this also results in a small compile-time improvement: http://llvm-compile-time-tracker.com/compare.php?from=4c748821cd18a13898db87cbe4925e5f26af1fab&to=e21a18f8e74a7bdb1bf98fbe1ce6accce3a10a0a&stat=instructions:u
Do we have any tests where there's a signed overflow here? Would be good to make sure this is covered in the tests.