From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VAPyT-0004Fx-OM for qemu-devel@nongnu.org; Fri, 16 Aug 2013 15:46:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VAPyL-0007xl-77 for qemu-devel@nongnu.org; Fri, 16 Aug 2013 15:46:17 -0400 Sender: Richard Henderson Message-ID: <520E817B.3010105@twiddle.net> Date: Fri, 16 Aug 2013 12:46:03 -0700 From: Richard Henderson MIME-Version: 1.0 References: <20130816124915.12577.72732.stgit@bling.home> <520E44CA.6050205@twiddle.net> <1376667453.28796.0.camel@ul30vt.home> In-Reply-To: <1376667453.28796.0.camel@ul30vt.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] exec: Fix non-power-of-2 sized accesses List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alex Williamson Cc: lersek@redhat.com, qemu-devel@nongnu.org, qemu-stable@nongnu.org On 08/16/2013 08:37 AM, Alex Williamson wrote: > On Fri, 2013-08-16 at 08:27 -0700, Richard Henderson wrote: >> On 08/16/2013 05:50 AM, Alex Williamson wrote: >>> + /* Size must be a power of 2 */ >>> + if (l & (l - 1)) { >>> + while (l & (access_size_max - 1)) { >>> + access_size_max >>= 1; >>> + } >>> + } >>> + >> >> Why the loop at all? x & -x extracts the lsb of x. > > l = 5, we want 4, not 1. Thanks, It still doesn't require a loop. l = 1 << (31 - clz32(l)); r~