Are there unsigned equivalents of the x87 FILD and SSE CVTSI2SD instructions?

前端 未结 5 1397
离开以前
离开以前 2021-01-18 20:12

I want to implement the equivalent of C\'s uint-to-double cast in the GHC Haskell compiler. We already implement int-to-double

5条回答
  •  温柔的废话
    2021-01-18 21:09

    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);
    }
    

提交回复
热议问题