value range propagation for _bitwise_ OR

Steven Schveighoffer schveiguy at yahoo.com
Tue Apr 13 07:52:14 PDT 2010


On Tue, 13 Apr 2010 09:56:34 -0400, Adam Ruppe <destructionator at gmail.com>  
wrote:

> Jerome's highbit function is the same as std.intrinsic.bsr. I wonder
> which is faster?

Just a note, this code should be runnable in C++, because the compiler is  
written in C++.  Is bsr available there?

> Recompiling with -inline -O -release cuts the raw numbers about in
> half, but keeps about the same difference, leading me to think
> overhead amounts for a fair amount of the percentage instead of actual
> implementation. The new averages are 1134 and 853.

Probably the inlining accounts for the savings here.  Calling a function  
is rather expensive.

> I've gotta say, your implementation of the function is better than I
> would have done though. Without bsr, I probably would have looped,
> shifted, and tested each individual bit...

I never would have thought of doing a binary search for the high bit, it  
is definitely a novel idea to me :)

-Steve



More information about the Digitalmars-d mailing list