Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Moving an XMM register to a less than 128 bit memory location

soth
Beginner
1,233 Views
Code:
class Vec3_SSE
{

	
public:

	union
	{
		 ALIGN16( float V[3] );
		struct
		{
		 float x,y,z;
		};
	};

	Vec3_SSE()
	{
		x=0.0f;
		y=0.0f;
		z=0.0f;		
	}

	Vec3_SSE(float _x,float _y,float _z)
	{
		x=_x;
		y=_y;
		z=_z;
	};

	
	inline float Normalize(void);//normalizes vector 3d
	};

/////////////////////////////////////////////////////////////////////////////////
float Vec3_SSE::Normalize(void)
{
	float d;
	

	__asm
	{
		mov	edi, this
		movaps	xmm0, [edi]
		movaps	xmm1, xmm0
		mulps	xmm1, xmm1
		haddps	xmm1, xmm1
		haddps	xmm1, xmm1
		sqrtps  xmm1, xmm1
		movss	d, xmm1
		rcpps	xmm1, xmm1
		mulps	xmm0, xmm1

		movaps	[edi], xmm0		//can this lead to memory overrun?

		
	}
	
	return d;
}


The question is :
Can Iget memory corruption by movinga 128 bit register contents to a 96 bit memory location?
At a first glance everything works fine.
0 Kudos
0 Replies
Reply