c++ - 在 gcc 中使用结构作为 SSE vector 类型?

标签 c++ c gcc sse

在 GCC 中是否可以使用结构或类作为 SSE 指令的 vector 类型?

类似于:

typedef struct vfloat __attribute__((vector_size(16))) {
   float x,y,z,w;
} vfloat;

而不是规范的:

typedef float v4sf __attribute__ ((vector_size(16)));

union vfloat {
    v4sf  v;
    float f[4];
};

会非常方便,但我似乎无法让它工作。

最佳答案

你能不能像你发布的那样创建一个 union 但使用你的 struct 而不是 float f[4]; 作为第二个成员?这会给你你想要的行为。

关于c++ - 在 gcc 中使用结构作为 SSE vector 类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4917560/

相关文章:

c++ - 使用线程在python中调用多个c++函数

c - ld: cannot perform PE operations on non PE output file 错误

c++ - 如何方便地初始化函数指针数组?

c++ - 无法从 mmod 面部检测器获取 dlib 矩形坐标

c - 通过指针C将数组连接到结构

c - 系统小程序 : Assertion failed - How can I solve?

从 Linux 编译适用于 Windows 的 GTK+ 应用程序

gcc - ARM预取解决方法

c++ - linux C++、libnoise、getvalue() 返回值 > 1? (报告为错误)

c++ - 如何知道磁盘是基本磁盘还是动态磁盘?