From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 144813858C31; Mon, 17 Jun 2024 07:41:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 144813858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1718610067; bh=Qpnaa93Uis2kh+TQy2N+XXYhVkrx2V2O22m1gwNzupg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B693qmvX5l1tf+Tz+lfN21tae1RjiI+LyeqnU+Ci/N+P91w77CmYgVYWJZwXesmF5 FFvPtHjozZBLGYtY8LdZq1+q1QyQxKh1T0EjqoENLxE+2S15z7L7fuiFCD6QEl65i/ 3pCYOMUl2R8ifs/QQnShvGkSFgXHKjYxkdGEdPwk= From: "hongyuw at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/115256] [15 Regression] 502.gcc_r Run failed with '-march=native -Ofast -funroll-loops -flto' since r15-571-g1e0ae1f52741f7 Date: Mon, 17 Jun 2024 07:41:05 +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: 15.0 X-Bugzilla-Keywords: needs-reduction, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: hongyuw at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 15.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D115256 Hongyu Wang changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hongyuw at gcc dot gnu.org --- Comment #4 from Hongyu Wang --- Part of the dump for create_preheaders before DSE ------ [local count: 29277718]:=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_153 =3D PHI <.MEM_161(4), .MEM_161(3)> # _15 =3D PHI <_17(4), 0(3)>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20 # _120 =3D PHI <_19(4), 0(3)>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 if (_120 =3D=3D 0)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 goto ; [45.64%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20 else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 goto ; [54.36%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 [local count: 27536775]:=20=20=20=20=20=20=20=20=20=20=20=20 # _66 =3D PHI <_15(6), _17(5)>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_125 =3D PHI <.MEM_153(6), .MEM_164(5)> _87 =3D (long unsigned int) _66;=20=20=20=20=20=20=20=20=20=20=20=20=20 _88 =3D _87 * 4;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 _89 =3D _88 + 8;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20 _110 =3D _89;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_167 =3D VDEF <.MEM_125>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 newmem_111 =3D malloc (_110);=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20 if (newmem_111 =3D=3D 0B)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20 goto ; [0.04%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 goto ; [99.96%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 [local count: 11015]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_168 =3D VDEF <.MEM_167>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 xmalloc_failed (_110);=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 [local count: 27536775]:=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_154 =3D PHI <.MEM_167(7), .MEM_168(8)> # .MEM_170 =3D VDEF <.MEM_154>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 MEM[(struct vec_prefix *)newmem_111].alloc =3D _66;=20=20=20=20=20=20 # .MEM_171 =3D VDEF <.MEM_170>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 MEM[(struct vec_prefix *)newmem_111].num =3D 0;=20=20=20=20=20=20=20=20=20= =20 [local count: 39298950]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 # _91 =3D PHI <0B(6), newmem_111(9)>=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 # .MEM_152 =3D PHI <.MEM_153(6), .MEM_171(9)>=20=20=20=20=20=20=20=20=20=20= =20=20 # .MEM_174 =3D VDEF <.MEM_152>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 li.to_visit =3D _91;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # VUSE <.MEM_174>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _61 =3D cfun;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # VUSE <.MEM_174>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _62 =3D _61->x_current_loops;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20 # VUSE <.MEM_174>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _63 =3D _62->tree_root;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 [local count: 77159561]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 # aloop_80 =3D PHI <_63(10), _108(26)>=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20 # .MEM_147 =3D PHI <.MEM_174(10), .MEM_90(26)>=20=20=20=20=20=20=20=20=20= =20=20 [local count: 701450557]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 # aloop_64 =3D PHI =20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20 # .MEM_148 =3D PHI <.MEM_147(11), .MEM_149(16)>=20=20=20=20=20=20=20=20=20= =20 # VUSE <.MEM_148>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _65 =3D aloop_64->num;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 if (_65 > 0)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 goto ; [50.00%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 goto ; [50.00%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 [local count: 350725279]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 if (_91 !=3D 0B)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 goto ; [70.00%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 goto ; [30.00%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 [local count: 245507696]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 _67 =3D &MEM[(struct VEC_int_heap *)_91].base;=20=20=20=20=20=20=20=20=20= =20=20 [local count: 350725279]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 # _68 =3D PHI <0B(13), _67(14)>=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 # VUSE <.MEM_148>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _69 =3D _68->num;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _70 =3D _69 + 1;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_179 =3D VDEF <.MEM_148>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 _68->num =3D _70;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_180 =3D VDEF <.MEM_179>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 MEM [(int *)_68].vec[_69] =3D _65;=20 ------ The problem is, for the malloced stores,=20 MEM[(struct vec_prefix *)newmem_111].alloc =3D _66;=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 MEM[(struct vec_prefix *)newmem_111].num =3D 0;=20=20=20=20 These 2 stmts are marked as dead store and eliminated, but actually there w= as a use chain ------ [local count: 39298950]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20 # _91 =3D PHI <0B(6), newmem_111(9)> # .MEM_152 =3D PHI <.MEM_153(6), .MEM_171(9)> # .MEM_174 =3D VDEF <.MEM_152>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 li.to_visit =3D _91; ... [local count: 350725279]: if (_91 !=3D 0B)=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 goto ; [70.00%]=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 else=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20 goto ; [30.00%]=20=20=20 [local count: 245507696]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 _67 =3D &MEM[(struct VEC_int_heap *)_91].base;=20 [local count: 350725279]:=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 # _68 =3D PHI <0B(13), _67(14)>=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 # VUSE <.MEM_148>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 _69 =3D _68->num; _70 =3D _69 + 1;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_179 =3D VDEF <.MEM_148>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 _68->num =3D _70;=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 # .MEM_180 =3D VDEF <.MEM_179>=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20 MEM [(int *)_68].vec[_69] =3D _65; ------ The source code has an implicit type casting li->to_visit =3D (VEC_int_heap_alloc(number_of_loops () )); ... (VEC_int_base_quick_push(((li->to_visit) ? &(li->to_visit)->base : 0),aloop->num )); Who casts the malloced pointer newmem_111 to (struct VEC_int_heap *), then = cast again to (int *) in VEC_int_base_quick_push. But the store to newmem_111 was casted to (struct vec_prefix *) in VEC_int_heap_alloc. As such casting violates aliasing rule, -fno-strict-aliasing may be needed, otherwise TBAA cannot identify the ref and use actually aliases. The patch r15-571 allows analysis on multiple vdefs in dse_classify_store, = and prior to the patch it directly returns DSE_STORE_MAYBE_PARTIAL_DEAD for multiple vdefs for this case, so the issue was just exposed by the patch.=