Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Smart_Lubobya
Beginner
120 Views

error c2664 in sse2

Jump to solution
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
.
.temp = _mm_mulhi_epi16(x0,pink[_y]

)//error C2664: '_mm_mulhi_epi16' : cannot convert parameter 2 from 'const int' to '__m128i'

0 Kudos
1 Solution
120 Views
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]

to another __mm128i variable then do the multiplication.

__m128i _pink = __mm_cvtsi32_si128(pinl[_y]

);

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

View solution in original post

5 Replies
121 Views
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]

to another __mm128i variable then do the multiplication.

__m128i _pink = __mm_cvtsi32_si128(pinl[_y]

);

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

View solution in original post

Smart_Lubobya
Beginner
120 Views
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
120 Views

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


Smart_Lubobya
Beginner
120 Views
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
.

__m128i _pink = __mm_cvtsi32_si128(pinl[_y]

);//this is the change i made and initial error was sorted


.temp = _mm_mulhi_epi16(x0,pink[_y]

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

120 Views
Instead of
temp = _mm_mulhi_epi16(x0,pink[_y]

)//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);

Reply