2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
35 #ifndef _kernelutil_x86_sse4_1_single_h_
36 #define _kernelutil_x86_sse4_1_single_h_
40 #include "gromacs/simd/general_x86_sse4_1.h"
45 /* Normal sum of four xmm registers */
46 #define gmx_mm_sum4_ps(t0, t1, t2, t3) _mm_add_ps(_mm_add_ps(t0, t1), _mm_add_ps(t2, t3))
48 static gmx_inline __m128
49 gmx_mm_calc_rsq_ps(__m128 dx, __m128 dy, __m128 dz)
51 return _mm_add_ps( _mm_add_ps( _mm_mul_ps(dx, dx), _mm_mul_ps(dy, dy) ), _mm_mul_ps(dz, dz) );
55 gmx_mm_any_lt(__m128 a, __m128 b)
57 return _mm_movemask_ps(_mm_cmplt_ps(a, b));
60 /* Load a single value from 1-4 places, merge into xmm register */
62 static gmx_inline __m128
63 gmx_mm_load_4real_swizzle_ps(const float * gmx_restrict ptrA,
64 const float * gmx_restrict ptrB,
65 const float * gmx_restrict ptrC,
66 const float * gmx_restrict ptrD)
70 t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA), _mm_load_ss(ptrC));
71 t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB), _mm_load_ss(ptrD));
72 return _mm_unpacklo_ps(t1, t2);
75 static gmx_inline void
76 gmx_mm_store_4real_swizzle_ps(float * gmx_restrict ptrA,
77 float * gmx_restrict ptrB,
78 float * gmx_restrict ptrC,
79 float * gmx_restrict ptrD,
84 t3 = _mm_movehl_ps(_mm_setzero_ps(), xmm1);
85 t2 = _mm_shuffle_ps(xmm1, xmm1, _MM_SHUFFLE(1, 1, 1, 1));
86 t4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1));
87 _mm_store_ss(ptrA, xmm1);
88 _mm_store_ss(ptrB, t2);
89 _mm_store_ss(ptrC, t3);
90 _mm_store_ss(ptrD, t4);
93 /* Similar to store, but increments value in memory */
94 static gmx_inline void
95 gmx_mm_increment_4real_swizzle_ps(float * gmx_restrict ptrA,
96 float * gmx_restrict ptrB,
97 float * gmx_restrict ptrC,
98 float * gmx_restrict ptrD, __m128 xmm1)
102 tmp = gmx_mm_load_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD);
103 tmp = _mm_add_ps(tmp, xmm1);
104 gmx_mm_store_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, tmp);
108 static gmx_inline void
109 gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1,
110 const float * gmx_restrict p2,
111 const float * gmx_restrict p3,
112 const float * gmx_restrict p4,
113 __m128 * gmx_restrict c6,
114 __m128 * gmx_restrict c12)
116 __m128 t1, t2, t3, t4;
118 t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p1); /* - - c12a c6a */
119 t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p2); /* - - c12b c6b */
120 t3 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p3); /* - - c12c c6c */
121 t4 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p4); /* - - c12d c6d */
122 t1 = _mm_unpacklo_ps(t1, t2);
123 t2 = _mm_unpacklo_ps(t3, t4);
124 *c6 = _mm_movelh_ps(t1, t2);
125 *c12 = _mm_movehl_ps(t2, t1);
129 static gmx_inline void
130 gmx_mm_load_shift_and_1rvec_broadcast_ps(const float * gmx_restrict xyz_shift,
131 const float * gmx_restrict xyz,
132 __m128 * gmx_restrict x1,
133 __m128 * gmx_restrict y1,
134 __m128 * gmx_restrict z1)
136 __m128 t1, t2, t3, t4;
138 t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift);
139 t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz);
140 t3 = _mm_load_ss(xyz_shift+2);
141 t4 = _mm_load_ss(xyz+2);
142 t1 = _mm_add_ps(t1, t2);
143 t3 = _mm_add_ss(t3, t4);
145 *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0));
146 *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1));
147 *z1 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0));
151 static gmx_inline void
152 gmx_mm_load_shift_and_3rvec_broadcast_ps(const float * gmx_restrict xyz_shift,
153 const float * gmx_restrict xyz,
154 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
155 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
156 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3)
159 __m128 t1, t2, t3, t4, t5, t6;
161 tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift);
162 tB = _mm_load_ss(xyz_shift+2);
164 t1 = _mm_loadu_ps(xyz);
165 t2 = _mm_loadu_ps(xyz+4);
166 t3 = _mm_load_ss(xyz+8);
168 tA = _mm_movelh_ps(tA, tB);
169 t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0));
170 t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1));
171 t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2));
173 t1 = _mm_add_ps(t1, t4);
174 t2 = _mm_add_ps(t2, t5);
175 t3 = _mm_add_ss(t3, t6);
177 *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0));
178 *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1));
179 *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2));
180 *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3));
181 *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0));
182 *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1));
183 *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2));
184 *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3));
185 *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0));
189 static gmx_inline void
190 gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift,
191 const float * gmx_restrict xyz,
192 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
193 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
194 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3,
195 __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4)
198 __m128 t1, t2, t3, t4, t5, t6;
200 tA = _mm_castpd_ps(_mm_load_sd((const double *)xyz_shift));
201 tB = _mm_load_ss(xyz_shift+2);
203 t1 = _mm_loadu_ps(xyz);
204 t2 = _mm_loadu_ps(xyz+4);
205 t3 = _mm_loadu_ps(xyz+8);
207 tA = _mm_movelh_ps(tA, tB);
208 t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0));
209 t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1));
210 t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2));
212 t1 = _mm_add_ps(t1, t4);
213 t2 = _mm_add_ps(t2, t5);
214 t3 = _mm_add_ps(t3, t6);
216 *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0));
217 *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1));
218 *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2));
219 *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3));
220 *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0));
221 *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1));
222 *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2));
223 *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3));
224 *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0));
225 *x4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1));
226 *y4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(2, 2, 2, 2));
227 *z4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(3, 3, 3, 3));
231 static gmx_inline void
232 gmx_mm_load_1rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA,
233 const float * gmx_restrict ptrB,
234 const float * gmx_restrict ptrC,
235 const float * gmx_restrict ptrD,
236 __m128 * gmx_restrict x1,
237 __m128 * gmx_restrict y1,
238 __m128 * gmx_restrict z1)
240 __m128 t1, t2, t3, t4, t5, t6, t7, t8;
241 t1 = _mm_castpd_ps(_mm_load_sd((const double *)ptrA));
242 t2 = _mm_castpd_ps(_mm_load_sd((const double *)ptrB));
243 t3 = _mm_castpd_ps(_mm_load_sd((const double *)ptrC));
244 t4 = _mm_castpd_ps(_mm_load_sd((const double *)ptrD));
245 t5 = _mm_load_ss(ptrA+2);
246 t6 = _mm_load_ss(ptrB+2);
247 t7 = _mm_load_ss(ptrC+2);
248 t8 = _mm_load_ss(ptrD+2);
249 t1 = _mm_unpacklo_ps(t1, t2);
250 t3 = _mm_unpacklo_ps(t3, t4);
251 *x1 = _mm_movelh_ps(t1, t3);
252 *y1 = _mm_movehl_ps(t3, t1);
253 t5 = _mm_unpacklo_ps(t5, t6);
254 t7 = _mm_unpacklo_ps(t7, t8);
255 *z1 = _mm_movelh_ps(t5, t7);
259 static gmx_inline void
260 gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA,
261 const float * gmx_restrict ptrB,
262 const float * gmx_restrict ptrC,
263 const float * gmx_restrict ptrD,
264 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
265 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
266 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3)
268 __m128 t1, t2, t3, t4;
269 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrA ) );
270 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrB ) );
271 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrC ) );
272 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrD ) );
273 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
278 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA+4) ) );
279 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+4) ) );
280 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+4) ) );
281 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+4) ) );
282 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
287 t1 = _mm_load_ss(ptrA+8);
288 t2 = _mm_load_ss(ptrB+8);
289 t3 = _mm_load_ss(ptrC+8);
290 t4 = _mm_load_ss(ptrD+8);
291 t1 = _mm_unpacklo_ps(t1, t3);
292 t3 = _mm_unpacklo_ps(t2, t4);
293 *z3 = _mm_unpacklo_ps(t1, t3);
297 static gmx_inline void
298 gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA,
299 const float * gmx_restrict ptrB,
300 const float * gmx_restrict ptrC,
301 const float * gmx_restrict ptrD,
302 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
303 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
304 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3,
305 __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4)
307 __m128 t1, t2, t3, t4;
308 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA) ) );
309 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB) ) );
310 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC) ) );
311 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD) ) );
312 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
317 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA+4) ) );
318 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+4) ) );
319 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+4) ) );
320 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+4) ) );
321 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
326 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA+8) ) );
327 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+8) ) );
328 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+8) ) );
329 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+8) ) );
330 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
339 static gmx_inline void
340 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(float * ptrA,
344 __m128 x1, __m128 y1, __m128 z1)
346 __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12;
347 t5 = _mm_unpacklo_ps(y1, z1);
348 t6 = _mm_unpackhi_ps(y1, z1);
349 t7 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(1, 0, 0, 0));
350 t8 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(3, 2, 0, 1));
351 t9 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(1, 0, 0, 2));
352 t10 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(3, 2, 0, 3));
353 t1 = _mm_load_ss(ptrA);
354 t1 = _mm_loadh_pi(t1, (__m64 *)(ptrA+1));
355 t1 = _mm_sub_ps(t1, t7);
356 _mm_store_ss(ptrA, t1);
357 _mm_storeh_pi((__m64 *)(ptrA+1), t1);
358 t2 = _mm_load_ss(ptrB);
359 t2 = _mm_loadh_pi(t2, (__m64 *)(ptrB+1));
360 t2 = _mm_sub_ps(t2, t8);
361 _mm_store_ss(ptrB, t2);
362 _mm_storeh_pi((__m64 *)(ptrB+1), t2);
363 t3 = _mm_load_ss(ptrC);
364 t3 = _mm_loadh_pi(t3, (__m64 *)(ptrC+1));
365 t3 = _mm_sub_ps(t3, t9);
366 _mm_store_ss(ptrC, t3);
367 _mm_storeh_pi((__m64 *)(ptrC+1), t3);
368 t4 = _mm_load_ss(ptrD);
369 t4 = _mm_loadh_pi(t4, (__m64 *)(ptrD+1));
370 t4 = _mm_sub_ps(t4, t10);
371 _mm_store_ss(ptrD, t4);
372 _mm_storeh_pi((__m64 *)(ptrD+1), t4);
377 #if defined (_MSC_VER) && defined(_M_IX86)
378 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
379 #define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \
380 _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \
382 __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \
383 __m128 _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19; \
384 __m128 _t20, _t21, _t22, _t23, _t24, _t25; \
385 _t13 = _mm_unpackhi_ps(_x1, _y1); \
386 _x1 = _mm_unpacklo_ps(_x1, _y1); \
387 _t14 = _mm_unpackhi_ps(_z1, _x2); \
388 _z1 = _mm_unpacklo_ps(_z1, _x2); \
389 _t15 = _mm_unpackhi_ps(_y2, _z2); \
390 _y2 = _mm_unpacklo_ps(_y2, _z2); \
391 _t16 = _mm_unpackhi_ps(_x3, _y3); \
392 _x3 = _mm_unpacklo_ps(_x3, _y3); \
393 _t17 = _mm_shuffle_ps(_z3, _z3, _MM_SHUFFLE(0, 0, 0, 1)); \
394 _t18 = _mm_movehl_ps(_z3, _z3); \
395 _t19 = _mm_shuffle_ps(_t18, _t18, _MM_SHUFFLE(0, 0, 0, 1)); \
396 _t20 = _mm_movelh_ps(_x1, _z1); \
397 _t21 = _mm_movehl_ps(_z1, _x1); \
398 _t22 = _mm_movelh_ps(_t13, _t14); \
399 _t14 = _mm_movehl_ps(_t14, _t13); \
400 _t23 = _mm_movelh_ps(_y2, _x3); \
401 _t24 = _mm_movehl_ps(_x3, _y2); \
402 _t25 = _mm_movelh_ps(_t15, _t16); \
403 _t16 = _mm_movehl_ps(_t16, _t15); \
404 _t1 = _mm_loadu_ps(ptrA); \
405 _t2 = _mm_loadu_ps(ptrA+4); \
406 _t3 = _mm_load_ss(ptrA+8); \
407 _t1 = _mm_sub_ps(_t1, _t20); \
408 _t2 = _mm_sub_ps(_t2, _t23); \
409 _t3 = _mm_sub_ss(_t3, _z3); \
410 _mm_storeu_ps(ptrA, _t1); \
411 _mm_storeu_ps(ptrA+4, _t2); \
412 _mm_store_ss(ptrA+8, _t3); \
413 _t4 = _mm_loadu_ps(ptrB); \
414 _t5 = _mm_loadu_ps(ptrB+4); \
415 _t6 = _mm_load_ss(ptrB+8); \
416 _t4 = _mm_sub_ps(_t4, _t21); \
417 _t5 = _mm_sub_ps(_t5, _t24); \
418 _t6 = _mm_sub_ss(_t6, _t17); \
419 _mm_storeu_ps(ptrB, _t4); \
420 _mm_storeu_ps(ptrB+4, _t5); \
421 _mm_store_ss(ptrB+8, _t6); \
422 _t7 = _mm_loadu_ps(ptrC); \
423 _t8 = _mm_loadu_ps(ptrC+4); \
424 _t9 = _mm_load_ss(ptrC+8); \
425 _t7 = _mm_sub_ps(_t7, _t22); \
426 _t8 = _mm_sub_ps(_t8, _t25); \
427 _t9 = _mm_sub_ss(_t9, _t18); \
428 _mm_storeu_ps(ptrC, _t7); \
429 _mm_storeu_ps(ptrC+4, _t8); \
430 _mm_store_ss(ptrC+8, _t9); \
431 _t10 = _mm_loadu_ps(ptrD); \
432 _t11 = _mm_loadu_ps(ptrD+4); \
433 _t12 = _mm_load_ss(ptrD+8); \
434 _t10 = _mm_sub_ps(_t10, _t14); \
435 _t11 = _mm_sub_ps(_t11, _t16); \
436 _t12 = _mm_sub_ss(_t12, _t19); \
437 _mm_storeu_ps(ptrD, _t10); \
438 _mm_storeu_ps(ptrD+4, _t11); \
439 _mm_store_ss(ptrD+8, _t12); \
442 /* Real function for sane compilers */
443 static gmx_inline void
444 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB,
445 float * gmx_restrict ptrC, float * gmx_restrict ptrD,
446 __m128 x1, __m128 y1, __m128 z1,
447 __m128 x2, __m128 y2, __m128 z2,
448 __m128 x3, __m128 y3, __m128 z3)
450 __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
451 __m128 t11, t12, t13, t14, t15, t16, t17, t18, t19;
452 __m128 t20, t21, t22, t23, t24, t25;
454 t13 = _mm_unpackhi_ps(x1, y1);
455 x1 = _mm_unpacklo_ps(x1, y1);
456 t14 = _mm_unpackhi_ps(z1, x2);
457 z1 = _mm_unpacklo_ps(z1, x2);
458 t15 = _mm_unpackhi_ps(y2, z2);
459 y2 = _mm_unpacklo_ps(y2, z2);
460 t16 = _mm_unpackhi_ps(x3, y3);
461 x3 = _mm_unpacklo_ps(x3, y3);
462 t17 = _mm_shuffle_ps(z3, z3, _MM_SHUFFLE(0, 0, 0, 1));
463 t18 = _mm_movehl_ps(z3, z3);
464 t19 = _mm_shuffle_ps(t18, t18, _MM_SHUFFLE(0, 0, 0, 1));
465 t20 = _mm_movelh_ps(x1, z1);
466 t21 = _mm_movehl_ps(z1, x1);
467 t22 = _mm_movelh_ps(t13, t14);
468 t14 = _mm_movehl_ps(t14, t13);
469 t23 = _mm_movelh_ps(y2, x3);
470 t24 = _mm_movehl_ps(x3, y2);
471 t25 = _mm_movelh_ps(t15, t16);
472 t16 = _mm_movehl_ps(t16, t15);
473 t1 = _mm_loadu_ps(ptrA);
474 t2 = _mm_loadu_ps(ptrA+4);
475 t3 = _mm_load_ss(ptrA+8);
476 t4 = _mm_loadu_ps(ptrB);
477 t5 = _mm_loadu_ps(ptrB+4);
478 t6 = _mm_load_ss(ptrB+8);
479 t7 = _mm_loadu_ps(ptrC);
480 t8 = _mm_loadu_ps(ptrC+4);
481 t9 = _mm_load_ss(ptrC+8);
482 t10 = _mm_loadu_ps(ptrD);
483 t11 = _mm_loadu_ps(ptrD+4);
484 t12 = _mm_load_ss(ptrD+8);
486 t1 = _mm_sub_ps(t1, t20);
487 t2 = _mm_sub_ps(t2, t23);
488 t3 = _mm_sub_ss(t3, z3);
489 _mm_storeu_ps(ptrA, t1);
490 _mm_storeu_ps(ptrA+4, t2);
491 _mm_store_ss(ptrA+8, t3);
492 t4 = _mm_sub_ps(t4, t21);
493 t5 = _mm_sub_ps(t5, t24);
494 t6 = _mm_sub_ss(t6, t17);
495 _mm_storeu_ps(ptrB, t4);
496 _mm_storeu_ps(ptrB+4, t5);
497 _mm_store_ss(ptrB+8, t6);
498 t7 = _mm_sub_ps(t7, t22);
499 t8 = _mm_sub_ps(t8, t25);
500 t9 = _mm_sub_ss(t9, t18);
501 _mm_storeu_ps(ptrC, t7);
502 _mm_storeu_ps(ptrC+4, t8);
503 _mm_store_ss(ptrC+8, t9);
504 t10 = _mm_sub_ps(t10, t14);
505 t11 = _mm_sub_ps(t11, t16);
506 t12 = _mm_sub_ss(t12, t19);
507 _mm_storeu_ps(ptrD, t10);
508 _mm_storeu_ps(ptrD+4, t11);
509 _mm_store_ss(ptrD+8, t12);
513 #if defined (_MSC_VER) && defined(_M_IX86)
514 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
515 #define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \
516 _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \
518 __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11; \
519 __m128 _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22; \
521 _t13 = _mm_unpackhi_ps(_x1, _y1); \
522 _x1 = _mm_unpacklo_ps(_x1, _y1); \
523 _t14 = _mm_unpackhi_ps(_z1, _x2); \
524 _z1 = _mm_unpacklo_ps(_z1, _x2); \
525 _t15 = _mm_unpackhi_ps(_y2, _z2); \
526 _y2 = _mm_unpacklo_ps(_y2, _z2); \
527 _t16 = _mm_unpackhi_ps(_x3, _y3); \
528 _x3 = _mm_unpacklo_ps(_x3, _y3); \
529 _t17 = _mm_unpackhi_ps(_z3, _x4); \
530 _z3 = _mm_unpacklo_ps(_z3, _x4); \
531 _t18 = _mm_unpackhi_ps(_y4, _z4); \
532 _y4 = _mm_unpacklo_ps(_y4, _z4); \
533 _t19 = _mm_movelh_ps(_x1, _z1); \
534 _z1 = _mm_movehl_ps(_z1, _x1); \
535 _t20 = _mm_movelh_ps(_t13, _t14); \
536 _t14 = _mm_movehl_ps(_t14, _t13); \
537 _t21 = _mm_movelh_ps(_y2, _x3); \
538 _x3 = _mm_movehl_ps(_x3, _y2); \
539 _t22 = _mm_movelh_ps(_t15, _t16); \
540 _t16 = _mm_movehl_ps(_t16, _t15); \
541 _t23 = _mm_movelh_ps(_z3, _y4); \
542 _y4 = _mm_movehl_ps(_y4, _z3); \
543 _t24 = _mm_movelh_ps(_t17, _t18); \
544 _t18 = _mm_movehl_ps(_t18, _t17); \
545 _t1 = _mm_loadu_ps(ptrA); \
546 _t2 = _mm_loadu_ps(ptrA+4); \
547 _t3 = _mm_loadu_ps(ptrA+8); \
548 _t1 = _mm_sub_ps(_t1, _t19); \
549 _t2 = _mm_sub_ps(_t2, _t21); \
550 _t3 = _mm_sub_ps(_t3, _t23); \
551 _mm_storeu_ps(ptrA, _t1); \
552 _mm_storeu_ps(ptrA+4, _t2); \
553 _mm_storeu_ps(ptrA+8, _t3); \
554 _t4 = _mm_loadu_ps(ptrB); \
555 _t5 = _mm_loadu_ps(ptrB+4); \
556 _t6 = _mm_loadu_ps(ptrB+8); \
557 _t4 = _mm_sub_ps(_t4, _z1); \
558 _t5 = _mm_sub_ps(_t5, _x3); \
559 _t6 = _mm_sub_ps(_t6, _y4); \
560 _mm_storeu_ps(ptrB, _t4); \
561 _mm_storeu_ps(ptrB+4, _t5); \
562 _mm_storeu_ps(ptrB+8, _t6); \
563 _t7 = _mm_loadu_ps(ptrC); \
564 _t8 = _mm_loadu_ps(ptrC+4); \
565 _t9 = _mm_loadu_ps(ptrC+8); \
566 _t7 = _mm_sub_ps(_t7, _t20); \
567 _t8 = _mm_sub_ps(_t8, _t22); \
568 _t9 = _mm_sub_ps(_t9, _t24); \
569 _mm_storeu_ps(ptrC, _t7); \
570 _mm_storeu_ps(ptrC+4, _t8); \
571 _mm_storeu_ps(ptrC+8, _t9); \
572 _t10 = _mm_loadu_ps(ptrD); \
573 _t11 = _mm_loadu_ps(ptrD+4); \
574 _t12 = _mm_loadu_ps(ptrD+8); \
575 _t10 = _mm_sub_ps(_t10, _t14); \
576 _t11 = _mm_sub_ps(_t11, _t16); \
577 _t12 = _mm_sub_ps(_t12, _t18); \
578 _mm_storeu_ps(ptrD, _t10); \
579 _mm_storeu_ps(ptrD+4, _t11); \
580 _mm_storeu_ps(ptrD+8, _t12); \
583 /* Real function for sane compilers */
584 static gmx_inline void
585 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB,
586 float * gmx_restrict ptrC, float * gmx_restrict ptrD,
587 __m128 x1, __m128 y1, __m128 z1,
588 __m128 x2, __m128 y2, __m128 z2,
589 __m128 x3, __m128 y3, __m128 z3,
590 __m128 x4, __m128 y4, __m128 z4)
592 __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11;
593 __m128 t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22;
595 t13 = _mm_unpackhi_ps(x1, y1);
596 x1 = _mm_unpacklo_ps(x1, y1);
597 t14 = _mm_unpackhi_ps(z1, x2);
598 z1 = _mm_unpacklo_ps(z1, x2);
599 t15 = _mm_unpackhi_ps(y2, z2);
600 y2 = _mm_unpacklo_ps(y2, z2);
601 t16 = _mm_unpackhi_ps(x3, y3);
602 x3 = _mm_unpacklo_ps(x3, y3);
603 t17 = _mm_unpackhi_ps(z3, x4);
604 z3 = _mm_unpacklo_ps(z3, x4);
605 t18 = _mm_unpackhi_ps(y4, z4);
606 y4 = _mm_unpacklo_ps(y4, z4);
607 t19 = _mm_movelh_ps(x1, z1);
608 z1 = _mm_movehl_ps(z1, x1);
609 t20 = _mm_movelh_ps(t13, t14);
610 t14 = _mm_movehl_ps(t14, t13);
611 t21 = _mm_movelh_ps(y2, x3);
612 x3 = _mm_movehl_ps(x3, y2);
613 t22 = _mm_movelh_ps(t15, t16);
614 t16 = _mm_movehl_ps(t16, t15);
615 t23 = _mm_movelh_ps(z3, y4);
616 y4 = _mm_movehl_ps(y4, z3);
617 t24 = _mm_movelh_ps(t17, t18);
618 t18 = _mm_movehl_ps(t18, t17);
619 t1 = _mm_loadu_ps(ptrA);
620 t2 = _mm_loadu_ps(ptrA+4);
621 t3 = _mm_loadu_ps(ptrA+8);
622 t1 = _mm_sub_ps(t1, t19);
623 t2 = _mm_sub_ps(t2, t21);
624 t3 = _mm_sub_ps(t3, t23);
625 _mm_storeu_ps(ptrA, t1);
626 _mm_storeu_ps(ptrA+4, t2);
627 _mm_storeu_ps(ptrA+8, t3);
628 t4 = _mm_loadu_ps(ptrB);
629 t5 = _mm_loadu_ps(ptrB+4);
630 t6 = _mm_loadu_ps(ptrB+8);
631 t4 = _mm_sub_ps(t4, z1);
632 t5 = _mm_sub_ps(t5, x3);
633 t6 = _mm_sub_ps(t6, y4);
634 _mm_storeu_ps(ptrB, t4);
635 _mm_storeu_ps(ptrB+4, t5);
636 _mm_storeu_ps(ptrB+8, t6);
637 t7 = _mm_loadu_ps(ptrC);
638 t8 = _mm_loadu_ps(ptrC+4);
639 t9 = _mm_loadu_ps(ptrC+8);
640 t7 = _mm_sub_ps(t7, t20);
641 t8 = _mm_sub_ps(t8, t22);
642 t9 = _mm_sub_ps(t9, t24);
643 _mm_storeu_ps(ptrC, t7);
644 _mm_storeu_ps(ptrC+4, t8);
645 _mm_storeu_ps(ptrC+8, t9);
646 t10 = _mm_loadu_ps(ptrD);
647 t11 = _mm_loadu_ps(ptrD+4);
648 t12 = _mm_loadu_ps(ptrD+8);
649 t10 = _mm_sub_ps(t10, t14);
650 t11 = _mm_sub_ps(t11, t16);
651 t12 = _mm_sub_ps(t12, t18);
652 _mm_storeu_ps(ptrD, t10);
653 _mm_storeu_ps(ptrD+4, t11);
654 _mm_storeu_ps(ptrD+8, t12);
659 static gmx_inline void
660 gmx_mm_update_iforce_1atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
661 float * gmx_restrict fptr,
662 float * gmx_restrict fshiftptr)
666 fix1 = _mm_hadd_ps(fix1, fix1);
667 fiy1 = _mm_hadd_ps(fiy1, fiz1);
669 fix1 = _mm_hadd_ps(fix1, fiy1); /* fiz1 fiy1 fix1 fix1 */
671 t2 = _mm_load_ss(fptr);
672 t2 = _mm_loadh_pi(t2, (__m64 *)(fptr+1));
673 t3 = _mm_load_ss(fshiftptr);
674 t3 = _mm_loadh_pi(t3, (__m64 *)(fshiftptr+1));
676 t2 = _mm_add_ps(t2, fix1);
677 t3 = _mm_add_ps(t3, fix1);
679 _mm_store_ss(fptr, t2);
680 _mm_storeh_pi((__m64 *)(fptr+1), t2);
681 _mm_store_ss(fshiftptr, t3);
682 _mm_storeh_pi((__m64 *)(fshiftptr+1), t3);
685 #if defined (_MSC_VER) && defined(_M_IX86)
686 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
687 #define gmx_mm_update_iforce_3atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \
690 __m128 _t1, _t2, _t3, _t4; \
692 fix1 = _mm_hadd_ps(fix1, fiy1); \
693 fiz1 = _mm_hadd_ps(fiz1, fix2); \
694 fiy2 = _mm_hadd_ps(fiy2, fiz2); \
695 fix3 = _mm_hadd_ps(fix3, fiy3); \
696 fiz3 = _mm_hadd_ps(fiz3, fiz3); \
697 fix1 = _mm_hadd_ps(fix1, fiz1); \
698 fiy2 = _mm_hadd_ps(fiy2, fix3); \
699 fiz3 = _mm_hadd_ps(fiz3, fiz3); \
700 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \
701 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \
702 _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); \
703 _t4 = _mm_load_ss(fshiftptr+2); \
704 _t4 = _mm_loadh_pi(_t4, (__m64 *)(fshiftptr)); \
705 _t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); \
706 _t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); \
707 _t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); \
708 _t3 = _mm_shuffle_ps(_t3, _t3, _MM_SHUFFLE(1, 2, 0, 0)); \
709 _t1 = _mm_add_ps(_t1, _t2); \
710 _t3 = _mm_add_ps(_t3, _t4); \
711 _t1 = _mm_add_ps(_t1, _t3); \
712 _mm_store_ss(fshiftptr+2, _t1); \
713 _mm_storeh_pi((__m64 *)(fshiftptr), _t1); \
716 /* Real function for sane compilers */
717 static gmx_inline void
718 gmx_mm_update_iforce_3atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
719 __m128 fix2, __m128 fiy2, __m128 fiz2,
720 __m128 fix3, __m128 fiy3, __m128 fiz3,
721 float * gmx_restrict fptr,
722 float * gmx_restrict fshiftptr)
724 __m128 t1, t2, t3, t4;
726 fix1 = _mm_hadd_ps(fix1, fiy1);
727 fiz1 = _mm_hadd_ps(fiz1, fix2);
728 fiy2 = _mm_hadd_ps(fiy2, fiz2);
729 fix3 = _mm_hadd_ps(fix3, fiy3);
730 fiz3 = _mm_hadd_ps(fiz3, fiz3);
732 fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */
733 fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */
734 fiz3 = _mm_hadd_ps(fiz3, fiz3); /* - - - fiz3 */
736 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) ));
737 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4)));
738 _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) ));
740 t4 = _mm_load_ss(fshiftptr+2);
741 t4 = _mm_loadh_pi(t4, (__m64 *)(fshiftptr));
743 t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); /* fiy1 fix1 - fiz3 */
744 t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); /* fiy3 fix3 - fiz1 */
745 t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); /* fix2 fix2 fiy2 fiz2 */
746 t3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 2, 0, 0)); /* fiy2 fix2 - fiz2 */
748 t1 = _mm_add_ps(t1, t2);
749 t3 = _mm_add_ps(t3, t4);
750 t1 = _mm_add_ps(t1, t3); /* y x - z */
752 _mm_store_ss(fshiftptr+2, t1);
753 _mm_storeh_pi((__m64 *)(fshiftptr), t1);
757 #if defined (_MSC_VER) && defined(_M_IX86)
758 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
759 #define gmx_mm_update_iforce_4atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \
762 __m128 _t1, _t2, _t3, _t4, _t5; \
764 fix1 = _mm_hadd_ps(fix1, fiy1); \
765 fiz1 = _mm_hadd_ps(fiz1, fix2); \
766 fiy2 = _mm_hadd_ps(fiy2, fiz2); \
767 fix3 = _mm_hadd_ps(fix3, fiy3); \
768 fiz3 = _mm_hadd_ps(fiz3, fix4); \
769 fiy4 = _mm_hadd_ps(fiy4, fiz4); \
770 fix1 = _mm_hadd_ps(fix1, fiz1); \
771 fiy2 = _mm_hadd_ps(fiy2, fix3); \
772 fiz3 = _mm_hadd_ps(fiz3, fiy4); \
773 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \
774 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \
775 _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); \
776 _t5 = _mm_load_ss(fshiftptr+2); \
777 _t5 = _mm_loadh_pi(_t5, (__m64 *)(fshiftptr)); \
778 _t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2)); \
779 _t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1)); \
780 _t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0)); \
781 _t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); \
782 _t4 = _mm_shuffle_ps(fiz3, _t4, _MM_SHUFFLE(2, 0, 3, 3)); \
783 _t1 = _mm_add_ps(_t1, _t2); \
784 _t3 = _mm_add_ps(_t3, _t4); \
785 _t1 = _mm_add_ps(_t1, _t3); \
786 _t5 = _mm_add_ps(_t5, _t1); \
787 _mm_store_ss(fshiftptr+2, _t5); \
788 _mm_storeh_pi((__m64 *)(fshiftptr), _t5); \
791 /* Real function for sane compilers */
792 static gmx_inline void
793 gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
794 __m128 fix2, __m128 fiy2, __m128 fiz2,
795 __m128 fix3, __m128 fiy3, __m128 fiz3,
796 __m128 fix4, __m128 fiy4, __m128 fiz4,
797 float * gmx_restrict fptr,
798 float * gmx_restrict fshiftptr)
800 __m128 t1, t2, t3, t4, t5;
802 fix1 = _mm_hadd_ps(fix1, fiy1);
803 fiz1 = _mm_hadd_ps(fiz1, fix2);
804 fiy2 = _mm_hadd_ps(fiy2, fiz2);
805 fix3 = _mm_hadd_ps(fix3, fiy3);
806 fiz3 = _mm_hadd_ps(fiz3, fix4);
807 fiy4 = _mm_hadd_ps(fiy4, fiz4);
809 fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */
810 fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */
811 fiz3 = _mm_hadd_ps(fiz3, fiy4); /* fiz4 fiy4 fix4 fiz3 */
813 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) ));
814 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4)));
815 _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8)));
817 t5 = _mm_load_ss(fshiftptr+2);
818 t5 = _mm_loadh_pi(t5, (__m64 *)(fshiftptr));
820 t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2));
821 t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1));
822 t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0));
823 t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3));
824 t4 = _mm_shuffle_ps(fiz3, t4, _MM_SHUFFLE(2, 0, 3, 3));
826 t1 = _mm_add_ps(t1, t2);
827 t3 = _mm_add_ps(t3, t4);
828 t1 = _mm_add_ps(t1, t3);
829 t5 = _mm_add_ps(t5, t1);
831 _mm_store_ss(fshiftptr+2, t5);
832 _mm_storeh_pi((__m64 *)(fshiftptr), t5);
837 static gmx_inline void
838 gmx_mm_update_1pot_ps(__m128 pot1, float * gmx_restrict ptrA)
840 pot1 = _mm_add_ps(pot1, _mm_movehl_ps(_mm_setzero_ps(), pot1));
841 pot1 = _mm_add_ps(pot1, _mm_shuffle_ps(pot1, pot1, _MM_SHUFFLE(0, 0, 0, 1)));
842 _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA)));
845 static gmx_inline void
846 gmx_mm_update_2pot_ps(__m128 pot1, float * gmx_restrict ptrA,
847 __m128 pot2, float * gmx_restrict ptrB)
850 t1 = _mm_movehl_ps(pot2, pot1);
851 t2 = _mm_movelh_ps(pot1, pot2);
852 t1 = _mm_add_ps(t1, t2);
853 t2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 1, 1));
854 pot1 = _mm_add_ps(t1, t2);
855 pot2 = _mm_movehl_ps(t2, pot1);
856 _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA)));
857 _mm_store_ss(ptrB, _mm_add_ss(pot2, _mm_load_ss(ptrB)));
861 #endif /* _kernelutil_x86_sse4_1_single_h_ */