This patch add an additional InstCombine pass executed after PPCCTRLoop pass.
The intention of this additional InstCombine pass is to clean up accesses to induction variables in a loop if PPCCTRLoop pass makes them dead code.
A motivating example is as follow:
bool func(long a[N][N], long row, long col) { for (long i = row, j = col; j >= 0 && i < N; i++, j--) if (a[i][j]) return false; return true; }
This loop is compiled into
.LBB0_2: # %for.body ldu 7, 56(6) cmpldi 7, 0 bne 0, .LBB0_5 addi 4, 4, 1 addi 5, 5, -1 bdnz .LBB0_2
Two addi for r4 and r5 are not used here.
By running InstCombine (even with ExpensiveCombines = false), these instructions are eliminated.
By adding the last InstCombine pass, 43 test cases (including those not optimized by PPCCTRLoop) fail. So it looks like this last InstCombine pass cleanup the code in many cases.
I observed that adding this pass increases compilation time by about 0.5% (both in # cycles and in # instructions).
I like to hear the opinion on whether adding this last InstCombine pass is reasonable as a trade-off between the compilation cost and code quality before modifying lots of test cases.