[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <ccb719dd52354cfab8def75689d675af@AcuMS.aculab.com>
Date: Fri, 30 Nov 2018 12:27:58 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Dave Rodgman' <dave.rodgman@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
CC: "herbert@...dor.apana.org.au" <herbert@...dor.apana.org.au>,
"davem@...emloft.net" <davem@...emloft.net>,
Matt Sealey <Matt.Sealey@....com>,
"nitingupta910@...il.com" <nitingupta910@...il.com>,
"markus@...rhumer.com" <markus@...rhumer.com>,
"minchan@...nel.org" <minchan@...nel.org>,
"sergey.senozhatsky.work@...il.com"
<sergey.senozhatsky.work@...il.com>,
"sonnyrao@...gle.com" <sonnyrao@...gle.com>,
"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
nd <nd@....com>
Subject: RE: [PATCH 2/8] lib/lzo: clean-up by introducing COPY16
From: Dave Rodgman
> Sent: 30 November 2018 11:48
> From: Matt Sealey <matt.sealey@....com>
>
> Most compilers should be able to merge adjacent loads/stores of sizes
> which are less than but effect a multiple of a machine word size (in
> effect a memcpy() of a constant amount). However the semantics of the
> macro are that it just does the copy, the pointer increment is in the
> code, hence we see
>
> *a = *b
> a += 8
> b += 8
> *a = *b
> a += 8
> b += 8
>
> This introduces a dependency between the two groups of statements which
> seems to defeat said compiler optimizers and generate some very strange
> sequences of addition and subtraction of address offsets (i.e. it is
> overcomplicated).
>
> Since COPY8 is only ever used to copy amounts of 16 bytes (in pairs),
> just define COPY16 as COPY8,COPY8. We leave the definition to preserve
> the need to do unaligned accesses to machine-sized words per the
> original code intent, we just don't use it in the code proper.
>
> COPY16 then gives us code like:
>
> *a = *b
> *(a+8) = *(b+8)
> a += 16
> b += 16
You probably actually want:
t1 = *b;
t2 = *(b+8);
*a = t1;
*(a+8) = t2;
a += 16;
b += 16;
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists