SDHLT icon indicating copy to clipboard operation
SDHLT copied to clipboard

Incompatibilities in compress.h

Open oskarlh opened this issue 1 year ago • 0 comments

The reason compress_compatability_test() fails in some cases (like when compiling for ARM with Clang with -O2) appears to be that shifts in vector_compress (the VECTOR24/VECTOR32 cases) are sometimes made like x >> y where x is unsigned int and y is greater than std::numeric_limits<unsigned int>::digits, which means the behavior is undefined. So if

			i1 = float_istoobig (*p1)? ~0u : (bitget (*p1, 0, 23) | bitput (1, 23, 24)) >> (1 + max - bitget (*p1, 23, 31));
			i2 = float_istoobig (*p2)? ~0u : (bitget (*p2, 0, 23) | bitput (1, 23, 24)) >> (1 + max - bitget (*p2, 23, 31));
			i3 = float_istoobig (*p3)? ~0u : (bitget (*p3, 0, 23) | bitput (1, 23, 24)) >> (1 + max - bitget (*p3, 23, 31));

is replaced by

			i1 = float_istoobig (*p1)? ~0u : (bitget (*p1, 0, 23) | bitput (1, 23, 24)) >> ((1 + max - bitget (*p1, 23, 31)) % 32);
			i2 = float_istoobig (*p2)? ~0u : (bitget (*p2, 0, 23) | bitput (1, 23, 24)) >> ((1 + max - bitget (*p2, 23, 31)) % 32);
			i3 = float_istoobig (*p3)? ~0u : (bitget (*p3, 0, 23) | bitput (1, 23, 24)) >> ((1 + max - bitget (*p3, 23, 31)) % 32);

I don't think the compatibility test is needed

oskarlh avatar Dec 07 '24 03:12 oskarlh