From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3C3363857B89; Mon, 8 Aug 2022 15:13:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C3363857B89 From: "qinzhao at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106457] array_at_struct_end_p returns TRUE for a two-dimension array which is not inside any structure Date: Mon, 08 Aug 2022 15:13:58 +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: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: qinzhao at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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: Mon, 08 Aug 2022 15:13:58 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106457 --- Comment #7 from qinzhao at gcc dot gnu.org --- another testing case failed with the current "array_at_struct_end_p": gcc/testsuite/gcc.target/aarch64/vadd_reduc-2.c 1 /* { dg-do compile } */ 2 /* { dg-additional-options "-O3 -std=3Dc99" } */ 3 /* { dg-final { check-function-bodies "**" "" "" } } */ 4=20 5 #include 6=20 7 #pragma GCC target "+nosve" 8=20 9 /* 10 **test: 11 ** ... 12 ** addv s0, v0.4s 13 ** fmov w0, s0 14 ** and w1, w0, 65535 15 ** add w0, w1, w0, lsr 16 16 ** lsr w0, w0, 1 17 ** ret 18 */ 19 int test (uint8_t *p, uint32_t t[1][1], int n) { 20=20 21 int sum =3D 0; 22 uint32_t a0; 23 for (int i =3D 0; i < 4; i++, p++) 24 t[i][0] =3D p[0]; 25=20 26 for (int i =3D 0; i < 4; i++) { 27 { 28 int t0 =3D t[0][i] + t[0][i]; 29 a0 =3D t0; 30 }; 31 sum +=3D a0; 32 } 33 return (((uint16_t)sum) + ((uint32_t)sum >> 16)) >> 1; 34 } in the above, at line 24, the array_ref t[i][0] was identified as "true" by= the current array_at_struct_end_p: Breakpoint 1, array_at_struct_end_p (ref=3D0xfffff57a2990) at ../../latest_gcc/gcc/tree.cc:12690 12690 if (TREE_CODE (ref) =3D=3D ARRAY_REF (gdb) call debug_tree(ref) unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0xfffff57d0690 precision:32 min max context > arg:0 SI size unit-size align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-ty= pe 0xfffff5a70e70 domain pointer_to_this > arg:0 visited def_stmt _4 =3D t_27(D) + _3; version:4 ptr-info 0xfffff56c84c0> arg:1 t.c:24:6 start: t.c:24:5 finish: t.c:24:8> arg:1 constant 0> t.c:24:9 start: t.c:24:5 finish: t.c:24:11> ...(gdb) n 12774 if (ref (gdb) n 12806 return true; (gdb)=20 Looks like that the current array_at_struct_end_p cannot handle multi-dimen= sion array reference correctly.=