Hi Sven,Sven Schüle wrote: @Michael: I would also propose to remove this line:which points again to the "-(ui64_t) 1"Code: Select all
#pragma warning (disable: 4146)
For this reason I also don't think the compiler is "buggy" here. With the warning C4146, given that you don't suppress it, it announces that something unexpected can happen.
Which data type is returned by bsr64()? In case of "unsigned char", this might be part of the problem, if the compiler truncates the left operand of the << operator in the "optimized" version due to the "unsigned char" type of the right operand.
Sven
I think the type determing the 32/64-bit shift should be the const ui64_t allBitsSet = 0xffffffffffffffffULL and not the type of the shift amount in a 0..63 range, see Visual Studio 2008 - Shift Operators: >> and <<:
With the source below, without a warning C4146 due to 0xffffffffffffffffULL instead of unary minus, but still producing the errornous byte-wise shift instructions for (attackLine.. & 32), implies a compiler bug.The type of the result is the same as the type of the left operand. The value of a right-shift expression x >> y is x / 2y, and the value of a left-shift expression x << y is x * 2y. The result is undefined if the right operand of a shift expression is negative or if the right operand is greater than or equal to the number of bits in the (promoted) left operand.
Code: Select all
static __inline ui64_t attackLine(linemask_t *lmsk,ui64_t occ)
{
const ui64_t allBitsSet = 0xffffffffffffffffULL;
ui64_t lo = allBitsSet << bsr64((lmsk->lineLo & occ)|1);
ui64_t hi = lmsk->lineHi & occ;
return(lmsk->lineEx & (2*(hi&-hi)-lo));
}
Code: Select all
mov edx, 255
mov eax, edx
shl al, cl ; shl rax, cl required since cl might be >= 32 < 64
GerdTrue integration of 64-bit compilers to the Visual C++ 2008 Express Edition is possible, but remains cumbersome ...