From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ADA1B3858D37; Mon, 26 Sep 2022 20:10:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADA1B3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1664223020; bh=Q8CzZ1VYozq9kwlMXb5Ap9ZdSVBUhfvDlwaQX6ZJSd8=; h=From:To:Subject:Date:From; b=rE+PdFaZLoHhXK0v+F+7Ywto85oej5w2yusEkzgCpOCZh7F6IQbGjRX8dvXIpzr9u SG0lnvvrT+nxGfX3Sy7VOj3Ow8BOLbPE6f1kA6jMkICFVXHoJp2zqMzarGcLSvg4G9 4RbS0A0VxWZVIeT8hAziELtst3uw+tIQ5aJ/K3xk= From: "drepper.fsp+rhbz at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107043] New: range information not used in popcount Date: Mon, 26 Sep 2022 20:10:20 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: drepper.fsp+rhbz at gmail dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D107043 Bug ID: 107043 Summary: range information not used in popcount Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: drepper.fsp+rhbz at gmail dot com Target Milestone: --- This code could be compiled to a simple return of the value 1 but it isn't because the range information for n does not survive long enough. int g(int n) { n &=3D 0x8000; if (n =3D=3D 0) return 1; return __builtin_popcount(n); } The code generated today is lengthy: 0: 81 e7 00 80 00 00 and $0x8000,%edi 6: ba 01 00 00 00 mov $0x1,%edx b: 89 f8 mov %edi,%eax d: c1 e8 0f shr $0xf,%eax 10: 85 ff test %edi,%edi 12: 0f 44 c2 cmove %edx,%eax 15: c3 ret=