2
votes

I'm trying to write a little SSE code but can't continue because of this error:

error C2664: '_mm_loadu_ps' : cannot convert parameter 1 from 'const __m128 *' to 'const float *'

I've to load unaligned data and to convert into __m128 in order to use the SSE intrinsics functions. I'm searching on the web but can't get this work. Here's my code:

const Matrix<T> mul_SSE (const Matrix<T>& m)const{
    // ...
    __m128 a = _mm_loadu_ps((__m128 const*)&m(0,0)); //<-Here's the error line
    // ...
}

the parameter m is a matrix of floats. Any suggestion? Thank you very much!

ps. Also if I write __m128 a = _mm_loadu_ps((__m128*)&m(0,0)); it's giving me the same error:

error C2664: '_mm_loadu_ps' : cannot convert parameter 1 from '__m128 *' to 'const float *'

SOLVED: The right way:

__m128 a = _mm_loadu_ps(&m(0,0));
1

1 Answers

0
votes

The documentation on MSDN states that _mm_loadu_ps takes a float* with 4 floats.

You need to pass in a float* pointing to an array of the floats in your matrix (4 actually).

You are casting a reference to your matrix to a __m128 const* when the function expects a float*.