[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YZT4sdwf25XV6pKu@smile.fi.intel.com>
Date: Wed, 17 Nov 2021 14:42:25 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Florian Fainelli <f.fainelli@...il.com>
Cc: bcm-kernel-feedback-list@...adcom.com,
linux-rpi-kernel@...ts.infradead.org,
linux-arm-kernel@...ts.infradead.org, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, Jim Quinlan <jim2101024@...il.com>,
Nicolas Saenz Julienne <nsaenz@...nel.org>,
Lorenzo Pieralisi <lorenzo.pieralisi@....com>,
Rob Herring <robh@...nel.org>,
Krzysztof WilczyĆski <kw@...ux.com>,
Bjorn Helgaas <bhelgaas@...gle.com>
Subject: Re: [PATCH v2 1/1] PCI: brcmstb: Use BIT() as __GENMASK() is for
internal use only
On Tue, Nov 16, 2021 at 12:38:39PM -0800, Florian Fainelli wrote:
> On 11/15/21 3:20 AM, Andy Shevchenko wrote:
> > Use BIT() as __GENMASK() is for internal use only. The rationale
> > of switching to BIT() is to provide better generated code. The
> > GENMASK() against non-constant numbers may produce an ugly assembler
> > code. On contrary the BIT() is simply converted to corresponding shift
> > operation.
>
> The code is not necessarily any different on ARMv8 as far as I can tell,
> before:
>
> static void brcm_msi_set_regs(struct brcm_msi *msi)
> {
> u32 val = __GENMASK(31, msi->legacy_shift);
> 84: b9406402 ldr w2, [x0,#100]
> 88: d2800021 mov x1, #0x1
> // #1
> 8c: 9ac22021 lsl x1, x1, x2
> 90: 4b0103e1 neg w1, w1
>
>
> after:
>
> static void brcm_msi_set_regs(struct brcm_msi *msi)
> {
> u32 val = ~(BIT(msi->legacy_shift) - 1);
> 84: b9406402 ldr w2, [x0,#100]
> 88: d2800021 mov x1, #0x1
> // #1
> 8c: 9ac22021 lsl x1, x1, x2
> 90: 4b0103e1 neg w1, w1
>
> and the usage of BIT() does not make this any clearer.
While I disagree on the conclusion it's good that assembly isn't bad.
Last time I have tried to compile just GENMASK() excerpts for arm32
the non-constant variants were quite bad. And it was obvious win for
BIT() over GENMASK().
Actually it maybe that I have tested something like
`GENMASK(C1 + var, C2 + var)` vs. `GENMASK(C1, C2) << var`
that time.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists