On Thu, Nov 21, 2013 at 03:15:18PM -0800, Jarno Rajahalme wrote:
> 
> On Nov 21, 2013, at 2:48 PM, Ben Pfaff <b...@nicira.com> wrote:
> 
> > On Thu, Nov 21, 2013 at 02:25:30PM -0800, Jarno Rajahalme wrote:
> >> Count leading zeroes using builtins if available.
> >> 
> >> Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
> > 
> > Could we rename raw_clz() to raw_clz64()?  clz is a function that
> > doesn't make sense without a defined length.
> 
> Should clz() be clz32() to then as well?

I'd support that.

> >> +static inline int
> >> +raw_clz(uint64_t n)
> >> +{
> >> +    /* With GCC 4.7 on 32-bit x86, if a 32-bit integer is passed as 'n', 
> >> using
> >> +     * a plain __builtin_ctzll() here always generates an out-of-line 
> >> function
> >> +     * call.  The test below helps it to emit a single 'bsf' instruction. 
> >> */
> >> +    return (__builtin_constant_p(n <= UINT32_MAX) && n <= UINT32_MAX
> >> +            ? __builtin_clz(n) + 32
> >> +            : __builtin_clzll(n));
> > 
> > In my tests the above trick isn't necessary for clz.  Just writing
> > __builtin_clzll() generates good code.  (But the comment would need an
> > update anyway: s/ctz/clz/ and s/bsf/bsr/.)
> 
> OK. Are you saying that clz32() could call raw_clz64() without
> penalty, or should I add a raw_clz32() as well?

clz32() can call raw_clz64() without penalty in my tests.
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to