From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754087AbeDPIhC (ORCPT ); Mon, 16 Apr 2018 04:37:02 -0400 Received: from smtprelay2.synopsys.com ([198.182.60.111]:52721 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752941AbeDPIhB (ORCPT ); Mon, 16 Apr 2018 04:37:01 -0400 Subject: Re: [PATCH v2 8/9] PCI: dwc: Small computation improvement To: Fabio Estevam Cc: Jingoo Han , "bhelgaas@google.com" , "lorenzo.pieralisi@arm.com" , "Joao.Pinto@synopsys.com" , "kishon@ti.com" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "devicetree@vger.kernel.org" References: <5181f7ffbb9d2889974c49d84e72042251adf8b6.1523266508.git.gustavo.pimentel@synopsys.com> <003001d3d128$39f3eaa0$addbbfe0$@gmail.com> From: Gustavo Pimentel Message-ID: Date: Mon, 16 Apr 2018 09:35:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Fabio, On 15/04/2018 14:09, Fabio Estevam wrote: > Hi Gustavo, > > On Wed, Apr 11, 2018 at 4:40 AM, Gustavo Pimentel > wrote: > >> Can be this one? >> >> Probably any recent and decent compiler does this kind of substitution >> in order to improve code performance. Nevertheless it's a coding good >> practice whenever there is a division / multiplication by multiple of 2 >> to replace it by the equivalent operation in this case, the shift >> rotation. > > Subject says that this patch provides a computation improvement, but > as you said above the compiler > will perform the shift, so it doesn't seem we will get any benefit. In the worth case there is no performance, so it will not hurt having it. However depending the compiler and the platform this can bring some improvement. For instance like Jingoo said: "The most platforms using 'dwc' are based on ARM CPUs. So, the shift rotation can be better." It's just a attempt to improve the code that doesn't bring any harm. > > IMHO the original code has better readability as it makes easier to > understand that pp->cfg0_size will get the half of > resource_size(pp->cfg) size. Personally I prefer the shift rotation rather the division by 2. But in my case I'm used to use/see this type of operation, but it's like I said it's my personal opinion. > > I would say it is better to drop this patch from the series. Let's see this patch inflicts pain on someone else, in that case I'll remove from the series. > > Thanks > Regards, Gustavo