From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4B14C39BE816; Fri, 11 Jun 2021 09:08:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B14C39BE816 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/101025] [11/12 Regression] wrong code at -O3 on x86_64-linux-gnu Date: Fri, 11 Jun 2021 09:08:44 +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: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.2 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, 11 Jun 2021 09:08:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D101025 --- Comment #5 from Richard Biener --- The issue is with sm_seq_valid_bb which when processing store sequences from multiple branches of the CFG performs merging in a way that drops refs that still need to be considered for dependence queries. Notably /* Incrementally merge seqs into first_edge_seq. */ for (unsigned int i =3D 0; i < min_len; ++i)=20 { /* ??? We can more intelligently merge when we face different order by additional sinking operations in one sequence. For now we simply mark them as to be processed by the not order-preserving SM code. */ if (first_edge_seq[i].first !=3D edge_seq[i].first) { if (first_edge_seq[i].second =3D=3D sm_ord) bitmap_set_bit (refs_not_supported, first_edge_seq[i].first);=20 if (edge_seq[i].second =3D=3D sm_ord) bitmap_set_bit (refs_not_supported, edge_seq[i].fir= st); first_edge_seq[i].second =3D sm_other; first_edge_seq[i].from =3D NULL_TREE; we re matching f =3D{v} 0 against a[3] =3D ...;, marking 'f' as not support= ed for store-motion and to be dependence checked against all stores in the sequenc= e. But we simply forget about a[3] =3D ... which we'd need to insert somehow i= nto the sequence for dependence checking purposes similar to how we handle /* Any excess elements become sm_other since they are now coonditionally executed. */ if (first_edge_seq.length () > edge_seq.length ()) {=20=20=20=20=20 (but even that code looks suspicious). What we'd need to verify is that we can push the ref down in 'edge_seq' (but not actually do that) and then append it like the late loop (but we need to disambiguate against the stores in first_edge_seq as well). The code is quite complex and as it handles dependence queries incrementally it's also fragile...=