Skip to content

Instantly share code, notes, and snippets.

@gamefreak
Created October 4, 2011 12:40
Show Gist options
  • Save gamefreak/1261537 to your computer and use it in GitHub Desktop.
Save gamefreak/1261537 to your computer and use it in GitHub Desktop.
Failed MMX attempt.
static uint32_t pixel_magnitude(uint32 pixel, uint32 color) {
_m_empty();
__m64 null_ = _m_from_int(0x00000000);
__m64 pixel_ = _m_from_int(pixel);
pixel_ = _mm_unpacklo_pi8(pixel_, null_);
__m64 color_ = _m_from_int(color);
color_ = _mm_unpacklo_pi8(color_, null_);
pixel_ = _mm_sub_pi16(color_, pixel_);
pixel_ = _mm_madd_pi16(pixel_, pixel_);
color_ = _mm_srli_si64(pixel_, 32);
pixel_ = _mm_add_pi32(color_, pixel_);
int empty, out;
_mm_set_pi32(empty, out);
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment