Topological order
foo
foo/bar
foo/bar/baz
foo-fleem
foo-fleem/morx
Simple version
/* Put re-ordered character from
* string sa into ca */
if (*sa == '/')
ca = 1;
else if (*sa > 0 && *sa < '/')
ca = *sa + 1;
else
ca = *sa;
Single Instruction
Multiple Data
Some 128-bit SIMD registers
four 32-bit integers

eight 16-bit integers

sixteen bytes

movdqa (%rdi), %xmm0
paddusb (%rsi), %xmm0
movdqa %xmm0, (%rdi)

becomes
we already know this tune
movdqa (%rdi), %xmm0
paddusb (%rsi), %xmm0
movdqa %xmm0, (%rdi)
Constructing if-then-else
from
AND, XOR, and OR
if (*sa == '/')
ca = 1;
else
ca = *sa;
xmm1 before pcmpeqb

xmm7

xmm1 after pcmpeqb

xmm6

movdqa %xmm1, %xmm2
pand %xmm6, %xmm2
xmm2
xmm5
xmm1 before pxor

pxor %xmm5, %xmm1
xmm5 after pxor
xmm0 before pand

xmm1

pand %xmm1, %xmm0
xmm0 after pand
xmm0
xmm2

por %xmm2, %xmm0
xmm0, after por
xmm0
xmm1
pcmpistri %xmm0, %xmm1
rcx register gets 7
carry flag and zero flag get set
pshufb
Bonus slide
Extracting a byte
xmm5

add $1, %rcx
movq %rcx, %xmm4

paddb %xmm5, %xmm4

pshufb %xmm4, %xmm0
movq %xmm0, %rax