From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 275683858D20; Wed, 9 Nov 2022 08:17:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 275683858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667981829; bh=PTx3p0AyMvXIkdNjl1m+oeLxhAiXdf1a826q4et4Ers=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SuZI/AzBDTwXW2188YJoKYdnKadLaLLkLsRNl6+CSEfbVlAbgUfi5Fw5G5vPx2e4d LbBOzHQsGIbr/jQftrEZu5y4o9IATi3+ziRemC4W7oC5Hl9FBF9mEzgS0N9j/DwS2i CTq/2ZmG2J4OLm2XaXhq4Vv2Qn2GJ/ThsmuAPqOo= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/84646] Missed optimisation for hoisting conditions outside nested loops Date: Wed, 09 Nov 2022 08:17:07 +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: 8.0.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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=3D84646 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |aldyh at gcc dot gnu.org --- Comment #3 from Richard Biener --- (In reply to Jeffrey A. Law from comment #2) > The backwards threader discovers the threads, but refuses to optimize them > because it thinks doing so will create an irreducible loop without enough > benefit. The reason is now: Checking profitability of path (backwards): bb:3 (2 insns) bb:7 (4 insns) = bb:6 (1 insns) (latch) bb:5 Control statement insns: 2 Overall: 5 insns Registering value_relation (path_oracle) (j_17 < m_23(D)) (root: bb5) path: 5->6->7->3->xx REJECTED (unreachable) it seems the path oracle is confused here. [local count: 955630225]: if (running_14 !=3D 0) goto ; [50.00%] else goto ; [50.00%] [local count: 477815112]: _1 =3D (long unsigned int) i_16; _2 =3D _1 * 4; _3 =3D p_25(D) + _2; _4 =3D *_3; _5 =3D (long unsigned int) j_17; _6 =3D _5 * 4; _7 =3D q_26(D) + _6; _8 =3D *_7; _9 =3D _4 * _8; sum_27 =3D _9 + sum_11; if (sum_27 > 19999) goto ; [50.00%] else goto ; [50.00%] [local count: 238907556]: [local count: 955630225]: # sum_10 =3D PHI # running_13 =3D PHI <0(3), 0(5), 1(4)> j_28 =3D j_17 + 1; [local count: 1073741824]: # sum_11 =3D PHI # running_14 =3D PHI # j_17 =3D PHI <0(11), j_28(6)> if (j_17 < m_23(D)) goto ; [89.00%] else goto ; [11.00%]=