解决方法
// N number of ints to be added // a,b input array // c sum array // nReg number of required vector registers const unsigned nReg = N*sizeof(uint32_t)/sizeof(__v4si); __v4si a[nReg],b[nReg],c[nReg]; for (unsigned i=0; i<nReg; ++i) c[i] = _mm_add_epi32(a[i],b[i]); // in c++ simply for (unsigned i=0; i<nReg; ++i) c[i] = a[i] + b[i];
根据需要展开循环和预取元素.建议进行性能分析.用__v16qi,__ v8hi,__ v2di替换__v4si为8,16,64位整数.