On Tue, Jan 24, 2017 at 11:12 AM, Bin Cheng <bin.ch...@arm.com> wrote: > Hi, > Given test as reported in PR79159: > > void foo(float tmpCorr[9][9]); > float bar; > > void finalDigits(int& n) > { > float tmpCorr[9][9] = {{0}}; > > foo(tmpCorr); > for (int i = 0; i < n; i++) { > for (int j = i+1; j < n; j++) { > bar = tmpCorr[i][j]; > } > } > } > Pass cunrolli unrolls the inner loop with unrolling number 9 which is > inferred from bound of local array definition: "tmpCorr[9][9]". In fact, it > only needs to be unrolled by 8 times because the starting value of "j" is 1. > However, loop niter analyzer fails to compute the accurate niter bound > because cunrolli is before vrp pass and it doesn't know anything about outer > loop's induction variable in inner loop handling. This patch computes init > value of induction variable and uses that to improve boundary analysis. > Bootstrap and test on x86_64 and AArch64. Is it OK?
Ok. Thanks, Richard. > Thanks, > bin > > 2017-01-23 Bin Cheng <bin.ch...@arm.com> > > PR tree-optimization/79159 > * tree-ssa-loop-niter.c (get_cst_init_from_scev): New function. > (record_nonwrapping_iv): Imporve boundary using above function if no > value range information. > > gcc/testsuite/ChangeLog > 2017-01-23 Bin Cheng <bin.ch...@arm.com> > > PR tree-optimization/79159 > * g++.dg/tree-ssa/pr79159.C: New test.