3 ms·
> So, maybe [...] is better You were one click away of using LLVM's Machine Code Analyzer (MCA) within godbolt to see why one of the two isvowel one-liners is
by fluffything 6y ago
> So, maybe [...] is better
You were one click away of using LLVM's Machine Code Analyzer (MCA) within godbolt to see why one of the two isvowel one-liners is objectively better than the other: https://godbolt.org/z/fGEv3c https://godbolt.org/z/fGEv3c
This version:
bool isvowel(char c){ return (0x104111>>c-'a')&1; }
puts way more pressure on Port 2 on skylake, reducing the number of IPC that can be scheduled. The first version is therefore a bit better.
;)
- ncmncm 6y agoToday I learned six new things: - Clang thinks compressing 0x104111 to 0x495 is a good idea - Clang thinks 0x495>>((c-'a')>>1)&1 is better than 1<<c-'a'&0x104111 - LLVM has a machine code analyzer - Godbolt has a button to apply it - Clang is wrong about that - Gcc-9 and newer prefers to index into a jump table, instead of bitmasking. (!) Yet another reason to set up a periodic contribution to Godbolt.
- fluffything 6y agoWhile deprecated, intel has also an opensource machine code analyzer called IACA. It is also worth pointing out that these "analyzers" are just tools that simulate particular CPU architectures. Their models are just approximations and aren't perfect, so don't take them as a source of truth.