Skip to content

Instantly share code, notes, and snippets.

@rygorous
Created June 15, 2012 17:04
Embed
What would you like to do?
Another selb attempt
# Rough sketch, not actually tested or anything...
# in any case, way too many instrs to be actually useful.
rotqbyi inMaskY, inMask, 4
rotqbyi inMaskZ, inMask, 8
rotqbyi inMaskW, inMask, 12
cwd maskX, 4(inMask) # 0x00010203 in maskX.x if inMask.x set, 0x10111213 otherwise (rest id + 0x10)
cwd maskY, 8(inMaskY) # 0x00010203 in maskY.y if inMask.y set, 0x14151617 otherwise (rest id + 0x10)
cwd maskZ, 12(inMaskZ) # 0x00010203 in maskZ.z if inMask.z set, 0x18191a1b otherwise (rest id + 0x10)
cwd maskW, 0(inMaskW) # 0x00010203 in maskZ.w if inMask.w set, 0x1c1d1e1f otherwise (rest id + 0x10)
# magicY.x = 0x04050607
# magicZ.x = 0x08090a0b
# magicW.x = 0x0c0d0e0f
shufb outY, magicY, maskX, maskY
shufb outZ, magicZ, outY, maskZ
shufb outW, magicW, outZ, maskW
# now outW contains shufb mask (but positions of a and b reversed!)
shufb result, val_b, val_a, outW
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment