在MSVC上从__m128逐位转换为__m128i

Geo*_*ing 10 sse visual-studio

在Linux和Mac上,人们可以做到

__m128 x;
__m128i n = (__m128i)x;
Run Code Online (Sandbox Code Playgroud)

此操作将x的位表示复制到n,并且对于实现在SSE浮点寄存器上操作的各种无分支条件操作很有用.在MSVC 11上,它给出了

eikonal-generated.h(1228) : error C2440: 'type cast' : cannot convert from '__m128' to '__m128i'; No constructor could take the source type, or constructor overload resolution was ambiguous
Run Code Online (Sandbox Code Playgroud)

Microsoft Visual Studio中的等价物是什么?

请注意,我不是要求标准的float-to-int转换函数_mm_cvtepi32_ps,它具有数字上有意义的转换.

Pau*_*l R 17

使用MSVC,您需要使用:

_mm_castsi128_ps从按位投__m128i__m128

_mm_castps_si128从按位投__m128__m128i

对于其他编译器(gcc,ICC ),您可以使用普通的强制转换.