From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 148D53870878; Wed, 21 Oct 2020 08:54:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 148D53870878 From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/97503] Suboptimal use of cntlzw and cntlzd Date: Wed, 21 Oct 2020 08:54:54 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.1.1 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Oct 2020 08:54:55 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97503 --- Comment #3 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:5244b4af5e47bc98a2a9cf36f048981583a1b163 commit r11-4183-g5244b4af5e47bc98a2a9cf36f048981583a1b163 Author: Jakub Jelinek Date: Wed Oct 21 10:51:33 2020 +0200 phiopt: Optimize x ? __builtin_clz (x) : 32 in GIMPLE [PR97503] While we have at the RTL level noce_try_ifelse_collapse combined with simplify_cond_clz_ctz, that optimization doesn't always trigger because e.g. on powerpc there is an define_insn to compare a reg against zero a= nd copy that register to another one and so we end up with a different pse= udo in the simplify_cond_clz_ctz test and punt. For targets that define C?Z_DEFINED_VALUE_AT_ZERO to 2 for certain mode= s, we can optimize it already in phiopt though, just need to ensure that we transform the __builtin_c?z* calls into .C?Z ifns because my recent VRP changes codified that the builtin calls are always undefined at zer= o, while ifns honor C?Z_DEFINED_VALUE_AT_ZERO equal to 2. And, in phiopt we already have popcount handling that does pretty much = the same thing, except for always using a zero value rather than the one set by C?Z_DEFINED_VALUE_AT_ZERO. So, this patch extends that function to handle not just popcount, but a= lso clz and ctz. 2020-10-21 Jakub Jelinek PR tree-optimization/97503 * tree-ssa-phiopt.c: Include internal-fn.h. (cond_removal_in_popcount_pattern): Rename to ... (cond_removal_in_popcount_clz_ctz_pattern): ... this. Handle n= ot just popcount, but also clz and ctz if it has C?Z_DEFINED_VALUE_AT_Z= ERO 2. * gcc.dg/tree-ssa/pr97503.c: New test.=