gue*_*est 5 c optimization gcc sse simd
如果可能,我想使用SSE指令优化以下代码段:
/*
* the data structure
*/
typedef struct v3d v3d;
struct v3d {
double x;
double y;
double z;
} tmp = { 1.0, 2.0, 3.0 };
/*
* the part that should be "optimized"
*/
tmp.x /= 4.0;
tmp.y /= 4.0;
tmp.z /= 4.0;
Run Code Online (Sandbox Code Playgroud)
这有可能吗?
足够tmp.x *= 0.25;的?
请注意,对于 SSE 指令(如果您想使用它们),重要的是:
1)所有内存访问都是16字节对齐
2) 操作是循环执行的
3) 不执行 int <-> float 或 float <-> double 转换
4)尽可能避免分裂