This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH PR79159]Fix spurious array bound warning.
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Bin Cheng <Bin dot Cheng at arm dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, nd <nd at arm dot com>
- Date: Tue, 24 Jan 2017 11:51:16 +0100
- Subject: Re: [PATCH PR79159]Fix spurious array bound warning.
- Authentication-results: sourceware.org; auth=none
- References: <VI1PR0802MB21769D6E96331FFADE055DBEE7750@VI1PR0802MB2176.eurprd08.prod.outlook.com>
On Tue, Jan 24, 2017 at 11:12 AM, Bin Cheng <Bin.Cheng@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.cheng@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.cheng@arm.com>
>
> PR tree-optimization/79159
> * g++.dg/tree-ssa/pr79159.C: New test.