Passing types containing SSE/AVX values

你。 提交于 2019-12-08 01:11:51

问题


Let's say I have the following

struct A
{
    __m256 a;
}
struct B
{
    __m256 a;
    float b;
}

Which of the following's generally better (if any and why) in a hard core loop?

void f0(A a) { ... }
void f1(A& a) { ... } //and the pointer variation
void f2(B b) { ...}
void f3(B& b) { ... } //and the pointer variation

回答1:


The answer is that it doesn't matter.

According to this:

http://msdn.microsoft.com/en-us/library/ms235286.aspx

The calling convention states that 16-byte (and probably 32-byte) operands are always passed by reference. So even if you to pass by value, the compiler will pass it by reference underneath.

In other words, XMM and YMM registers are never passed by value in Windows. But the lower halves of XMM0-4 can still be used to pass 64-bit parameters by value.

EDIT:

In your second example with the float value, there is a slight difference since it will still affect whether or not b is passed by reference or by value.



来源:https://stackoverflow.com/questions/7852783/passing-types-containing-sse-avx-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!