On Freitag, 14. August 2020 18:43:12 CEST Stefan Kanthak wrote: > Hi @ll, > > in his ACM queue article <https://queue.acm.org/detail.cfm?id=3372264>, > Matt Godbolt used the function > > | bool isWhitespace(char c) > | { > | > | return c == ' ' > | > | || c == '\r' > | || c == '\n' > | || c == '\t'; > | > | } > > as an example, for which GCC 9.1 emits the following assembly for AMD64 > > processors (see <https://godbolt.org/z/acm19_conds>): > | xor eax, eax ; result = false > | cmp dil, 32 ; is c > 32 > | ja .L4 ; if so, exit with false > | movabs rax, 4294977024 ; rax = 0x100002600 > | shrx rax, rax, rdi ; rax >>= c > | and eax, 1 ; result = rax & 1 > | > |.L4: > | ret > No it doesn't. As your example shows if you took the time to read it, it is what gcc emit when generating code to run on a _haswell_ architecture. If you remove -march=haswell from the command line you get:
xor eax, eax cmp dil, 32 ja .L1 movabs rax, 4294977024 mov ecx, edi shr rax, cl and eax, 1 It uses one mov more, but no shrx. 'Allan