54 ms·
I’m tempted to emulate a conventional SIMD solution and go with a small lookup table: uint8_t classify(uint8_t c) { return c - (0x5F45452B2B210000ULL >
by mananaysiempre 1y ago
I’m tempted to emulate a conventional SIMD solution and go with a small lookup table:
uint8_t classify(uint8_t c) {
return c - (0x5F45452B2B210000ULL >> ((c & 0x70) >> 1));
}
The AND-then-shift sequence on the right is annoying and it feels like one should be able to avoid it, but I don’t see how. Overall, this is more expensive than it looks—neither a full 64-bit constant nor a variable 64-bit shift are exactly free. So I’m probably missing something here.