From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5CDE93858C42; Sun, 7 Jan 2024 12:56:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5CDE93858C42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704632210; bh=wl17GBeTh6NF78oAnFg2jMsZJ46OcnWlwHuxSfavqgY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XyqJTCA4l8Qg3jXP0fSlTjF57ZIu+aTKapb12yiStKAXAgg+Kqk4Uh6c0oU3tBiTn H8wWPfVTa/+lnowoLxJ6/QR32OWNbN/BTVnALdEK7szR4JWNQONtDFoQDdNVWxaOQ0 62VvgrSq33XQ9zRvQ4hJ0V+yOZMD77nN/7HuMB0U= From: "piotrsiupa at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/90693] Missing popcount simplifications Date: Sun, 07 Jan 2024 12:56:48 +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: 10.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: piotrsiupa at gmail dot com X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: wilco 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=3D90693 --- Comment #11 from Piotr Siupa --- Thanks! Now the generated assembly is one instruction shorter. It works for: bool foo(unsigned x) { [[assume(x !=3D 0)]]; return std::has_single_bit(x); } and for: bool foo(unsigned x) { if (x =3D=3D 0) std::unreachable(); else return std::has_single_bit(x); } However, I've noticed that: bool foo(unsigned x) { if (x =3D=3D 0) return true; else return std::has_single_bit(x); } still uses (X ^ (X - 1)) > (X - 1).=