Error : casting user defined data types in c

后端 未结 2 1080
旧时难觅i
旧时难觅i 2020-12-21 13:32

This is a simpler view of my Problem, I want to convert a float value into defined type v4si (I want to use SIMD Operation for optimization.) Please help to convert float/do

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-21 13:45

    You don't need to define a custom SIMD vector type (v4si) or mess around with casts and type punning - just use the provided intrinsics in the appropriate *intrin.h header, e.g.

    #include  // use SSE intrinsics 
    
    int main(void)
    {
        __m128 v;          // __m128 is the standard SSE vector type for 4 x float
        float x, y, z, w;
    
        v = _mm_set_ps(x, y, z, w);
                           // use intrinsic to set vector contents to x, y, z, w
    
        // ...
    
        return 0;
    }
    

提交回复
热议问题