0

我想知道微软的 SSE 内在函数是否与规范有点不同,因为我尝试使用带有标志的 GCC 编译这段代码-msse -msse2 -msse3 -msse4

#include <stdio.h>
#include <smmintrin.h>

int main ()
{
    __m128i a, b;

    a.m128i_u64[0] = 0x000000000000000;
    b.m128i_u64[0] = 0xFFFFFFFFFFFFFFF;

    a.m128i_u64[1] = 0x000000000000000;
    b.m128i_u64[1] = 0x000000000000000;

    int res1 = _mm_testnzc_si128(a, b);

    a.m128i_u64[0] = 0x000000000000001;

    int res2 = _mm_testnzc_si128(a, b);

    printf_s("First result should be 0: %d\nSecond result should be 1: %d\n",
                res1, res2);

    return 0;
}

它给了我以下错误:

sse_test_not_zero.c||In function 'main':|
sse_test_not_zero.c|8|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|9|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|9|warning: integer constant is too large for 'long' type|
sse_test_not_zero.c|11|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|12|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|16|error: request for member 'm128i_u64' in something not a structure or union|
sse_test_not_zero.c|20|warning: implicit declaration of function 'printf_s'|

在我看来,我需要为这个问题创造struct一个__m128i更好的解决方案,如果其他人知道的话。

4

1 回答 1

2

SSE类型的定义,例如,__m128i在微软领域与世界其他地方不同。如果您想编写可移植的 SSE 代码,那么请坚持所有平台共有的内在函数,并且不要对 SSE 向量类型的定义方式做出任何假设(即将它们视为或多或少不透明的数据类型)。您可以使用适当的_mm_set_xxx内在函数来实现您问题中的代码。

于 2013-07-07T21:43:30.627 回答