Thread overview
[D-runtime] core.bitop.bsr
Jul 09, 2012
Jonathan M Davis
Jul 09, 2012
Iain Buclaw
Jul 10, 2012
Martin Nowak
Jul 10, 2012
Iain Buclaw
July 08, 2012
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@puremagic.com
http://lists.puremagic.com/mailman/listinfo/d-runtime

July 09, 2012
On Mon, Jul 9, 2012 at 5:57 AM, Jonathan M Davis <jmdavisProg@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)?

It is always defined in DMD, GDC, and LDC. Just kill whatever code thinks it might not exist.

Regards,
Alex
_______________________________________________
D-runtime mailing list
D-runtime@puremagic.com
http://lists.puremagic.com/mailman/listinfo/d-runtime

July 09, 2012
On 9 July 2012 04:57, Jonathan M Davis <jmdavisProg@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)?
>

bsr is handled as an internal builtin function here at gdc.

-- 
Iain Buclaw

*(p < e ? p++ : p) = (c & 0x0f) + '0';
_______________________________________________
D-runtime mailing list
D-runtime@puremagic.com
http://lists.puremagic.com/mailman/listinfo/d-runtime

July 10, 2012
On Mon, 09 Jul 2012 05:57:26 +0200, Jonathan M Davis <jmdavisProg@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@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
_______________________________________________
D-runtime mailing list
D-runtime@puremagic.com
http://lists.puremagic.com/mailman/listinfo/d-runtime

July 10, 2012
On 10 July 2012 09:10, Martin Nowak <dawg@dawgfoto.de> wrote:
> On Mon, 09 Jul 2012 05:57:26 +0200, Jonathan M Davis <jmdavisProg@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@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';
_______________________________________________
D-runtime mailing list
D-runtime@puremagic.com
http://lists.puremagic.com/mailman/listinfo/d-runtime