From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44038) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTXoS-0002Kk-1F for qemu-devel@nongnu.org; Thu, 05 Mar 2015 10:35:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YTXoL-0007B7-Gy for qemu-devel@nongnu.org; Thu, 05 Mar 2015 10:35:47 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YTXoL-0007Aw-9v for qemu-devel@nongnu.org; Thu, 05 Mar 2015 10:35:41 -0500 Date: Thu, 5 Mar 2015 16:35:36 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Message-ID: <20150305153535.GB3361@potion.redhat.com> References: <1425479449-11480-1-git-send-email-kraxel@redhat.com> <1425479449-11480-4-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PULL 3/7] qxl: refactor rounding up to a nearest power of 2 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dongsheng Song Cc: Gerd Hoffmann , qemu-devel@nongnu.org 2015-03-05 12:57+0800, Dongsheng Song: > On Wed, Mar 4, 2015 at 10:30 PM, Gerd Hoffmann wrote: > > +/* round up to the nearest power of 2 (0 if overflow) */ > > +uint64_t pow2ceil(uint64_t value) > > +{ > > + uint8_t nlz = clz64(value); > > + > > + if (is_power_of_2(value)) { > > + return value; > > + } > > please call clz64 after is_power_of_2. All callers under clz64() are inline, so the optimizer can see that there are no side effects and move the code if it would be faster; I thought that separating it would only make the code uglier, because QEMU doesn't allow lazy declarations ... Markus had another design issue with this patch, so I'll send a v2 after reaching the conclusion there. Thanks.