4 ms·
I wonder how a table lookup compares? Something like mov edx, @table xor eax, eax loop: mov al, [ecx] inc ecx cmp byte [edx+eax],
by userbinator 13y ago
I wonder how a table lookup compares? Something like
mov edx, @table
xor eax, eax
loop:
mov al, [ecx]
inc ecx
cmp byte [edx+eax], 0
jnz loop
I really wish Intel would optimise lodsb, scasb, and the rest of the string instructions, since they're powerful and particularly suited for this sort of scanning.
- zvrba 13y agoI think it's more likely that they'll eventually re-purpose these opcodes (further ISA extensions), and string operations will be optimized through simple hardware matching of documented instruction sequences. Already today, Intel's optimization manual gives SSE-optimized string search routines, which consume 16 bytes at a time. Removing and re-purposing instructions is not unprecedented; it has already been done at 32->64 jump. (Prefixes, decimal instructions, etc.)
- pbsd 13y agoI doubt those instructions (especially stos* and movs*, respectively matching memset and memcpy) are going anywhere. Intel has even changed their semantics in recent chips to work on 16-byte or larger chunks, and to have out-of-order memory accesses. Current MOVSB, for instance, should be nearly as fast as SSE/AVX optimized memory transfers.
- userbinator 13y agoI wouldn't say their semantics have changed but certainly their implementation. The fact that Intel used to recommend against using them but now advises the opposite, suggests that scas/cmps (memchr/memset) could be next. In any case, the thought of one machine instruction doing better than lots of carefully hand-written assembly is nice.