4 ms·
The suggested code tests for bitfield borrows with auto c = ((~x & y) | (~(x ^ y) & (x - y)); c &= 0x8410; return c == 0; where the literal bitmap
by tromp 2y ago
The suggested code tests for bitfield borrows with
auto c = ((~x & y) | (~(x ^ y) & (x - y));
c &= 0x8410;
return c == 0;
where the literal bitmap contains the most significant bit of each bitfield.
Couldn't this be written equivalently as
auto c = x ^ y ^ (x - y);
c &= 0x10820;
where the literal bitmap now contains the bits just left of each bitfield?
- teo_zero 2y agoI think part of the challenge is to not exceed the word size, 16 bits in this case.
- kragen 2y agothat's useful with explicit simd instructions which let you process 32 (pairs of corresponding) 16-bit pixels with one avx-512 instruction, or on a 16-bit machine like the 80286, but unnecessary if you're processing a single pair of 16-bit pixels with 32-bit instructions. on the other hand, you might have 32-bit vectors or something, for example for the standard axis-aligned bounding box test