[英]incompatible types when assigning to type ‘__m128i’ from type ‘int’
[英]converting from int to (16-bit) __m128i
我將以下代碼作為程序的一部分,但是當我對其進行編譯時,出現以下錯誤:
cannot convert ‘int’ to ‘__m128i {aka __vector(2) long long int}’ in assignment
代碼在哪里:
int t;
int s;
__m128i *array;
__m128i vector;
posix_memalign ((void **) &array, BYTE_ALIGNMENT, n * m * sizeof(__m128i) );
int l=0;
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
{
array[l] = (condition) ? t : s; // fill the array elements with s or t
l++;
}
}
vector = _mm_load_si128( &array[index]);
問題是在這條線
array[l] = (condition) ? t : s;
我發現了指令__m128i _mm_cvtsi32_si128(int a)
但不幸的是,它僅用於32位元素,而我只有16位元素(大小為8的向量)。
最后,我發現此更新正常運行
int t;
int s;
int16_t *array;
__m128i vector;
posix_memalign ((void **) &array, BYTE_ALIGNMENT, n * m * sizeof(int16_t) );
int l=0;
for (int i=0; i<n; i++)
{
for (int j=0; j<m; j++)
{
array[l] = (condition) ? t : s; // fill the array elements with s or t
l++;
}
}
vector = _mm_load_si128( (__m128i*)&array[index]);
謝謝大家
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.