From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 738113858D37; Thu, 2 Mar 2023 22:51:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 738113858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677797497; bh=a6K78C50Tl6gmBi6nwV16xpLqgmn0Q3h0rJtaAR7ihQ=; h=From:To:Subject:Date:From; b=Lu0FNzovr1QAhMzxM8LXwWIxNBA+Z3P8OzHE8MiLnWwTnjroYTacYh2S/al0quHzD SXXa/TLwjwkdefq+AqgkVqswHP+4amU5IDsYRkZCmE6gbLwXWZowZzP3fjsRPgQK0r S6nf+TgoWktP0tbxuNq+RtOpVDYiExik5XkTL9hI= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/108997] New: GCC prediction on bool comparisons seems wrong Date: Thu, 02 Mar 2023 22:51:37 +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.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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 keywords 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=3D108997 Bug ID: 108997 Summary: GCC prediction on bool comparisons seems wrong Product: gcc Version: 13.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- I noticed this while looking into 108992. I suspect we look into this but I am not 100% sure this is a bug. Testcase: void use(int *); void use2(int *); void foo(bool cond, int * p) { if (cond) { use(p); } use2(p); } GCC predicts the branch to be taken 66% of the time, but I would have assum= e it should be 50% as it is a bool and there is no other information. I suspect = this is due to prediction when comparing against 0.=