Boost logo

Boost Users :

Subject: Re: [Boost-users] run-time integer log2
From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2010-07-15 03:36:22

ajb_at_[hidden] wrote:
> Many modern ISAs (at least EM64T, PPC and recent ARMs; these are just
> the ones I know about) have a single-instruction priority encoder
> usually called "count leading zeroes". In GCC, it's available as a
> builtin:
> uint64_t log2v = v == 1 ? 0 : 64 - __builtin_clzll(v - 1);

Guess my old signal processing habits showed up ;)
Of course, mapping to intrinsic is better I think.
But I guess when they are not there, we need a fallback ;)

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at