I want to implement the equivalent of C\'s uint-to-double cast in the GHC Haskell compiler. We already implement int-to-double>
uint
double
int
double>
There is a better way
__m128d _mm_cvtsu32_sd(__m128i n) { const __m128i magic_mask = _mm_set_epi32(0, 0, 0x43300000, 0); const __m128d magic_bias = _mm_set_sd(4503599627370496.0); return _mm_sub_sd(_mm_castsi128_pd(_mm_or_si128(n, magic_mask)), magic_bias); }