From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934189AbcBBUqL (ORCPT ); Tue, 2 Feb 2016 15:46:11 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:36350 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933907AbcBBUqJ (ORCPT ); Tue, 2 Feb 2016 15:46:09 -0500 From: Rasmus Villemoes To: Eric Dumazet Cc: Andi Kleen , Andi Kleen , akpm@linux-foundation.org, linux-kernel@vger.kernel.org, davidlohr.bueso@hp.com, rafael.j.wysocki@intel.com, lenb@kernel.org Subject: Re: [PATCH] Optimize int_sqrt for small values for faster idle Organization: D03 References: <1454017365-8509-1-git-send-email-andi@firstfloor.org> <87y4b4azsy.fsf@rasmusvillemoes.dk> <20160201213622.GA15302@tassilo.jf.intel.com> <87powgav0h.fsf@rasmusvillemoes.dk> <1454373398.7627.193.camel@edumazet-glaptop2.roam.corp.google.com> X-Hashcash: 1:20:160202:andi@firstfloor.org::0JuHMPAcUzcJPySG:0000000000000000000000000000000000000000000k+H X-Hashcash: 1:20:160202:davidlohr.bueso@hp.com::/zX+bvkeWLtpagqn:0000000000000000000000000000000000000001sPW X-Hashcash: 1:20:160202:ak@linux.intel.com::B7YGILuVQre6whSA:000000000000000000000000000000000000000000028gq X-Hashcash: 1:20:160202:linux-kernel@vger.kernel.org::cw111DD6XQXkadT5:0000000000000000000000000000000002DHO X-Hashcash: 1:20:160202:akpm@linux-foundation.org::Aw85gAYxzLHWdc8w:0000000000000000000000000000000000004Afu X-Hashcash: 1:20:160202:eric.dumazet@gmail.com::68i3y1OakpVGAGqB:0000000000000000000000000000000000000005VLW X-Hashcash: 1:20:160202:rafael.j.wysocki@intel.com::y12Xn3oYP1HdxoGX:0000000000000000000000000000000000055Zi X-Hashcash: 1:20:160202:lenb@kernel.org::8oNxx4AYQoqnp+QN:008nZv Date: Tue, 02 Feb 2016 21:46:05 +0100 In-Reply-To: <1454373398.7627.193.camel@edumazet-glaptop2.roam.corp.google.com> (Eric Dumazet's message of "Mon, 01 Feb 2016 16:36:38 -0800") Message-ID: <8760y6zvqq.fsf@rasmusvillemoes.dk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 02 2016, Eric Dumazet wrote: > On Tue, 2016-02-02 at 00:08 +0100, Rasmus Villemoes wrote: > >> Thanks. (Is there a good way to tell gcc that avg*avg is actually a >> 32x32->64 multiplication?) > > If avg is 32bit, compiler does that for you. > > u32 avg = ... > > u64 result = (u64)avg * avg; Yeah, but in this case avg is u64 because it is used to temporarily contain the sum of a bunch of u32s, before being divided by #bunch. So I'd have to write that as (u64)(u32)avg * (u32)avg, which isn't very readable :-/ I just thought the scenario of a u64 known to be holding a value < 2^32 was common enough that some utility macros already existed. Rasmus