Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2393025pxb; Tue, 13 Apr 2021 00:19:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmG8AV5qW6a6xH4zqN0KHpuvW8kkClxVppTBt8QqX7m1epCQ1M5dpavQDYpoph+nNuD0n+ X-Received: by 2002:a17:906:26c9:: with SMTP id u9mr30238633ejc.520.1618298356442; Tue, 13 Apr 2021 00:19:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618298356; cv=none; d=google.com; s=arc-20160816; b=0ONMs/sNpQdbNd6P4+hpNUHKHKfbSXBaB247HlVT/EUvAFa+ILJFJHTBsz0YbtWiyI pBYRGJbbd355rmw/BnRjsDbFw4b8cz85+EyKKB1tTHQRexlKTsTLJqaIwmus+cVyPqvz 5FvWGw8uOmKlFbxJoWyzGxlhxyew3m9xyTjrhImvx1c8Yvk7AfsjhM2d7QNrQpv1svMh 2YECHB1rrhuYKAMPtHIkDzNgiylgDp4yrc21xpC8+RRn12jRtxzjmSA0luAZ6FEduVm/ JwXXtBykqsnnJaM0bfr6CZAyYwheJMIpoF+L09LqYuP/BQJDw5kQVik1vCCaVRVKApk/ sV0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=6t7Sch3/IhIWwGGheDImNd83APnPGXLuiRWBsVo5IUw=; b=sghvEv3eVUSk6O+/ngbPjkPKWd93H4ktDx1Ifv2ML7dShXperSMuYaA2g7nlnq4hx7 1EMxzZ5jmvRH7nqY8yhv9QxjYXyYSm1XEkdqNmt/AiRVeFPbDIgdxWKOxilUG+r3UYe1 5f+I334LC/c4LZ4PD0qMXtytLOlyvSoEISSp7hx7ZmMt5D7bmwkvts5F3R7HMEHuJ6sD 7OzUD4TVHUKx8te1H6pkwnHllJ+VKkJY+2Ruwv0WRx1hj0q+zows8BTFyGfOX6y2JHZA vFBVPatJlKAlPBXKwR5QoPlS1zmqcI6TfNSNAryFr2Kj21WMdrq13TZo5RlmjUI/psIH r6Lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si9948778ejc.46.2021.04.13.00.18.51; Tue, 13 Apr 2021 00:19:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244225AbhDLWA3 (ORCPT + 99 others); Mon, 12 Apr 2021 18:00:29 -0400 Received: from gate.crashing.org ([63.228.1.57]:54271 "EHLO gate.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238235AbhDLWA1 (ORCPT ); Mon, 12 Apr 2021 18:00:27 -0400 Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 13CLsVAn011590; Mon, 12 Apr 2021 16:54:31 -0500 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 13CLsTMj011588; Mon, 12 Apr 2021 16:54:29 -0500 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Mon, 12 Apr 2021 16:54:28 -0500 From: Segher Boessenkool To: Christophe Leroy Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/2] powerpc/bitops: Use immediate operand when possible Message-ID: <20210412215428.GM26583@gate.crashing.org> References: <09da6fec57792d6559d1ea64e00be9870b02dab4.1617896018.git.christophe.leroy@csgroup.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <09da6fec57792d6559d1ea64e00be9870b02dab4.1617896018.git.christophe.leroy@csgroup.eu> User-Agent: Mutt/1.4.2.3i Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi! On Thu, Apr 08, 2021 at 03:33:44PM +0000, Christophe Leroy wrote: > For clear bits, on 32 bits 'rlwinm' can be used instead or 'andc' for > when all bits to be cleared are consecutive. Also on 64-bits, as long as both the top and bottom bits are in the low 32-bit half (for 32 bit mode, it can wrap as well). > For the time being only > handle the single bit case, which we detect by checking whether the > mask is a power of two. You could look at rs6000_is_valid_mask in GCC: used by rs6000_is_valid_and_mask immediately after it. You probably want to allow only rlwinm in your case, and please note this checks if something is a valid mask, not the inverse of a valid mask (as you want here). So yes this is pretty involved :-) Your patch looks good btw. But please use "n", not "i", as constraint? Segher