lkml.org 
[lkml]   [2021]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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


\
 
 \ /
  Last update: 2021-11-17 13:43    [W:0.105 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site