Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3681308imu; Fri, 30 Nov 2018 04:28:43 -0800 (PST) X-Google-Smtp-Source: AFSGD/V4V5U3uohrpnV0hc2/TfkX4KX1alIboZ9Rq8hEZqxGYF2uqk0b/fzqnBF5QemktXLRvuJ3 X-Received: by 2002:a65:448a:: with SMTP id l10mr3506046pgq.387.1543580923904; Fri, 30 Nov 2018 04:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543580923; cv=none; d=google.com; s=arc-20160816; b=OzkVW93G7i1PA17ahferQeLa4GZ9k65c3gUdRiTr+OksOrIr8Hez51R0b2rREh3Q7c GRhhUEmjWkW4YShRjU3wtNeQ9jEEuaMCpsKo0UEdLkxkDLOElEAdrXgGEFFFkWF3RuV3 Yo/1F8ax5Tp2ww87rXvv0e/cRDP4CG2ry/u6RBrS5Js7bys3Svvl4cSkxAAYEs6nz4G7 2U3rr02XzUe1oj7QeSvJeO97Qx9wYRuWrjE6NnQVJk8VwzjXdYIV1HYJFR1QdY18yXKP g3JE192F/295aCG0tH5SUbVhSlT/pSo2mEMO3ie/Mfi8F8vxg/eu1G5/xvRsMw/ZPy1H pCSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from; bh=5oIk2AnokrIhoAPUa8zUdQeSOwSNGf0vkg3EawmY3/g=; b=yT18a3GWc236OAWxSk/z/QapGdsWJOtFeRMXOQnHN47u7zrkLlzH+PxxtuooesQ3Fw UxkKvntbbGpb1OzFUrnks8ywgjP75Ag60FmSeuvdWHhKJiuuuMfgxzTAOpJW8bEEQ8dz Gq2FomuGYKSE9jHoNqRMIwFRknhy3id6YM0cur3POYmTHdE3n9EsZxYrW7LKvZrxNSpU o8/p8AYvFsLaWbqzkLQvTlCICoINkH5E/k8+pi49Laxv3hSObjGoDFKgLA/bCsL164t6 axaKPBDcTTkqyk/UrEvBf6259CqYH3Ulh4U4O2jBwgvHj4igEW2SfyvZk7KIDvkFGUuu EYJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n15si4366017pgk.27.2018.11.30.04.28.28; Fri, 30 Nov 2018 04:28:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbeK3XhB convert rfc822-to-8bit (ORCPT + 99 others); Fri, 30 Nov 2018 18:37:01 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([207.82.80.151]:38840 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726549AbeK3XhB (ORCPT ); Fri, 30 Nov 2018 18:37:01 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-144-4qFN5sBKP82d6eOpE1nuuw-1; Fri, 30 Nov 2018 12:27:50 +0000 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b::d117) by AcuMS.aculab.com (fd9f:af1c:a25b::d117) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Fri, 30 Nov 2018 12:27:58 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Fri, 30 Nov 2018 12:27:58 +0000 From: David Laight To: 'Dave Rodgman' , "linux-kernel@vger.kernel.org" , "akpm@linux-foundation.org" CC: "herbert@gondor.apana.org.au" , "davem@davemloft.net" , Matt Sealey , "nitingupta910@gmail.com" , "markus@oberhumer.com" , "minchan@kernel.org" , "sergey.senozhatsky.work@gmail.com" , "sonnyrao@google.com" , "gregkh@linuxfoundation.org" , nd Subject: RE: [PATCH 2/8] lib/lzo: clean-up by introducing COPY16 Thread-Topic: [PATCH 2/8] lib/lzo: clean-up by introducing COPY16 Thread-Index: AQHUiKKcsNRVxoInU0ado7SP4WwMWKVoPj+w Date: Fri, 30 Nov 2018 12:27:58 +0000 Message-ID: References: <20181130114715.27523-1-dave.rodgman@arm.com> <20181130114715.27523-3-dave.rodgman@arm.com> In-Reply-To: <20181130114715.27523-3-dave.rodgman@arm.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-MC-Unique: 4qFN5sBKP82d6eOpE1nuuw-1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dave Rodgman > Sent: 30 November 2018 11:48 > From: Matt Sealey > > 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)