From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 10899383A629 for ; Mon, 20 Nov 2023 08:39:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10899383A629 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 10899383A629 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700469585; cv=none; b=GRLurEzPYvA4li4VEZw01Yg5y+aZ1kXK3X+c8T5obwJs5FDH4VVZWNtnUNId+cdw0zc4cUQriXIWTNMPMY2OUD5bQYDp275+V7zZJx7ybGZ83h1dBGGdjllC3yjTsCV1XX72ZSJOIzo8xffMXyJEjaEGKe9JTmlHirefj7jnP38= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700469585; c=relaxed/simple; bh=1AJBcT1Vb1w0H06hMvomvcjvW0XRUXgDbzoNGWWHDrc=; h=DKIM-Signature:DKIM-Signature:Date:From:To:Subject:Message-ID: MIME-Version; b=tYqPEXilo24dhnMVWtJ5WynFBP9SaIVURR4QKxAzNjTGOa+5RlmaaAV1+R7aZQwxz3HBKUG0hvxV1kOg1rwBaTjNXDho3XFIFFr432uayVlPvN9ZWmReNwHTT8p9lPTPCegdLGemmmwnCYzQhQCbiuugG2ib4lKam946BMwL8ZQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 1B519218B1; Mon, 20 Nov 2023 08:39:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1700469583; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g8/zg5Hok64UadmiB9I9ZUsuLMz4RLN++y3+4Akxjmw=; b=wSHtXURD8Su4eMl5GtW6i4Fl3WrWHNvir/15WLc03i3da3CpNaugISrRsGO9D1tuq8JKUU jsKSVHeYxovsxJDfxZW/pnSFFVZuyhmEj8lfRZ//rDuLETj0PS9M6CoiqGDVMj13/Kuzmm HKEMbfN+goEXy+9dhbNdH301ojbnz4c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1700469583; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=g8/zg5Hok64UadmiB9I9ZUsuLMz4RLN++y3+4Akxjmw=; b=MJt2ar3D5AhIxf+z5VuFdyVPw+HC7uXYplapL3709+WfgV7ja8e3IALrIRc0qGNeUWBp3n TRapNEMotmGmUMAg== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 0C35F2CA2E; Mon, 20 Nov 2023 08:39:43 +0000 (UTC) Date: Mon, 20 Nov 2023 08:39:42 +0000 (UTC) From: Richard Biener To: Jakub Jelinek cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693] In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spamd-Bar: ++++++++++++++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd1 X-Spamd-Result: default: False [16.78 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_SPAM_SHORT(3.00)[1.000]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(1.20)[suse.de]; RWL_MAILSPIKE_GOOD(-1.00)[149.44.160.134:from]; R_SPF_SOFTFAIL(4.60)[~all]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWO(0.00)[2]; VIOLATED_DIRECT_SPF(3.50)[]; NEURAL_SPAM_LONG(3.50)[1.000]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(2.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-0.21)[71.70%] X-Spam-Score: 16.78 X-Rspamd-Queue-Id: 1B519218B1 X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 20 Nov 2023, Jakub Jelinek wrote: > On Mon, Nov 20, 2023 at 07:54:54AM +0000, Richard Biener wrote: > > On Fri, 17 Nov 2023, Jakub Jelinek wrote: > > > Per the earlier discussions on this PR, the following patch folds > > > popcount (x) == 1 (and != 1) into (x ^ (x - 1)) > x - 1 (or <=) > > > if the corresponding popcount optab isn't implemented (I think any > > > double-word popcount or call will be necessarily slower than the > > > above cheap 3 op check and even for -Os larger or same size). > > > > > > I've noticed e.g. C++ aligned new starts with std::has_single_bit > > > which does popcount (x) == 1. > > > > > > As a follow-up, I'm considering changing in this routine the popcount > > > call to IFN_POPCOUNT with 2 arguments and during expansion test costs. > > > > > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > > > Classically this would have been an RTL expansion alternative, given > > we want to do less of those the next place would have been the ISEL > > pass. Any particular reason you chose widening-mul for this (guess > > that pass just has a bad name and it's the effective "optimize" ISEL pass > > we have). > > I think the ssa-math-opts pass does far more of this staff than the isel > pass which only deals with vector stuff right now and you've even mentioned > that pass for that in the PR90693 thread. > That said, I can move it into the isel pass as well if you prefer that. I think it's fine as you posted (and Jeff approved), I'm just wondering if we should rename that pass somehow ;) Note ISEL is more for required pre-expansion stuff and widen-mul is for expansion related but optimization parts. Richard.