From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW537-0004wA-C1 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 11:29:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YW533-0001ny-94 for qemu-devel@nongnu.org; Thu, 12 Mar 2015 11:29:25 -0400 Received: from mail-qc0-x233.google.com ([2607:f8b0:400d:c01::233]:43406) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YW533-0001nk-5J for qemu-devel@nongnu.org; Thu, 12 Mar 2015 11:29:21 -0400 Received: by qcyl6 with SMTP id l6so19342317qcy.10 for ; Thu, 12 Mar 2015 08:29:20 -0700 (PDT) Sender: Richard Henderson Message-ID: <5501B0CC.3090500@twiddle.net> Date: Thu, 12 Mar 2015 08:29:16 -0700 From: Richard Henderson MIME-Version: 1.0 References: <1424694237-22786-1-git-send-email-aik@ozlabs.ru> <877fv8sp97.fsf@blackfin.pond.sub.org> <54ED19E9.4050503@ozlabs.ru> <877fv6gth5.fsf@blackfin.pond.sub.org> In-Reply-To: <877fv6gth5.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2] utils: Add pow2ceil() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , Alexey Kardashevskiy Cc: Peter Maydell , qemu-devel@nongnu.org On 02/25/2015 02:45 AM, Markus Armbruster wrote: > return 0x8000000000000000u >> (clz64(value - 1) - 1); I realize this was weeks ago, but it would certainly be preferable to shift a small constant left than a large constant right. Most RISC machines can't form 0x8000000000000000ull without loading 1 and then left shifting to start with. So end the end you're better off with return 1ull << (63 - clz64(value)); r~