From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 22A073858CDB; Thu, 2 Mar 2023 23:24:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22A073858CDB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677799466; bh=eOVcyAmK1bsdgYcrT+ECbeRR7qC17fe7rhtGkbm2nWk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dxoQFac1sE2hnPbJCT8uKjiqT/SL4r0t6mwLLAZ8MzbM1aKgf0+7UA9RMbj6eKKzi Z0IUBdYFiomIGofPh5yccf2DiNzIx6yTaRBPmIA8aFlKhNYxIYKsvbBNPdghOSq4Ro l8AN4UIS0j0FlDgwc10tSOXqDuJJbE4t5scS7Mqo= From: "nok.raven at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/108992] Regression: Branch direction canonicalization leads to pointless tail duplication / CSE/sinking by inverting branch Date: Thu, 02 Mar 2023 23:24:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 6.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: nok.raven at gmail dot com X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: INVALID 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: 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=3D108992 --- Comment #6 from Nikita Kniazev --- > Did you see this in real code or you just noticed this while looking at c= ode generation? If you mean do I have any benchmark - unfortunately no. I noticed it for a while by poking different code to compare Clang codegen to GCC. > In the first case GCC predicts that the cond is going to be true 66% of t= he time The 66% thing is what I also noticed for a while. > because there is comparison against 0 prediction going in the heurstics. The duplication happens even if I make cond int and compare with any other value void use(int *); void use2(int *); void foo(int * p, int cond) { if (cond =3D=3D 789) { use(p); } use2(p); }=