Testing Compiler Optimization
I'm trying to find out how exactly my compiler optimizes certain code.
The issue is that in any test program I have written MSVC will completely optimize out all the code knowing that it has no visible result!
For example, in an attempt to see how much the compiler can optimize this code:
Code:
Vector3D TestFn( float x, float y, float z )
{
return Vector3D( 1, 2, 3 ) * Vector3D( x, y, z );
}
(This is just a bad example)
Calling the function and saving the result will all simply be compiled out because it knows that I don't use the result.
Code:
Vector a = TestFn( 4, 5, 6 );
How can I trick MSVC into thinking that the return value is used so it will not compile it completely out? Or something similar.
Thanks!
EDIT: I'm looking at the assembly by the way, I want it to generate assembly as if I used the return value instead of generating nothing.