From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 74F04385843D; Fri, 15 Oct 2021 01:31:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74F04385843D From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102744] [12 regression] -O2 vectorization causes Wzero-length-array-bounds-2.c to fail on arc-elf Date: Fri, 15 Oct 2021 01:31:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: crazylht at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Oct 2021 01:31:18 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102744 --- Comment #2 from Hongtao.liu --- (In reply to Martin Sebor from comment #1) > Here's the relevant part of the test with line numbers: >=20 > 68 char cbuf1[1 * sizeof (struct C)]; > 69 char cbuf2[2 * sizeof (struct C)] =3D { }; > 70=09 > 71 void test_C_global_buf (void) > 72 { > 73 struct C *p =3D (struct C*)&cbuf1; > ... > 84 p =3D (struct C*)&cbuf2; > ... > 90 p->b2.a[ 0].i =3D 0; > 91 p->b2.a[ 1].i =3D 0; > 92 p->b2.a[ 2].i =3D 0; // { dg-warning "\\\[-Warray-bounds" } > 93 p->b2.a[ 3].i =3D 0; // { dg-warning "\\\[-Warray-bounds" } > 94 sink (p); >=20 > ad the output is below. We get the two -Warray-bounds instances as > expected; they are issued before vectorization. Then we get an additional > -Wstringop-overflow for the valid store on line 90 from the strlen pass > thanks to the four stores having been vectorized. So the problem is What i got is 2 store vectorized which cause extra -Wstringop-overflow=3D For x86 which have 4 stores vectorized, there's no extra warning. Should be behavior of extra warning for 2 store vectorized but not 4 store vectorized be expected Here is dump for arc-elf void test_C_global_buf () { int * vectp.23; vector(2) int * vectp_cbuf2.22; int * vectp.21; vector(2) int * vectp_cbuf2.20; int * vectp.19; vector(2) int * vectp_cbuf1.18; int * vectp.17; vector(2) int * vectp_cbuf1.16; int * _22; [local count: 1073741824]: MEM [(int *)&cbuf1] =3D { 0, 0 }; MEM[(struct C *)&cbuf1].b1.a[1].i =3D 0; sink (&cbuf1); MEM [(int *)&cbuf1 + 8B] =3D { 0, 0 }; sink (&cbuf1); MEM [(int *)&cbuf2] =3D { 0, 0 }; MEM[(struct C *)&cbuf2].b1.a[1].i =3D 0; sink (&cbuf2); MEM [(int *)&cbuf2 + 8B] =3D { 0, 0 }; _22 =3D &MEM[(struct C *)&cbuf2].b2.a[0].i + 8; MEM [(int *)_22] =3D { 0, 0 }; sink (&cbuf2); return; And dump for x86 void test_C_global_buf () { int * vectp.33; vector(4) int * vectp_cbuf2.32; int * vectp.31; vector(2) int * vectp_cbuf2.30; int * vectp.29; vector(2) int * vectp_cbuf1.28; int * vectp.27; vector(2) int * vectp_cbuf1.26; [local count: 1073741824]: MEM [(int *)&cbuf1] =3D { 0, 0 }; MEM[(struct C *)&cbuf1].b1.a[1].i =3D 0; sink (&cbuf1); MEM [(int *)&cbuf1 + 8B] =3D { 0, 0 }; sink (&cbuf1); MEM [(int *)&cbuf2] =3D { 0, 0 }; MEM[(struct C *)&cbuf2].b1.a[1].i =3D 0; sink (&cbuf2); MEM [(int *)&cbuf2 + 8B] =3D { 0, 0, 0, 0 }; sink (&cbuf2); return; }=