From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C127A3857C56; Tue, 27 Sep 2022 15:40:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C127A3857C56 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664293229; bh=zWXQpti116+D54TAVoCRJA69CdLVk4kXkImh7u5fs4Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=KmSKCUuCnZFk3xmZWmLp9UQ5PmUML5jNkpOW3UHbSBXTnGLlauQFNTjz3j7OcSeWh guanZLAiAd47Het1TutXy3H2V2YIPuWK4hrAjN9rFg4cFhrPRvuJZrpqb8k+h++/uq LAq5YluINhd0E1u0zJ3+irM5Aex8bD5BUWazOkx0= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107053] ones bits is not tracked and popcount is not tracked Date: Tue, 27 Sep 2022 15:40:29 +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: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: 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=3D107053 --- Comment #2 from Andrew Pinski --- Note the correct testcase is: void link_failure(); void f(int a) { a |=3D 0x300; int b =3D __builtin_popcount(a); if (b < 2) link_failure(); } --- CUT --- the range of b should be 2..31 (assuming int is 32bits). With this change clang is able to optimize it. For the original testcase I think it can be folded to: void link_failure(); void f(int a) { int a1 &=3D ~0x300; if (a1 !=3D 0) link_failure(); } but that might be worse unless popcount can be removed. (If I did this correctly).=