Jonathan Wakely [Tuesday, 10 February 2026 22:59:30 CET]:
> On Tue, 10 Feb 2026 at 14:07, Tomasz Kaminski <[email protected]> wrote:
> > That's a really cool idea, to switch on one character.
> 
> […]
> 4) ... it's 20 years later, maybe optimizers have changed :-)

I actually looked at this because I wondered whether using SIMD would be 
beneficial. But GCC takes the char, subtracts the minimum case ('a'), jumps 
behind the block for anything greater than the maximum (unsigned, so anything 
below is covered as well) and then does a table lookup for the remaining 
(small) integer for an indirect jump. I love it.

The only way to potentially make it more efficient would be to have machine 
code sections of equal size for the cases and compute the jump offset via 
multiplication rather than table lookup. (If the table entry is not in cache, 
it can stall for a long time with no way to do a speculative jump.)

-- 
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Center for Heavy Ion Research               https://gsi.de
 std::simd
──────────────────────────────────────────────────────────────────────────

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to