[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFnufp06+s43z5SxL48LB73=GdzYFiq578MCHZ_NMUNZkwdo9g@mail.gmail.com>
Date: Wed, 23 Jun 2021 00:53:35 +0200
From: Matteo Croce <mcroce@...ux.microsoft.com>
To: David Laight <David.Laight@...lab.com>
Cc: Christoph Hellwig <hch@...radead.org>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Atish Patra <atish.patra@....com>,
Emil Renner Berthing <kernel@...il.dk>,
Akira Tsukamoto <akira.tsukamoto@...il.com>,
Drew Fustini <drew@...gleboard.org>,
Bin Meng <bmeng.cn@...il.com>, Guo Ren <guoren@...nel.org>
Subject: Re: [PATCH v3 1/3] riscv: optimized memcpy
On Tue, Jun 22, 2021 at 10:19 AM David Laight <David.Laight@...lab.com> wrote:
>
> From: Christoph Hellwig
> > Sent: 21 June 2021 15:27
> ...
> > > + for (next = s.ulong[0]; count >= bytes_long + mask; count -= bytes_long) {
> >
> > Please avoid the pointlessly overlong line. And (just as a matter of
> > personal preference) I find for loop that don't actually use a single
> > iterator rather confusing. Wjy not simply:
> >
> > next = s.ulong[0];
> > while (count >= bytes_long + mask) {
> > ...
> > count -= bytes_long;
> > }
>
> My fist attack on long 'for' statements is just to move the
> initialisation to the previous line.
> Then make sure there is nothing in the comparison that needs
> to be calculated every iteration.
> I suspect you can subtract 'mask' from 'count'.
> Giving:
> count -= mask;
> next = s.ulong[0];
> for (;; count > bytes_long; count -= bytes_long) {
>
This way we'll lose the remainder, as count is used at the end to copy
the leftover.
Anyway, both bytes_long and mask are constant, I doubt they get summed
at every cycle.
> Next is to shorten the variable names!
>
> David
>
--
per aspera ad upstream
Powered by blists - more mailing lists