From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 51E23385770B; Fri, 30 Jun 2023 13:53:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 51E23385770B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688133182; bh=5uYF2sBXipF1m5zErazHrTGItkxo+ATLqEjkNxN7/Ps=; h=From:To:Subject:Date:From; b=VfV1o1P/bqYR5n+e8cyks1c4LYgVef60SVez9ZkgVs6a55uMN/bqEdABxYlNNi/MK GI0zpbbldjf2gPQVQ7QoQlQpOPYJZzpex+XT6FQpJ8MOxMyocFkVFUe8Xa5F3ucGCt 5pi+ZfB5mAm1sbss2vOzMRIPYaL1kkskchSzYPy0= From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110499] New: malloc branch predictor is broken Date: Fri, 30 Jun 2023 13:53:01 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.1.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=3D110499 Bug ID: 110499 Summary: malloc branch predictor is broken Product: gcc Version: 13.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: hubicka at gcc dot gnu.org Target Milestone: --- Malloc branch predictor currently predicts that malloc() call likely return= s 1. This is good for NULL pointer checks, but not good for checking pointers for equality: #include void test() { if (malloc(10) =3D=3D malloc(20)) printf ("Impossible!\n"); } gets predicted as: void test () { void * _1; void * _2; [local count: 1073741824]: _1 =3D malloc (10); _2 =3D malloc (20); if (_1 =3D=3D _2) goto ; [99.96%] else goto ; [0.04%] [local count: 1073312329]: __builtin_puts (&"Impossible!"[0]); [local count: 1073741824]: return; } So we think that Impossible is output with 99.96 probability.=