From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 73222385DC3A; Mon, 8 Jan 2024 08:11:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 73222385DC3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704701517; bh=ONSa01u6yZWVN/gC2kso63UyLFZ/ay1A9wNs4EFk32c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=J+60zDMpFBRMFhxVsofon0wj3CNzceLW2lLaagBQC5WgXGqr0ZipMnsLtgkEoAKsS DzGOUW9MaVdi7H8cklHwkK0bzTWkaSC8H/LE42PQaS9r2ASiHM8ynkYTAJ549iIS5t CQE9XMOdh9MjiakiGnx1AKnF9V8PHdJLITmYZefA= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113134] gcc does not version loops with early break conditions that don't have side-effects Date: Mon, 08 Jan 2024 08:11:54 +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: 14.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement 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=3D113134 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org --- Comment #18 from Richard Biener --- The loop is rotated by header copying and the "combined" exit test looks li= ke if (i_21 =3D=3D 1001) goto ; [1.00%] else goto ; [99.00%] [local count: 1004539166]: i_18 =3D i_21 + 1; if (N_13(D) > i_18) goto ; [94.50%] else goto ; [5.50%] this could be rewritten to use min(1002, N_13(D)) with the knowledge how 'i' evolves. We get i_21 !=3D 1001 || N_13(D) > (i_21 + 1) for the iterati= on condition which I think we cannot combine in general. The "easiest" way would be to have loop splitting split the loop on the i_21 =3D=3D 1001 condition I think.=