From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 04570385734B; Thu, 20 Apr 2023 17:45:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 04570385734B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682012745; bh=oiXmNwwjWLqAYk6NpcUcjkN3kDD7emVWX//EM6JJHJs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sMfn05zluopGGL0/N5M8Z2aJSIJOr4eBm0SmC+Yy3KUxLH3N8ABPuwvVTqeGP57HU gZwoKDHZKa/7qi6YKaLIIcLmnrFjd/6QPzJJP0DxelvSof8UV5vAdgewT4PpDoMdHO oCWU0CEK+SxT8KQSdqci7ujpx2zqgVsZhVzSLuEk= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109011] missed optimization in presence of __builtin_ctz Date: Thu, 20 Apr 2023 17:45:43 +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.2.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: jakub 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=3D109011 --- Comment #22 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:87c9bae4e32b54829dce0a93ff735412d5f684f8 commit r14-121-g87c9bae4e32b54829dce0a93ff735412d5f684f8 Author: Jakub Jelinek Date: Thu Apr 20 19:44:27 2023 +0200 tree-vect-patterns: One small vect_recog_ctz_ffs_pattern tweak [PR10901= 1] I've noticed I've made a typo, ifn in this function this late is always only IFN_CTZ or IFN_FFS, never IFN_CLZ. Due to this typo, we weren't using the originally intended .CTZ (X) =3D .POPCOUNT ((X - 1) & ~X) but .CTZ (X) =3D PREC - .POPCOUNT (X | -X) instead when we want to emit __builtin_ctz*/.CTZ using .POPCOUNT. Both compute the same value, both are defined at 0 with the same value (PREC), both have same number of GIMPLE statements, but I think the former ought to be preferred, because lots of targets have andn as a single operation rather than two, and also putting a -1 constant into a vector register is often cheaper than vector with broadcast PREC power of two value. 2023-04-20 Jakub Jelinek PR tree-optimization/109011 * tree-vect-patterns.cc (vect_recog_ctz_ffs_pattern): Use .CTZ (X) =3D .POPCOUNT ((X - 1) & ~X) in preference to .CTZ (X) =3D PREC - .POPCOUNT (X | -X).=