在 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/