Original Post
Hy! I've written this member function for SSE-accelereted matrix-matrix mutiplication: 1, UINL void Matrix4A::Mul_SSE_v2(const Matrix4A& m1, const Matrix4A& m2) 2, { 3, if(this == &m1) 4, { 5, Matrix4A tmp(m1); 6, __asm 7, { 8, lea eax, dword ptr [tmp] 9, mov ecx, dword ptr [m2] 10, } 11, } else 12, { 13, __asm 14, { 15, mov eax, dword ptr [m1] 16, mov ecx, dword ptr [m2] 17, } . } . __asm . { . //---------PART-0--------// . movaps xmm0, [eax + m00]; . ... . ... . ... . } .} This functions multiplies two matrices m1 and m2 and stores the result in *this. The problem becomes real when "m1 is (*this)". Since m1 and the result is the same matrix, I need to create a temporary matrix to store the original matrix m1 (before I overwrite it). My question is: Is it a bad thing to declare a variable tmp (line 5) inside the if(...) segment, save it's address and reuse it later OUTSIDE the if() segment? Or is it the better way to copy-paste my Multiplyes ASM code after booth versions of the loader code (line 3-17)? The code works fine; and runs about 3.1x times faster than normal C++ code without SSE.