From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EE182384D1BF; Thu, 6 Oct 2022 09:22:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EE182384D1BF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665048140; bh=nqO2r5WcYeRCC/J/B2XjsHfiPnWQuYd5n3pc8rOOqnk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XDV8eTdQ1/1Q11crbxQUk+vBZXlIlXKBLsNTVsyIApxq8nY0V8eaaBEeVRWn+zU4L yPV+7yTeF2sQSbzNylD4hyYXQlI4KhrYNA+KczXYU3gO0m1yi1YSk+YMOmKbgVQKBn X4e24UQz8BpaMoQaEDSbWP1jbawxwNinINPeE0XM= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107107] [10/11/12/13 Regression] Wrong codegen from TBAA when stores to distinct same-mode types are collapsed? Date: Thu, 06 Oct 2022 09:22: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: unknown X-Bugzilla-Keywords: alias, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth 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: 10.5 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107107 --- Comment #9 from Richard Biener --- The issue is how we value-number for tail-merging. We do Processing block 1: BB4 Value numbering stmt =3D MEM[(long int *)_3] =3D 2; RHS 2 simplified to 2 No store match Value numbering store MEM[(long int *)_3] to 2 Setting value number of .MEM_12 to .MEM_12 (changed) marking outgoing edge 4 -> 5 executable Processing block 2: BB3 Value numbering stmt =3D *_3 =3D 2; RHS 2 simplified to 2 Setting value number of .MEM_11 to .MEM_12 (changed) marking outgoing edge 3 -> 5 executable Processing block 3: BB5 Value numbering stmt =3D .MEM_10 =3D PHI <.MEM_11(3), .MEM_12(4)> Setting value number of .MEM_10 to .MEM_12 (changed) Value numbering stmt =3D _9 =3D *p_5(D); Setting value number of _9 to 1 (changed) oops. So we figure that the two stores from '2' are "redundant" which caus= es us to only consider one (the wrong one) when later looking up *p_5(D). That's if (!resultsame) { /* Only perform the following when being called from PRE which embeds tail merging. */ if (default_vn_walk_kind =3D=3D VN_WALK) { assign =3D build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, op); vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult, false); if (vnresult) { VN_INFO (vdef)->visited =3D true; return set_ssa_val_to (vdef, vnresult->result_vdef); } that's a case I never understood fully (and that seems wrong). That visited flag set is also odd. I'm testing a patch.=