Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I pass SSE data to my functions/operators?

I'm writing a couple wrapper classes for the SSE Intrinsics - mostly to get type-safe geometry operations, but also to add a couple convenience functions. All my functions and operators are inline. In theory, they'll all compile directly to raw SSE assembly (no function calls), and my electrons will never leave the XMM registers.

How do I pass my SSE classes as arguments to ensure this result?

I never modify my arguments, so the choice is mostly between passing by value or passing by const reference. I assume a good compiler will optimize both styles down the same code. But I don't know that for sure. Can someone with more experience in the area expound on the best practices?

Thanks in advance!

like image 265
Xavier Holt Avatar asked Oct 06 '22 23:10

Xavier Holt


1 Answers

Either is fine for most compilers, but If you want the code to compile with Visual Studio then use const references, as the Visual Studio compiler is somewhat brain-dead and applies unnecessary ABI restrictions even when the function is inline.

like image 83
Paul R Avatar answered Oct 19 '22 16:10

Paul R