From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 300323858D20; Tue, 15 Feb 2022 10:02:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 300323858D20 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/104543] [12 Regression] wrong code at -O3 on x86_64-linux-gnu Date: Tue, 15 Feb 2022 10:02:04 +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: needs-bisection, 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: 12.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status assigned_to 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: Tue, 15 Feb 2022 10:02:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104543 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot = gnu.org --- Comment #4 from Richard Biener --- The issue is that we call do_rpo_vn without having SSA form updated and thus we see [local count: 90350471]: # c.4_22 =3D PHI <0(4), _40(24)> _8 =3D a[c.4_22]; _9 =3D _8 ^ 1; a[c.4_22] =3D _9; _10 =3D c.4_22 + 1; [local count: 11166912]: _16 =3D 3; _12 =3D b.6_23 + 1; [local count: 11166912]: # b.6_33 =3D PHI <_12(20)> [local count: 90350471]: # c.4_35 =3D PHI _37 =3D a[c.4_35]; _38 =3D _37 ^ 1; a[c.4_35] =3D _38; _40 =3D c.4_35 + 1; if (_40 <=3D 2) goto ; [89.00%] else goto ; [11.00%] but I think the PHI use in bb 23 will be _10 after updating SSA. Though need_ssa_update_p is false - tree_unroll_loop will call update SSA. Ah, after unroll but before fuse we have [local count: 90350471]: # c.4_22 =3D PHI <_10(10), 0(4)> and [local count: 90350471]: # c.4_35 =3D PHI <0(22), _40(24)> we've changed how CFG copying may alter PHI args. fuse_loops does /* The PHI nodes of the second body (single-argument now) need adjustments to use the right values: either directly the value of the corresponding PHI in the first copy or the one leaving the first body which unrolling did for us. See also unroll_jam_possible_p() for further possibilities. */ gphi_iterator psi_first, psi_second; e =3D single_pred_edge (next->header); for (psi_first =3D gsi_start_phis (loop->header), psi_second =3D gsi_start_phis (next->header); !gsi_end_p (psi_first); gsi_next (&psi_first), gsi_next (&psi_second)) { that we can iterate PHI args in lock-step this way is not guaranteed.=