From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by sourceware.org (Postfix) with ESMTPS id 25F303858C33 for ; Mon, 20 Nov 2023 13:03:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 25F303858C33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 25F303858C33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::233 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700485421; cv=none; b=qcPwnEhsOpsT6iAueTbWEfRtoKFnklsXlFf3Y6E0aZp9v6dFM0pvKlMTYzomy0yJqyQYTZksJuY36PItdTbnl48Xk9pSWixbAH1zHQDlN8kla6jl52yt6bfENe0rEpEKuys0Sh6yrEpAtKYuSnny8qKp1dhjPTCcPwVXQpRHnEc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700485421; c=relaxed/simple; bh=Cjaiy/pYmZYEED5WRNklUvc2gLjYuxvgzdRxBvc/Z18=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ICqhQlgyL6F9kJPixYkOPY3E/2qaYMIEJn63xjGl+FhMtI/32mGhEQv1zhOGgrYR3JrJJXK0J4uwsc4/w392tS5e/eZdly5/nJk8HNbH5/9lIJYib4meztySfZKCyeoxtQBj7R8LGZTrg3so9zvUdT0YdRD68LHL29Y8cEJNxSg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oi1-x233.google.com with SMTP id 5614622812f47-3b52360cdf0so2074116b6e.2 for ; Mon, 20 Nov 2023 05:03:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700485419; x=1701090219; darn=gcc.gnu.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=z8VjjCR7FbGfJNvRgMCQowwC9fPc90nzydefgoBjAEE=; b=b6JexWJBWlSPXAtOenCuZ+o2bpAA0JgXxc0y2E5CXpfYuVDND5uvyufHxxVelQciHr FM1j7Gnt7+8T3kSOJ9yDCPCQ1RaCWKdKFuS1ZtR7Cc7PmTKGVO5DnkTCR75i3t025cgn o43FUf33RMkpPNmzahGp22k4rVCEt495Zdzr2RJnteEOB4kgXnjoaK1jrIgM7WK4/zzM 6496XJWZ0YaeYkDT/l+DfjddtrDz1/aIVmUl9GL1sCrhvlMYm91XfeMD01sWldQ5t+z3 NsvVvPMgHjCTS6fWC/IZSw0MTqeNm5/XxdC38+ZR/OmOXF1GibJNWdkd2ZUn0ANbyykD ddxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700485419; x=1701090219; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=z8VjjCR7FbGfJNvRgMCQowwC9fPc90nzydefgoBjAEE=; b=P+tic2a83Ty//bW+/0eYj+IF4Tii2w/XA8faoQM1Jks5JXkzEeljRVT/bIy6Kl1xF3 e5hcJ5tfTwXdukS7OTBBNMUahgpu96E5nxK82MST6LrOvmq5wDUfgC7D11IGPQdy/JCz +nymKCKwkd3CM01e7hz5V3X3ZVIODwBGiIPuTYWCrYSezXfX+le4yXEoGpgXYmwwqR+9 EWNzPFKIrZn8yYaGMtCOAKh24r64mUa1atRrrHcluWiiuCqii7dnNeZNCB8gvVsirWMu YJVcsE4/X6alH1U+B6ij0KgsQdiLdvy0y5UCipk8WHLsylfPjxZSSsrq4wfmTMN5sfng Bytg== X-Gm-Message-State: AOJu0YzcX6AeQaL6xt4gRG3MIyV/sGfkH4lawlznUH9tvTfHS6vJdK4h u485l2AjTpApKJFZAnbSNqE= X-Google-Smtp-Source: AGHT+IHA9esCUD8gCfqxS/ztU9bj9ijn0O4fACOeWj5s++bhesSn917zwpktOeOaiHMst3adBWtdwQ== X-Received: by 2002:a05:6808:992:b0:3b2:e34f:349b with SMTP id a18-20020a056808099200b003b2e34f349bmr6132834oic.42.1700485419286; Mon, 20 Nov 2023 05:03:39 -0800 (PST) Received: from [172.31.0.109] ([136.36.130.248]) by smtp.gmail.com with ESMTPSA id dl1-20020a056808614100b003ae0e57874fsm1251029oib.21.2023.11.20.05.03.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Nov 2023 05:03:38 -0800 (PST) Message-ID: <8a6a139c-e432-4c15-85c6-3362b277ca2a@gmail.com> Date: Mon, 20 Nov 2023 06:03:37 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] tree-ssa-math-opts: popcount (X) == 1 to (X ^ (X - 1)) > (X - 1) optimization [PR90693] Content-Language: en-US To: Richard Biener , Jakub Jelinek Cc: gcc-patches@gcc.gnu.org References: From: Jeff Law In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 11/20/23 01:39, Richard Biener wrote: > 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. Yea, a rename seems appropriate given how much stuff in there is no longer math-ops related :-) jeff