2012-08-10 12:51:55

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions


On Saturday 2012-07-21 02:46, David Miller wrote:
>> Arnd Bergmann <[email protected]> wrote:
>>
>>> I don't generally like to put stuff into asm-generic when it's unlikely
>>> to be overridden by architectures. It would really belong into
>>> include/linux, but then again we have all the other bitops in asm-generic
>>> as well, so whatever...
>>
>> Some arches (such as Sparc, I think) have count-leading-zero instructions.
>
>Yes, newer sparc64 chips have leading-zero-detect, and I was pretty
>sure that powerpc had something similar. It's called count-leading-
>zeros or something like that.

And gcc has a __builtin_clz.


2012-08-10 21:08:30

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions

From: Jan Engelhardt <[email protected]>
Date: Fri, 10 Aug 2012 14:51:49 +0200 (CEST)

>
> On Saturday 2012-07-21 02:46, David Miller wrote:
>>> Arnd Bergmann <[email protected]> wrote:
>>>
>>>> I don't generally like to put stuff into asm-generic when it's unlikely
>>>> to be overridden by architectures. It would really belong into
>>>> include/linux, but then again we have all the other bitops in asm-generic
>>>> as well, so whatever...
>>>
>>> Some arches (such as Sparc, I think) have count-leading-zero instructions.
>>
>>Yes, newer sparc64 chips have leading-zero-detect, and I was pretty
>>sure that powerpc had something similar. It's called count-leading-
>>zeros or something like that.
>
> And gcc has a __builtin_clz.

Which I can't use. I have to patch the code at run time based upon
whether the cpu has the 'lzd' instruction or not.