All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: bcm-kernel-feedback-list@broadcom.com,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Jim Quinlan" <jim2101024@gmail.com>,
	"Nicolas Saenz Julienne" <nsaenz@kernel.org>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>
Subject: Re: [PATCH v2 1/1] PCI: brcmstb: Use BIT() as __GENMASK() is for internal use only
Date: Wed, 17 Nov 2021 14:42:25 +0200	[thread overview]
Message-ID: <YZT4sdwf25XV6pKu@smile.fi.intel.com> (raw)
In-Reply-To: <41b85802-6118-33a6-692a-043d74b82d8e@gmail.com>

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



WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: bcm-kernel-feedback-list@broadcom.com,
	linux-rpi-kernel@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Jim Quinlan" <jim2101024@gmail.com>,
	"Nicolas Saenz Julienne" <nsaenz@kernel.org>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Bjorn Helgaas" <bhelgaas@google.com>
Subject: Re: [PATCH v2 1/1] PCI: brcmstb: Use BIT() as __GENMASK() is for internal use only
Date: Wed, 17 Nov 2021 14:42:25 +0200	[thread overview]
Message-ID: <YZT4sdwf25XV6pKu@smile.fi.intel.com> (raw)
In-Reply-To: <41b85802-6118-33a6-692a-043d74b82d8e@gmail.com>

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



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-11-17 12:42 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15 11:20 [PATCH v2 1/1] PCI: brcmstb: Use BIT() as __GENMASK() is for internal use only Andy Shevchenko
2021-11-15 11:20 ` Andy Shevchenko
2021-11-15 11:57 ` Krzysztof Wilczyński
2021-11-15 11:57   ` Krzysztof Wilczyński
2021-11-15 13:59 ` Robin Murphy
2021-11-15 13:59   ` Robin Murphy
2021-11-15 14:14   ` Andy Shevchenko
2021-11-15 14:14     ` Andy Shevchenko
2021-11-15 14:39     ` Andy Shevchenko
2021-11-15 14:39       ` Andy Shevchenko
2021-11-16 18:20       ` Rob Herring
2021-11-16 18:20         ` Rob Herring
2021-11-16 20:41         ` Florian Fainelli
2021-11-16 20:41           ` Florian Fainelli
2021-11-16 20:56           ` Florian Fainelli
2021-11-16 20:56             ` Florian Fainelli
2021-11-17 10:37             ` Andy Shevchenko
2021-11-17 10:37               ` Andy Shevchenko
2021-11-17 22:46             ` Rob Herring
2021-11-17 22:46               ` Rob Herring
2021-11-16 20:38 ` Florian Fainelli
2021-11-16 20:38   ` Florian Fainelli
2021-11-17 12:42   ` Andy Shevchenko [this message]
2021-11-17 12:42     ` Andy Shevchenko
2021-12-01 15:53 ` Lorenzo Pieralisi
2021-12-01 15:53   ` Lorenzo Pieralisi
2021-12-01 16:01   ` Andy Shevchenko
2021-12-01 16:01     ` Andy Shevchenko
2021-12-01 17:13     ` Lorenzo Pieralisi
2021-12-01 17:13       ` Lorenzo Pieralisi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZT4sdwf25XV6pKu@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=jim2101024@gmail.com \
    --cc=kw@linux.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-rpi-kernel@lists.infradead.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=nsaenz@kernel.org \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.