Skip to content

Instantly share code, notes, and snippets.

@rygorous
Created February 10, 2014 00:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rygorous/8908164 to your computer and use it in GitHub Desktop.
Save rygorous/8908164 to your computer and use it in GitHub Desktop.
Game changer.
static __m128i const shuffles[16] = {
#define _ -1 // for readability
{ _,_,_,_, _,_,_,_, _,_,_,_, _,_,_,_ }, // 0000
{ 0,1,_,_, _,_,_,_, _,_,_,_, _,_,_,_ }, // 0001
{ _,_,_,_, 0,1,_,_, _,_,_,_, _,_,_,_ }, // 0010
{ 0,1,_,_, 2,3,_,_, _,_,_,_, _,_,_,_ }, // 0011
{ _,_,_,_, _,_,_,_, 0,1,_,_, _,_,_,_ }, // 0100
{ 0,1,_,_, _,_,_,_, 2,3,_,_, _,_,_,_ }, // 0101
{ _,_,_,_, 0,1,_,_, 2,3,_,_, _,_,_,_ }, // 0110
{ 0,1,_,_, 2,3,_,_, 4,5,_,_, _,_,_,_ }, // 0111
{ _,_,_,_, _,_,_,_, _,_,_,_, 0,1,_,_ }, // 1000
{ 0,1,_,_, _,_,_,_, _,_,_,_, 2,3,_,_ }, // 1001
{ _,_,_,_, 0,1,_,_, _,_,_,_, 2,3,_,_ }, // 1010
{ 0,1,_,_, 2,3,_,_, _,_,_,_, 4,5,_,_ }, // 1011
{ _,_,_,_, _,_,_,_, 0,1,_,_, 2,3,_,_ }, // 1100
{ 0,1,_,_, _,_,_,_, 2,3,_,_, 4,5,_,_ }, // 1101
{ _,_,_,_, 0,1,_,_, 2,3,_,_, 4,5,_,_ }, // 1110
{ 0,1,_,_, 2,3,_,_, 4,5,_,_, 6,7,_,_ }, // 1111
#undef _
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment