[D-runtime] core.bitop.bsr

Iain Buclaw ibuclaw at ubuntu.com
Tue Jul 10 01:36:41 PDT 2012


On 10 July 2012 09:10, Martin Nowak <dawg at dawgfoto.de> wrote:
> On Mon, 09 Jul 2012 05:57:26 +0200, Jonathan M Davis <jmdavisProg at gmx.com>
> wrote:
>
>> Is there any reason that Phobos can't assume that core.bitop.bsr is
>> defined?
>> It's not versioned at all, so as far as I can tell, it will always exist.
>> But
>> for some reason std.utf.strideImpl currently checks for whether
>> core.bitop.bsr
>> is defined. I'd prefer to remove dead code like that. Does anyone know why
>> it
>> _wouldn't_ be dead code (i.e. why core.bitop.bsr wouldn't be defined)?
>>
>> - Jonathan M Davis
>> _______________________________________________
>> D-runtime mailing list
>> D-runtime at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/d-runtime
>
>
> Yeah we should, bsr is very x86 specific, but intrinsics are broadly
> available
> and a handwritten replacement could easily be added.
>
> Just for the reference:
>
> LLVM:  llvm.ctlz.* @ http://llvm.org/docs/LangRef.html#int_ctlz
> GCC: __builtin_clz @
> http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Other-Builtins.html

bsf would be ctlz

bsr is (31 - ctlz) or (63 - ctlz) depending on type size.


-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';


More information about the D-runtime mailing list