63 short* permute_indexes,
69 unsigned int num_points)
72 const unsigned int num_bytes = num_points * 2;
74 __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;
76 __m128i *p_target, *p_cntl0, *p_cntl1, *p_cntl2, *p_cntl3, *p_scalars;
78 short* p_permute_indexes = permute_indexes;
80 p_target = (__m128i*)target;
81 p_cntl0 = (__m128i*)cntl0;
82 p_cntl1 = (__m128i*)cntl1;
83 p_cntl2 = (__m128i*)cntl2;
84 p_cntl3 = (__m128i*)cntl3;
85 p_scalars = (__m128i*)scalars;
89 int bound = (num_bytes >> 4);
90 int leftovers = (num_bytes >> 1) & 7;
92 xmm0 = _mm_load_si128(p_scalars);
94 xmm1 = _mm_shufflelo_epi16(xmm0, 0);
95 xmm2 = _mm_shufflelo_epi16(xmm0, 0x55);
96 xmm3 = _mm_shufflelo_epi16(xmm0, 0xaa);
97 xmm4 = _mm_shufflelo_epi16(xmm0, 0xff);
99 xmm1 = _mm_shuffle_epi32(xmm1, 0x00);
100 xmm2 = _mm_shuffle_epi32(xmm2, 0x00);
101 xmm3 = _mm_shuffle_epi32(xmm3, 0x00);
102 xmm4 = _mm_shuffle_epi32(xmm4, 0x00);
105 for (;
i < bound; ++
i) {
106 xmm0 = _mm_setzero_si128();
107 xmm5 = _mm_setzero_si128();
108 xmm6 = _mm_setzero_si128();
109 xmm7 = _mm_setzero_si128();
111 xmm0 = _mm_insert_epi16(xmm0, src0[p_permute_indexes[0]], 0);
112 xmm5 = _mm_insert_epi16(xmm5, src0[p_permute_indexes[1]], 1);
113 xmm6 = _mm_insert_epi16(xmm6, src0[p_permute_indexes[2]], 2);
114 xmm7 = _mm_insert_epi16(xmm7, src0[p_permute_indexes[3]], 3);
115 xmm0 = _mm_insert_epi16(xmm0, src0[p_permute_indexes[4]], 4);
116 xmm5 = _mm_insert_epi16(xmm5, src0[p_permute_indexes[5]], 5);
117 xmm6 = _mm_insert_epi16(xmm6, src0[p_permute_indexes[6]], 6);
118 xmm7 = _mm_insert_epi16(xmm7, src0[p_permute_indexes[7]], 7);
120 xmm0 = _mm_add_epi16(xmm0, xmm5);
121 xmm6 = _mm_add_epi16(xmm6, xmm7);
123 p_permute_indexes += 8;
125 xmm0 = _mm_add_epi16(xmm0, xmm6);
127 xmm5 = _mm_load_si128(p_cntl0);
128 xmm6 = _mm_load_si128(p_cntl1);
129 xmm7 = _mm_load_si128(p_cntl2);
131 xmm5 = _mm_and_si128(xmm5, xmm1);
132 xmm6 = _mm_and_si128(xmm6, xmm2);
133 xmm7 = _mm_and_si128(xmm7, xmm3);
135 xmm0 = _mm_add_epi16(xmm0, xmm5);
137 xmm5 = _mm_load_si128(p_cntl3);
139 xmm6 = _mm_add_epi16(xmm6, xmm7);
143 xmm5 = _mm_and_si128(xmm5, xmm4);
145 xmm0 = _mm_add_epi16(xmm0, xmm6);
150 xmm0 = _mm_add_epi16(xmm0, xmm5);
154 _mm_store_si128(p_target, xmm0);
159 for (
i = bound * 8;
i < (bound * 8) + leftovers; ++
i) {
160 target[
i] = src0[permute_indexes[
i]] + (cntl0[
i] & scalars[0]) +
161 (cntl1[
i] & scalars[1]) + (cntl2[
i] & scalars[2]) +
162 (cntl3[
i] & scalars[3]);