error c2664 in sse2

error c2664 in sse2

how can i resolve this error?
error C2664: '_mm_mulhi_epi16' : cannot convert parameter 2 from 'const int' to '__m128i'
.h file
class bigyy
{
public:
bigyy();
.
.
.

protected:
__declspec(align(16))static const int pink[5][2];
__declspec(align(16))static const int orange[12];

protected:

__declspec(align(16))int _x;
__declspec(align(16))int _y;
};

.cpp file
#include
const int bigyy::pink[5][2] =
{
{1,2},
{3,4},
{5,6 },
{ 7,8},
{ 9,10 }
};

const int bigyy::orange[12] =
{
0, 2, 2 ,
2, 1, 1 ,
0, 2, 2 ,
2, 1, 1
};

bigyy::bigyy()
{

_x = 1;
_y = _x % 6;

}
__m128i xo,temp;
.
.
.int p=orange[j]
.
.temp = _mm_mulhi_epi16(x0,pink[_y][p])//error C2664: '_mm_mulhi_epi16' : cannot convert parameter 2 from 'const int' to '__m128i'

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Best Reply

this intrinsic expect two __m128i type of parameters.
_mm_muli_epi16(__m128i, __m128i)

x0 is defined as __m128i but pink is an array.
You need to load pink[_y][p] to another __mm128i variable then do the multiplication.

__m128i _pink = __mm_cvtsi32_si128(pinl[_y][p]);

assuming you are loading 32bit integer. (you may have to check exact syntax.).

thanks brijender, the error was sorted after doing the conversion. but another one appeared on the same line.see below

error C2676: binary '[' : '__m128i' does not define this operator or a conversion to a type acceptable to the predefined operator

I am not sure how the code looks after the change. I assume that you are getting error at mm_cvtsi32_si128(). Make sure the parameter is "int" if not, then typecast to "int".
Secondly, I want to make sure that you understand that this instruction (movd) loads only 32bit integer and zeroes out upper part. You may have to shuffle this data up on other 32bit locations in xmm register if you want to broadcast to all locations. or you may have to copy someother data on upper 32bit locations.

it is defined as:

__m128i _mm_cvtsi32_si128 (int a);

and return values:

r0 := a

r1 := 0x0 ; r2 := 0x0 ; r3 := 0x0

note where the error is and i made correction to the initial error.

.h file
class bigyy
{
public:
bigyy();
.
.
.

protected:
__declspec(align(16))static const int pink[5][2];
__declspec(align(16))static const int orange[12];

protected:

__declspec(align(16))int _x;
__declspec(align(16))int _y;
};

.cpp file
#include
const int bigyy::pink[5][2] =
{
{1,2},
{3,4},
{5,6 },
{ 7,8},
{ 9,10 }
};

const int bigyy::orange[12] =
{
0, 2, 2 ,
2, 1, 1 ,
0, 2, 2 ,
2, 1, 1
};

bigyy::bigyy()
{

_x = 1;
_y = _x % 6;

}
__m128i xo,temp;
.
.
.int p=orange[j]
.

__m128i _pink = __mm_cvtsi32_si128(pinl[_y][p]);//this is the change i made and initial error was sorted

.temp
= _mm_mulhi_epi16(x0,pink[_y][p])//error C2676: binary '[' : '__m128i' does not define this operator or a conversion to a type acceptable to the predefined operator.

Instead of
temp = _mm_mulhi_epi16(x0,pink[_y][p])//error C2676: binary '[' : '__m128i' does not define this operator or a conversion to a type acceptable to the predefined operator.

it should be:
temp = _mm_mulhi_epi16(x0, _pink);

Leave a Comment

Please sign in to add a comment. Not a member? Join today