我正在测试pcmpistr指令,它是SSE中的strchr()等价物,但我得到返回值的错误,由于某种原因编译器认为'int'类型变量'idx'是一个向量,但它是一个标量,它应该存储在字符串中找到的字符的索引。这里有什么问题?编译sse内在指令
[[email protected] test]$ cat pcmpistr.c
#include <nmmintrin.h>
#include <stdio.h>
int main(int argc,char **argv) {
int idx;
char str1[16] __attribute__ ((aligned (16))) ={'G','E','T',' ','/','i','n','d','e','x','.','h','t','m','l','\n'} ;
char str2[1] __attribute__ ((aligned (16))) ={'\n'};
__m128i *a,*b;
a=(__m128i*) str1;
b=(__m128i*) str2;
idx=_mm_cmpestri (a, 16, b, 1, _SIDD_UBYTE_OPS |_SIDD_CMP_EQUAL_ANY|_SIDD_LEAST_SIGNIFICANT);
printf("idx=%d\n",idx);
}
[[email protected] test]$ gcc -o pcmpstr pcmpistr.c
pcmpistr.c: In function ‘main’:
pcmpistr.c:13:2: error: can’t convert value to a vector
idx=_mm_cmpestri (a, 16, b, 1, _SIDD_UBYTE_OPS |_SIDD_CMP_EQUAL_ANY|_SIDD_LEAST_SIGNIFICANT);
^
pcmpistr.c:13:2: error: can’t convert value to a vector
[[email protected] test]$
我认为你需要解除引用'a'和'b'。 – fuz