From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qLQsr-004WUc-01 for linux-arm-kernel@lists.infradead.org; Mon, 17 Jul 2023 16:15:38 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-666ecf9a0ceso3108940b3a.2 for ; Mon, 17 Jul 2023 09:15:36 -0700 (PDT) Date: Mon, 17 Jul 2023 09:15:34 -0700 From: Yury Norov Subject: Re: [PATCH v3 1/5] lib/bitmap: add bitmap_{set,get}_value() Message-ID: References: <20230717113709.328671-1-glider@google.com> <20230717113709.328671-2-glider@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+lwn-linux-arm-kernel=archive.lwn.net@lists.infradead.org List-Archive: To: Andy Shevchenko Cc: catalin.marinas@arm.com, will@kernel.org, pcc@google.com, andreyknvl@gmail.com, linux@rasmusvillemoes.dk, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, eugenis@google.com, syednwaris@gmail.com, william.gray@linaro.org, Arnd Bergmann On Mon, Jul 17, 2023 at 05:31:44PM +0300, Andy Shevchenko wrote: > On Mon, Jul 17, 2023 at 05:29:12PM +0300, Andy Shevchenko wrote: > > On Mon, Jul 17, 2023 at 04:14:57PM +0200, Alexander Potapenko wrote: > > ... > > > > > > + map[index] &= ~(GENMASK(nbits + offset - 1, offset)); > > > > > > > > I remember that this construction may bring horrible code on some architectures > > > > with some version(s) of the compiler (*). > > > > > > Wow, even the trunk Clang and GCC seem to generate better code for > > > your version of this line: https://godbolt.org/z/36Kqxhe6j > > > > Wow, indeed! Perhaps time to report to clang and GCC people. I believe the root > > cause is that in the original version compiler can't prove that l is constant > > for GENMASK(). > > > > > > To fix that I found an easy refactoring: > > > > > > > > map[index] &= ~(GENMASK(nbits, 0) << offset)); > > nbits - 1 it should be, btw. In any case it seems the code is still better. Yep. Alexander, for the next round can you please show disassembly for the functions in case of compile-time and run-time defined start and nbits? Thanks, Yury _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel