From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B1D2C3858C78; Wed, 29 May 2024 14:11:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B1D2C3858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716991889; bh=c362X6VoMojqJMtVdXpF5VXfmIYFOp5cs/KdLHhRxKk=; h=From:To:Subject:Date:From; b=kz9P50cwq+eB4R4KhniVWHxSQ+EcMePxrVwCJ/RIXItELvhRb+MS+icKoC/TGMMds pbKkMoge+imEHCd5ZiHabyJ7PjVeUn4NXyYUHC/tTS+z9COy4+JxMZMfyKPJq9KPaC Xogn0rvM5e7WJdcId75Uvm/IZyR7eF4rFY2cZxzE= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/115277] New: ICF needs to match loop bound estimates Date: Wed, 29 May 2024 14:11:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D115277 Bug ID: 115277 Summary: ICF needs to match loop bound estimates Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- jan@localhost:/tmp> cat tt.c int array[1000]; void test (int a) { if (__builtin_expect (a > 3, 1)) return; for (int i =3D 0; i < a; i++) array[i]=3Di; } void test2 (int a) { if (__builtin_expect (a > 10, 1)) return; for (int i =3D 0; i < a; i++) array[i]=3Di; } int main() { test(1); test(2); test(3); test2(10); if (array[9] !=3D 9) __builtin_abort (); return 0; } jan@localhost:/tmp> gcc -O2 tt.c ; ./a.out jan@localhost:/tmp> gcc -O3 tt.c ; ./a.out Aborted (core dumped) The problem here is that we do not match value ranges and thus we can end up with different estimates on number of iterations.=