Robert P. J. Day wrote:
> On Fri, 15 Jun 2007, H. Peter Anvin wrote:
>
>> Vegard Nossum wrote:
>>> From: Vegard Nossum <[EMAIL PROTECTED]>
>>> Date: Fri, 15 Jun 2007 18:35:49 +0200
>>> Subject: [PATCH] Optimize is_power_of_2().
>>>
>>&g
On Fri, 15 Jun 2007 14:54:20 -0500
"David M. Lloyd" <[EMAIL PROTECTED]> wrote:
> On Fri, 15 Jun 2007 21:47:50 +0200 (CEST)
> Jan Engelhardt <[EMAIL PROTECTED]> wrote:
>
> > On Jun 15 2007 18:56, Vegard Nossum wrote:
> > > bool is_power_of_2(unsigned long n)
> > > {
> > >- return (n != 0 && ((n &
On Fri, 15 Jun 2007 21:47:50 +0200 (CEST)
Jan Engelhardt <[EMAIL PROTECTED]> wrote:
> On Jun 15 2007 18:56, Vegard Nossum wrote:
> > bool is_power_of_2(unsigned long n)
> > {
> >-return (n != 0 && ((n & (n - 1)) == 0));
> >+return n * !(n & (n - 1));
> > }
>
> There is a third way which u
On Jun 15 2007 18:56, Vegard Nossum wrote:
> bool is_power_of_2(unsigned long n)
> {
>- return (n != 0 && ((n & (n - 1)) == 0));
>+ return n * !(n & (n - 1));
> }
There is a third way which uses neither * nor &&, but []:
bool is_power_of_2(unsigned long n)
{
static const bool
On Fri, 15 Jun 2007, H. Peter Anvin wrote:
> Vegard Nossum wrote:
> > From: Vegard Nossum <[EMAIL PROTECTED]>
> > Date: Fri, 15 Jun 2007 18:35:49 +0200
> > Subject: [PATCH] Optimize is_power_of_2().
> >
> > Rationale: Removes one conditional branch and reduc
Vegard Nossum wrote:
> From: Vegard Nossum <[EMAIL PROTECTED]>
> Date: Fri, 15 Jun 2007 18:35:49 +0200
> Subject: [PATCH] Optimize is_power_of_2().
>
> Rationale: Removes one conditional branch and reduces icache footprint.
> Proof: If n is false, the product of n and any
From: Vegard Nossum <[EMAIL PROTECTED]>
Date: Fri, 15 Jun 2007 18:35:49 +0200
Subject: [PATCH] Optimize is_power_of_2().
Rationale: Removes one conditional branch and reduces icache footprint.
Proof: If n is false, the product of n and any value is false. If n is
true, the truth of (n * x)
7 matches
Mail list logo