SIMD string->int
I'm sure there are people here who like useless exercises in SIMD assembly language.
The exercise: how fast can you perform atoi?
Specifically, let char* A point to a list of a million 0x0a-separated positive integers written out in decimal, each of 15 or fewer digits. Output the result of XORing the numbers together. libc is about 650 cycles per number on K8; this must be beatable!
For an easier case, let XMM0 contain something of the form
'3' '1' '4' '1' '5' '9' ':' '2' '7' '1' '8' '2' '8' '1' '8' ',' '8'
and return 314159.
For an even easier case, let XMM0 contain something of the form above, and do the right-justification to return
'0' '0' '0' '0' '0' '0' '0' '0' '0' '0' '3' '1' '4' '1' '5' '9'
in as few cycles as you can.
|