Author: Eugene Nalimov
Date: 23:29:09 05/19/05
Go up one level in this thread
On May 20, 2005 at 01:34:13, Tony Werten wrote:
>On May 15, 2005 at 06:22:22, Gerd Isenberg wrote:
>
>>On May 14, 2005 at 18:47:38, Tony Werten wrote:
>>
>>>Hi,
>>>
>>>when I use the compiler intrinsic __ull_rshift it has the (undocumented) feature
>>>of wrapping the shift amount around 32.
>>>
>>>What do I have to use to shift with more than 32 ?
>>>
>>>Cheers,
>>>
>>>Tony
>>
>>Yes, __ull_rshift seems to be wrong documented.
>
>Microsoft fixed it :) Unfortunately not with by adjusting the compiler but by
>adjusting the documentation :(
>
>Tony
>
>>It produces the shortest code, a shrd and a shr instruction with implicit nShift
>>mod 32. Performant - but only correct for nShifts < 32.
>>Shift right operand works correct on unsigned __int64 for all nShift mod 64 but
>>requires a call and some conditional jumps depending on nShift.
>>
>>extern "C"
>>unsigned __int64 __ull_rshift(unsigned __int64 mask, int nBit);
>>#pragma intrinsic(__ull_rshift)
>>
>>void test_Shr()
>>{
>> BitBoard b1 = 0x123456789abcdef0;
>> for (int i = 1; i < 64; i++)
>> {
>> BitBoard b2 = __ull_rshift(b1, i);
>> BitBoard b3 = b1 >> i;
>> if ( b2 != b3 )
>> __debugbreak();
>> }
>>}
>>
>>
>>Cheers,
>>Gerd
Actually I was a person who investigated bug report :-)
If you need shift by more than 31 you can always use "normal" operator >>.
Intrinsics is there for developer who know that shift amount is less than 32 and
absolutely needs performance.
If intrinsic would work the way you want it will be just another (and
non-standard) way to achieve exactly what operator >> does.
Thanks,
Eugene
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.