1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Revert small pop_1st_bit() optimization

We cannot cast a pointer type to an unrelated pointer type.
This is a violation of the strict aliasing rules.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2009-12-27 14:05:15 +01:00
parent aa86d81f79
commit 3f14f9a478

View file

@ -348,19 +348,21 @@ union b_union {
Square pop_1st_bit(Bitboard* bb) {
b_union* u;
b_union u;
Square ret;
u = (b_union*)bb;
u.b = *bb;
if (u->dw.l)
if (u.dw.l)
{
ret = Square(BitTable[((u->dw.l ^ (u->dw.l - 1)) * 0x783a9b23) >> 26]);
u->dw.l &= (u->dw.l - 1);
ret = Square(BitTable[((u.dw.l ^ (u.dw.l - 1)) * 0x783a9b23) >> 26]);
u.dw.l &= (u.dw.l - 1);
*bb = u.b;
return ret;
}
ret = Square(BitTable[((~(u->dw.h ^ (u->dw.h - 1))) * 0x783a9b23) >> 26]);
u->dw.h &= (u->dw.h - 1);
ret = Square(BitTable[((~(u.dw.h ^ (u.dw.h - 1))) * 0x783a9b23) >> 26]);
u.dw.h &= (u.dw.h - 1);
*bb = u.b;
return ret;
}