From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EAEB83858D28; Mon, 4 Mar 2024 16:41:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAEB83858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709570491; bh=Z6IhRM0fJ7IbcXdMyo6Oe4KIfXHo/5dNJvIb2xVbWLc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W9a5X+RXzhUXjzLeXpASf9zIFNW/QPs7+4wNc4WOcbWVPbnM+zVa+xTLPB21vs/LK 6pdulpy4olwbJPgfuBuL/gLffyeK10Trfi3LYRYlkTyn8oiHGhum5GNua3wnlxZaNc ECQ9B/etLHxNX3JOpARoUZx0roCBGI65mBznbFtQ= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/90693] Missing popcount simplifications Date: Mon, 04 Mar 2024 16:41:31 +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: pinskia at gcc dot gnu.org 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 #13 from Andrew Pinski --- (In reply to Andrew Pinski from comment #12) > (In reply to Piotr Siupa from comment #11) > > However, I've noticed that: > > bool foo(unsigned x) > > { > > if (x =3D=3D 0) > > return true; > > else > > return std::has_single_bit(x); > > } >=20 >=20 > Oh that is because expand does not use flow sensitive ranges/non-zero bits > there. There is talk about adding the ability for that but nothing has be= en > done yet. Well that also should be transformed into `__builtin_popcount(a) <=3D 1` wh= ich then gets expanded into `(v & (v - 1)) =3D=3D 0`. I will be handling both o= f those via PR 94787 .=