From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7BA7D3858C24; Mon, 4 Mar 2024 22:58:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7BA7D3858C24 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709593104; bh=FT714lmaQd8ct3kLvK8tFuMX7gyjFzsfPqCKqQ7x1Zk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LD21UEARXL45/OUvx7Eaq9QAtSqNCfDxDOmeYswIeJ9cQ0Lxc39XEtEqSh/i5IW3y TgTeZW2ZPFENFet9PrtxuwRoX5KVNvkOsnBQaeVzhYE3rnOeRpC/L/6gxQEhH6WUR4 GUjKbs1Q9n80V1WHT0QAOViAjYBom7lMt4nsHdtA= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/106727] Missed fold / canonicalization for checking if a number is a power of 2 Date: Mon, 04 Mar 2024 22:58:23 +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: 12.1.1 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: pinskia 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=3D106727 --- Comment #3 from Andrew Pinski --- (In reply to Richard Biener from comment #1) > Confirmed. Expanding __builtin_popcount (n) <=3D 1 as (n & (n - 1)) =3D= =3D 0 > might be already done. The canonicalization could be applied if .POPCOUNT > is available. No, it is not already done, expanding `__builtin_popcount (n) =3D=3D 1` is = done (and including if n is known not to include 0 which is exapnded as `n & (n = - 1) =3D=3D 0`)=