mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Andi Kleen <ak@linux.intel.com>, Andi Kleen <andi@firstfloor.org>,
	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
Date: Tue, 02 Feb 2016 21:46:05 +0100	[thread overview]
Message-ID: <8760y6zvqq.fsf@rasmusvillemoes.dk> (raw)
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")

On Tue, Feb 02 2016, Eric Dumazet <eric.dumazet@gmail.com> 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

  reply	other threads:[~2016-02-02 20:46 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-28 21:42 Andi Kleen
2016-01-28 22:04 ` kbuild test robot
2016-01-28 22:11 ` kbuild test robot
2016-01-28 22:15 ` Joe Perches
2016-01-28 22:40   ` Andi Kleen
2016-01-28 22:22 ` Joe Perches
2016-01-28 22:29 ` Eric Dumazet
2016-01-28 22:30 ` Andi Kleen
2016-01-29  3:59 ` Rafael J. Wysocki
2016-01-31  7:27 ` Thomas Rohwer
2016-02-01 21:25 ` Rasmus Villemoes
2016-02-01 21:36   ` Andi Kleen
2016-02-01 23:08     ` Rasmus Villemoes
2016-02-02  0:00       ` Andi Kleen
2016-02-02  0:36       ` Eric Dumazet
2016-02-02 20:46         ` Rasmus Villemoes [this message]
2016-02-02 21:30           ` Eric Dumazet
2017-07-20 10:10         ` Peter Zijlstra
2017-07-24 13:28           ` Eric Dumazet
2016-02-07 21:32     ` Rasmus Villemoes
2016-02-09 20:44       ` Andi Kleen
2016-02-10 13:31         ` Fengguang Wu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8760y6zvqq.fsf@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andi@firstfloor.org \
    --cc=davidlohr.bueso@hp.com \
    --cc=eric.dumazet@gmail.com \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome