替换“typedef int64_t x_t __attribute__((vector_size(16)));
Replacement of "typedef int64_t x_t __attribute__((vector_size(16)));
我在尝试在 VS2013 Community C++ 下编译的一些代码中遇到了上述 typedef。
我找到了对 __declspec(align(16)) 和 allignas(16) 的引用,但无论我如何尝试将它们与 typedef 结合使用,代码的某些部分都会出现问题;使用此类型定义:
typedef __declspec(align(16)) int64_t x_t;
函数声明出现以下错误:
bool funcSame(x_t e1, x_t e2)
{
return e1[eStart] == e2[eStart] && e1[eEnd] == e2[eEnd];
}
上面的错误都是 '[' with: no operator "[]" matches these operands
对于变量声明:
x_t a = { 0, 0 }; // at the 2nd '0' error too many initializer values
代码依赖于 x_t 被视为利用 SSE 操作的两个 64 位值的向量。
有人可以解释一下我如何替换这个 typedef 以获得编译和使用 SSE 操作的代码吗?
谢谢,
格雷厄姆....
如果我 the documentation for the vector_size
attribute 没看错,对齐只是结果的一部分(虽然在链接页面上什至没有提到,但提到了 SIMD,并且 SSE 需要,而且更喜欢对齐的操作数)。
不幸的是,我认为不存在直接的 1:1 替代方案。 VC++ 内在函数包括 __m128
类型,这是一个 16 字节对齐的类型,其大小与 "vector".
相同
请参阅 this question 了解如何比较两个 __m128
变量。
我在尝试在 VS2013 Community C++ 下编译的一些代码中遇到了上述 typedef。
我找到了对 __declspec(align(16)) 和 allignas(16) 的引用,但无论我如何尝试将它们与 typedef 结合使用,代码的某些部分都会出现问题;使用此类型定义:
typedef __declspec(align(16)) int64_t x_t;
函数声明出现以下错误:
bool funcSame(x_t e1, x_t e2)
{
return e1[eStart] == e2[eStart] && e1[eEnd] == e2[eEnd];
}
上面的错误都是 '[' with: no operator "[]" matches these operands
对于变量声明:
x_t a = { 0, 0 }; // at the 2nd '0' error too many initializer values
代码依赖于 x_t 被视为利用 SSE 操作的两个 64 位值的向量。
有人可以解释一下我如何替换这个 typedef 以获得编译和使用 SSE 操作的代码吗?
谢谢, 格雷厄姆....
如果我 the documentation for the vector_size
attribute 没看错,对齐只是结果的一部分(虽然在链接页面上什至没有提到,但提到了 SIMD,并且 SSE 需要,而且更喜欢对齐的操作数)。
不幸的是,我认为不存在直接的 1:1 替代方案。 VC++ 内在函数包括 __m128
类型,这是一个 16 字节对齐的类型,其大小与 "vector".
请参阅 this question 了解如何比较两个 __m128
变量。