From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 74ACD385B530; Mon, 6 Mar 2023 05:26:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74ACD385B530 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678080397; bh=MtYX5gV8Vez8r1T53tT4sb/2vHKREXVHQi+raqMmgxE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lP4Dr5TR1EfrAP+XC5N/PpF750hodLZiR+HV96akSyRVUaP2PT4VJXm6CZ3n7T38Q 7E51efOq3i2Rw10LZYrbtj2T8lLDFpZ2lEexs779FY7Fgysg8DuQGSU4BzLybT3Q5t kcmqBOPRpwAFPCJqIO1r13KgHploXInxzKnI7or0= From: "crazylht at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109011] missed optimization in presence of __builtin_ctz Date: Mon, 06 Mar 2023 05:26:35 +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: crazylht at gmail dot com 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 #11 from Hongtao.liu --- (In reply to Jakub Jelinek from comment #3) > Seems they are vectorizing __builtin_ctz (x) as bitsize - .CLZ ((x - 1) & > ~x) for CLZ_DEFINED_VALUE_AT_ZERO 2 with value bitsize. > Perhaps we should pattern match it in tree-vect-patterns.cc that way if c= lz > is vectorizable (it is with -mavx512cd) and ctz is not. Yes, I'm going to add a pattern match named vect_recog_ctz_as_clz_or_popcnt. BTW, It looks like only x86 have vector clz but not ctz, for other targets, they either have both or neither.=