Skip to content

Instantly share code, notes, and snippets.

@ssvb
Created June 12, 2012 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssvb/2913581 to your computer and use it in GitHub Desktop.
Save ssvb/2913581 to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <assert.h>
#include <emmintrin.h>
uint32_t foo(uint32_t a)
{
__m128i xa = _mm_cvtsi32_si128(a);
return _mm_cvtsi128_si32(_mm_packus_epi16(xa, xa));
}
__m128i bar(__m128i xa)
{
return _mm_packus_epi16(xa, xa);
}
int main(void)
{
assert(foo(0x12345678) == 0xFFFF);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment