2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2012,2013,2014, 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_
43 #define gmx_mm_castsi128_ps _mm_castsi128_ps
44 #define gmx_mm_extract_epi32 _mm_extract_epi32
46 /* Normal sum of four xmm registers */
47 #define gmx_mm_sum4_ps(t0, t1, t2, t3) _mm_add_ps(_mm_add_ps(t0, t1), _mm_add_ps(t2, t3))
49 static gmx_inline __m128
50 gmx_mm_calc_rsq_ps(__m128 dx, __m128 dy, __m128 dz)
52 return _mm_add_ps( _mm_add_ps( _mm_mul_ps(dx, dx), _mm_mul_ps(dy, dy) ), _mm_mul_ps(dz, dz) );
56 gmx_mm_any_lt(__m128 a, __m128 b)
58 return _mm_movemask_ps(_mm_cmplt_ps(a, b));
61 /* Load a single value from 1-4 places, merge into xmm register */
63 static gmx_inline __m128
64 gmx_mm_load_4real_swizzle_ps(const float * gmx_restrict ptrA,
65 const float * gmx_restrict ptrB,
66 const float * gmx_restrict ptrC,
67 const float * gmx_restrict ptrD)
71 t1 = _mm_unpacklo_ps(_mm_load_ss(ptrA), _mm_load_ss(ptrC));
72 t2 = _mm_unpacklo_ps(_mm_load_ss(ptrB), _mm_load_ss(ptrD));
73 return _mm_unpacklo_ps(t1, t2);
76 static gmx_inline void
77 gmx_mm_store_4real_swizzle_ps(float * gmx_restrict ptrA,
78 float * gmx_restrict ptrB,
79 float * gmx_restrict ptrC,
80 float * gmx_restrict ptrD,
85 t3 = _mm_movehl_ps(_mm_setzero_ps(), xmm1);
86 t2 = _mm_shuffle_ps(xmm1, xmm1, _MM_SHUFFLE(1, 1, 1, 1));
87 t4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1));
88 _mm_store_ss(ptrA, xmm1);
89 _mm_store_ss(ptrB, t2);
90 _mm_store_ss(ptrC, t3);
91 _mm_store_ss(ptrD, t4);
94 /* Similar to store, but increments value in memory */
95 static gmx_inline void
96 gmx_mm_increment_4real_swizzle_ps(float * gmx_restrict ptrA,
97 float * gmx_restrict ptrB,
98 float * gmx_restrict ptrC,
99 float * gmx_restrict ptrD, __m128 xmm1)
103 tmp = gmx_mm_load_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD);
104 tmp = _mm_add_ps(tmp, xmm1);
105 gmx_mm_store_4real_swizzle_ps(ptrA, ptrB, ptrC, ptrD, tmp);
109 static gmx_inline void
110 gmx_mm_load_4pair_swizzle_ps(const float * gmx_restrict p1,
111 const float * gmx_restrict p2,
112 const float * gmx_restrict p3,
113 const float * gmx_restrict p4,
114 __m128 * gmx_restrict c6,
115 __m128 * gmx_restrict c12)
117 __m128 t1, t2, t3, t4;
119 t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p1); /* - - c12a c6a */
120 t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p2); /* - - c12b c6b */
121 t3 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p3); /* - - c12c c6c */
122 t4 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)p4); /* - - c12d c6d */
123 t1 = _mm_unpacklo_ps(t1, t2);
124 t2 = _mm_unpacklo_ps(t3, t4);
125 *c6 = _mm_movelh_ps(t1, t2);
126 *c12 = _mm_movehl_ps(t2, t1);
130 static gmx_inline void
131 gmx_mm_load_shift_and_1rvec_broadcast_ps(const float * gmx_restrict xyz_shift,
132 const float * gmx_restrict xyz,
133 __m128 * gmx_restrict x1,
134 __m128 * gmx_restrict y1,
135 __m128 * gmx_restrict z1)
137 __m128 t1, t2, t3, t4;
139 t1 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift);
140 t2 = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz);
141 t3 = _mm_load_ss(xyz_shift+2);
142 t4 = _mm_load_ss(xyz+2);
143 t1 = _mm_add_ps(t1, t2);
144 t3 = _mm_add_ss(t3, t4);
146 *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0));
147 *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1));
148 *z1 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0));
152 static gmx_inline void
153 gmx_mm_load_shift_and_3rvec_broadcast_ps(const float * gmx_restrict xyz_shift,
154 const float * gmx_restrict xyz,
155 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
156 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
157 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3)
160 __m128 t1, t2, t3, t4, t5, t6;
162 tA = _mm_loadl_pi(_mm_setzero_ps(), (__m64 *)xyz_shift);
163 tB = _mm_load_ss(xyz_shift+2);
165 t1 = _mm_loadu_ps(xyz);
166 t2 = _mm_loadu_ps(xyz+4);
167 t3 = _mm_load_ss(xyz+8);
169 tA = _mm_movelh_ps(tA, tB);
170 t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0));
171 t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1));
172 t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2));
174 t1 = _mm_add_ps(t1, t4);
175 t2 = _mm_add_ps(t2, t5);
176 t3 = _mm_add_ss(t3, t6);
178 *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0));
179 *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1));
180 *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2));
181 *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3));
182 *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0));
183 *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1));
184 *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2));
185 *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3));
186 *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0));
190 static gmx_inline void
191 gmx_mm_load_shift_and_4rvec_broadcast_ps(const float * gmx_restrict xyz_shift,
192 const float * gmx_restrict xyz,
193 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
194 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
195 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3,
196 __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4)
199 __m128 t1, t2, t3, t4, t5, t6;
201 tA = _mm_castpd_ps(_mm_load_sd((const double *)xyz_shift));
202 tB = _mm_load_ss(xyz_shift+2);
204 t1 = _mm_loadu_ps(xyz);
205 t2 = _mm_loadu_ps(xyz+4);
206 t3 = _mm_loadu_ps(xyz+8);
208 tA = _mm_movelh_ps(tA, tB);
209 t4 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(0, 2, 1, 0));
210 t5 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(1, 0, 2, 1));
211 t6 = _mm_shuffle_ps(tA, tA, _MM_SHUFFLE(2, 1, 0, 2));
213 t1 = _mm_add_ps(t1, t4);
214 t2 = _mm_add_ps(t2, t5);
215 t3 = _mm_add_ps(t3, t6);
217 *x1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(0, 0, 0, 0));
218 *y1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(1, 1, 1, 1));
219 *z1 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(2, 2, 2, 2));
220 *x2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 3, 3));
221 *y2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(0, 0, 0, 0));
222 *z2 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(1, 1, 1, 1));
223 *x3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(2, 2, 2, 2));
224 *y3 = _mm_shuffle_ps(t2, t2, _MM_SHUFFLE(3, 3, 3, 3));
225 *z3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(0, 0, 0, 0));
226 *x4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 1, 1, 1));
227 *y4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(2, 2, 2, 2));
228 *z4 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(3, 3, 3, 3));
232 static gmx_inline void
233 gmx_mm_load_1rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA,
234 const float * gmx_restrict ptrB,
235 const float * gmx_restrict ptrC,
236 const float * gmx_restrict ptrD,
237 __m128 * gmx_restrict x1,
238 __m128 * gmx_restrict y1,
239 __m128 * gmx_restrict z1)
241 __m128 t1, t2, t3, t4, t5, t6, t7, t8;
242 t1 = _mm_castpd_ps(_mm_load_sd((const double *)ptrA));
243 t2 = _mm_castpd_ps(_mm_load_sd((const double *)ptrB));
244 t3 = _mm_castpd_ps(_mm_load_sd((const double *)ptrC));
245 t4 = _mm_castpd_ps(_mm_load_sd((const double *)ptrD));
246 t5 = _mm_load_ss(ptrA+2);
247 t6 = _mm_load_ss(ptrB+2);
248 t7 = _mm_load_ss(ptrC+2);
249 t8 = _mm_load_ss(ptrD+2);
250 t1 = _mm_unpacklo_ps(t1, t2);
251 t3 = _mm_unpacklo_ps(t3, t4);
252 *x1 = _mm_movelh_ps(t1, t3);
253 *y1 = _mm_movehl_ps(t3, t1);
254 t5 = _mm_unpacklo_ps(t5, t6);
255 t7 = _mm_unpacklo_ps(t7, t8);
256 *z1 = _mm_movelh_ps(t5, t7);
260 static gmx_inline void
261 gmx_mm_load_3rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA,
262 const float * gmx_restrict ptrB,
263 const float * gmx_restrict ptrC,
264 const float * gmx_restrict ptrD,
265 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
266 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
267 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3)
269 __m128 t1, t2, t3, t4;
270 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrA ) );
271 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrB ) );
272 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrC ) );
273 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)ptrD ) );
274 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
279 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA+4) ) );
280 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+4) ) );
281 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+4) ) );
282 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+4) ) );
283 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
288 t1 = _mm_load_ss(ptrA+8);
289 t2 = _mm_load_ss(ptrB+8);
290 t3 = _mm_load_ss(ptrC+8);
291 t4 = _mm_load_ss(ptrD+8);
292 t1 = _mm_unpacklo_ps(t1, t3);
293 t3 = _mm_unpacklo_ps(t2, t4);
294 *z3 = _mm_unpacklo_ps(t1, t3);
298 static gmx_inline void
299 gmx_mm_load_4rvec_4ptr_swizzle_ps(const float * gmx_restrict ptrA,
300 const float * gmx_restrict ptrB,
301 const float * gmx_restrict ptrC,
302 const float * gmx_restrict ptrD,
303 __m128 * gmx_restrict x1, __m128 * gmx_restrict y1, __m128 * gmx_restrict z1,
304 __m128 * gmx_restrict x2, __m128 * gmx_restrict y2, __m128 * gmx_restrict z2,
305 __m128 * gmx_restrict x3, __m128 * gmx_restrict y3, __m128 * gmx_restrict z3,
306 __m128 * gmx_restrict x4, __m128 * gmx_restrict y4, __m128 * gmx_restrict z4)
308 __m128 t1, t2, t3, t4;
309 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA) ) );
310 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB) ) );
311 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC) ) );
312 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD) ) );
313 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
318 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA+4) ) );
319 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+4) ) );
320 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+4) ) );
321 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+4) ) );
322 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
327 t1 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrA+8) ) );
328 t2 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrB+8) ) );
329 t3 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrC+8) ) );
330 t4 = gmx_mm_castsi128_ps( _mm_lddqu_si128( (void *)(ptrD+8) ) );
331 _MM_TRANSPOSE4_PS(t1, t2, t3, t4);
340 static gmx_inline void
341 gmx_mm_decrement_1rvec_4ptr_swizzle_ps(float * ptrA,
345 __m128 x1, __m128 y1, __m128 z1)
347 __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12;
348 t5 = _mm_unpacklo_ps(y1, z1);
349 t6 = _mm_unpackhi_ps(y1, z1);
350 t7 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(1, 0, 0, 0));
351 t8 = _mm_shuffle_ps(x1, t5, _MM_SHUFFLE(3, 2, 0, 1));
352 t9 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(1, 0, 0, 2));
353 t10 = _mm_shuffle_ps(x1, t6, _MM_SHUFFLE(3, 2, 0, 3));
354 t1 = _mm_load_ss(ptrA);
355 t1 = _mm_loadh_pi(t1, (__m64 *)(ptrA+1));
356 t1 = _mm_sub_ps(t1, t7);
357 _mm_store_ss(ptrA, t1);
358 _mm_storeh_pi((__m64 *)(ptrA+1), t1);
359 t2 = _mm_load_ss(ptrB);
360 t2 = _mm_loadh_pi(t2, (__m64 *)(ptrB+1));
361 t2 = _mm_sub_ps(t2, t8);
362 _mm_store_ss(ptrB, t2);
363 _mm_storeh_pi((__m64 *)(ptrB+1), t2);
364 t3 = _mm_load_ss(ptrC);
365 t3 = _mm_loadh_pi(t3, (__m64 *)(ptrC+1));
366 t3 = _mm_sub_ps(t3, t9);
367 _mm_store_ss(ptrC, t3);
368 _mm_storeh_pi((__m64 *)(ptrC+1), t3);
369 t4 = _mm_load_ss(ptrD);
370 t4 = _mm_loadh_pi(t4, (__m64 *)(ptrD+1));
371 t4 = _mm_sub_ps(t4, t10);
372 _mm_store_ss(ptrD, t4);
373 _mm_storeh_pi((__m64 *)(ptrD+1), t4);
378 #if defined (_MSC_VER) && defined(_M_IX86)
379 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
380 #define gmx_mm_decrement_3rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \
381 _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3) \
383 __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10; \
384 __m128 _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19; \
385 __m128 _t20, _t21, _t22, _t23, _t24, _t25; \
386 _t13 = _mm_unpackhi_ps(_x1, _y1); \
387 _x1 = _mm_unpacklo_ps(_x1, _y1); \
388 _t14 = _mm_unpackhi_ps(_z1, _x2); \
389 _z1 = _mm_unpacklo_ps(_z1, _x2); \
390 _t15 = _mm_unpackhi_ps(_y2, _z2); \
391 _y2 = _mm_unpacklo_ps(_y2, _z2); \
392 _t16 = _mm_unpackhi_ps(_x3, _y3); \
393 _x3 = _mm_unpacklo_ps(_x3, _y3); \
394 _t17 = _mm_shuffle_ps(_z3, _z3, _MM_SHUFFLE(0, 0, 0, 1)); \
395 _t18 = _mm_movehl_ps(_z3, _z3); \
396 _t19 = _mm_shuffle_ps(_t18, _t18, _MM_SHUFFLE(0, 0, 0, 1)); \
397 _t20 = _mm_movelh_ps(_x1, _z1); \
398 _t21 = _mm_movehl_ps(_z1, _x1); \
399 _t22 = _mm_movelh_ps(_t13, _t14); \
400 _t14 = _mm_movehl_ps(_t14, _t13); \
401 _t23 = _mm_movelh_ps(_y2, _x3); \
402 _t24 = _mm_movehl_ps(_x3, _y2); \
403 _t25 = _mm_movelh_ps(_t15, _t16); \
404 _t16 = _mm_movehl_ps(_t16, _t15); \
405 _t1 = _mm_loadu_ps(ptrA); \
406 _t2 = _mm_loadu_ps(ptrA+4); \
407 _t3 = _mm_load_ss(ptrA+8); \
408 _t1 = _mm_sub_ps(_t1, _t20); \
409 _t2 = _mm_sub_ps(_t2, _t23); \
410 _t3 = _mm_sub_ss(_t3, _z3); \
411 _mm_storeu_ps(ptrA, _t1); \
412 _mm_storeu_ps(ptrA+4, _t2); \
413 _mm_store_ss(ptrA+8, _t3); \
414 _t4 = _mm_loadu_ps(ptrB); \
415 _t5 = _mm_loadu_ps(ptrB+4); \
416 _t6 = _mm_load_ss(ptrB+8); \
417 _t4 = _mm_sub_ps(_t4, _t21); \
418 _t5 = _mm_sub_ps(_t5, _t24); \
419 _t6 = _mm_sub_ss(_t6, _t17); \
420 _mm_storeu_ps(ptrB, _t4); \
421 _mm_storeu_ps(ptrB+4, _t5); \
422 _mm_store_ss(ptrB+8, _t6); \
423 _t7 = _mm_loadu_ps(ptrC); \
424 _t8 = _mm_loadu_ps(ptrC+4); \
425 _t9 = _mm_load_ss(ptrC+8); \
426 _t7 = _mm_sub_ps(_t7, _t22); \
427 _t8 = _mm_sub_ps(_t8, _t25); \
428 _t9 = _mm_sub_ss(_t9, _t18); \
429 _mm_storeu_ps(ptrC, _t7); \
430 _mm_storeu_ps(ptrC+4, _t8); \
431 _mm_store_ss(ptrC+8, _t9); \
432 _t10 = _mm_loadu_ps(ptrD); \
433 _t11 = _mm_loadu_ps(ptrD+4); \
434 _t12 = _mm_load_ss(ptrD+8); \
435 _t10 = _mm_sub_ps(_t10, _t14); \
436 _t11 = _mm_sub_ps(_t11, _t16); \
437 _t12 = _mm_sub_ss(_t12, _t19); \
438 _mm_storeu_ps(ptrD, _t10); \
439 _mm_storeu_ps(ptrD+4, _t11); \
440 _mm_store_ss(ptrD+8, _t12); \
443 /* Real function for sane compilers */
444 static gmx_inline void
445 gmx_mm_decrement_3rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB,
446 float * gmx_restrict ptrC, float * gmx_restrict ptrD,
447 __m128 x1, __m128 y1, __m128 z1,
448 __m128 x2, __m128 y2, __m128 z2,
449 __m128 x3, __m128 y3, __m128 z3)
451 __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
452 __m128 t11, t12, t13, t14, t15, t16, t17, t18, t19;
453 __m128 t20, t21, t22, t23, t24, t25;
455 t13 = _mm_unpackhi_ps(x1, y1);
456 x1 = _mm_unpacklo_ps(x1, y1);
457 t14 = _mm_unpackhi_ps(z1, x2);
458 z1 = _mm_unpacklo_ps(z1, x2);
459 t15 = _mm_unpackhi_ps(y2, z2);
460 y2 = _mm_unpacklo_ps(y2, z2);
461 t16 = _mm_unpackhi_ps(x3, y3);
462 x3 = _mm_unpacklo_ps(x3, y3);
463 t17 = _mm_shuffle_ps(z3, z3, _MM_SHUFFLE(0, 0, 0, 1));
464 t18 = _mm_movehl_ps(z3, z3);
465 t19 = _mm_shuffle_ps(t18, t18, _MM_SHUFFLE(0, 0, 0, 1));
466 t20 = _mm_movelh_ps(x1, z1);
467 t21 = _mm_movehl_ps(z1, x1);
468 t22 = _mm_movelh_ps(t13, t14);
469 t14 = _mm_movehl_ps(t14, t13);
470 t23 = _mm_movelh_ps(y2, x3);
471 t24 = _mm_movehl_ps(x3, y2);
472 t25 = _mm_movelh_ps(t15, t16);
473 t16 = _mm_movehl_ps(t16, t15);
474 t1 = _mm_loadu_ps(ptrA);
475 t2 = _mm_loadu_ps(ptrA+4);
476 t3 = _mm_load_ss(ptrA+8);
477 t4 = _mm_loadu_ps(ptrB);
478 t5 = _mm_loadu_ps(ptrB+4);
479 t6 = _mm_load_ss(ptrB+8);
480 t7 = _mm_loadu_ps(ptrC);
481 t8 = _mm_loadu_ps(ptrC+4);
482 t9 = _mm_load_ss(ptrC+8);
483 t10 = _mm_loadu_ps(ptrD);
484 t11 = _mm_loadu_ps(ptrD+4);
485 t12 = _mm_load_ss(ptrD+8);
487 t1 = _mm_sub_ps(t1, t20);
488 t2 = _mm_sub_ps(t2, t23);
489 t3 = _mm_sub_ss(t3, z3);
490 _mm_storeu_ps(ptrA, t1);
491 _mm_storeu_ps(ptrA+4, t2);
492 _mm_store_ss(ptrA+8, t3);
493 t4 = _mm_sub_ps(t4, t21);
494 t5 = _mm_sub_ps(t5, t24);
495 t6 = _mm_sub_ss(t6, t17);
496 _mm_storeu_ps(ptrB, t4);
497 _mm_storeu_ps(ptrB+4, t5);
498 _mm_store_ss(ptrB+8, t6);
499 t7 = _mm_sub_ps(t7, t22);
500 t8 = _mm_sub_ps(t8, t25);
501 t9 = _mm_sub_ss(t9, t18);
502 _mm_storeu_ps(ptrC, t7);
503 _mm_storeu_ps(ptrC+4, t8);
504 _mm_store_ss(ptrC+8, t9);
505 t10 = _mm_sub_ps(t10, t14);
506 t11 = _mm_sub_ps(t11, t16);
507 t12 = _mm_sub_ss(t12, t19);
508 _mm_storeu_ps(ptrD, t10);
509 _mm_storeu_ps(ptrD+4, t11);
510 _mm_store_ss(ptrD+8, t12);
514 #if defined (_MSC_VER) && defined(_M_IX86)
515 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
516 #define gmx_mm_decrement_4rvec_4ptr_swizzle_ps(ptrA, ptrB, ptrC, ptrD, \
517 _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) \
519 __m128 _t1, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t10, _t11; \
520 __m128 _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19, _t20, _t21, _t22; \
522 _t13 = _mm_unpackhi_ps(_x1, _y1); \
523 _x1 = _mm_unpacklo_ps(_x1, _y1); \
524 _t14 = _mm_unpackhi_ps(_z1, _x2); \
525 _z1 = _mm_unpacklo_ps(_z1, _x2); \
526 _t15 = _mm_unpackhi_ps(_y2, _z2); \
527 _y2 = _mm_unpacklo_ps(_y2, _z2); \
528 _t16 = _mm_unpackhi_ps(_x3, _y3); \
529 _x3 = _mm_unpacklo_ps(_x3, _y3); \
530 _t17 = _mm_unpackhi_ps(_z3, _x4); \
531 _z3 = _mm_unpacklo_ps(_z3, _x4); \
532 _t18 = _mm_unpackhi_ps(_y4, _z4); \
533 _y4 = _mm_unpacklo_ps(_y4, _z4); \
534 _t19 = _mm_movelh_ps(_x1, _z1); \
535 _z1 = _mm_movehl_ps(_z1, _x1); \
536 _t20 = _mm_movelh_ps(_t13, _t14); \
537 _t14 = _mm_movehl_ps(_t14, _t13); \
538 _t21 = _mm_movelh_ps(_y2, _x3); \
539 _x3 = _mm_movehl_ps(_x3, _y2); \
540 _t22 = _mm_movelh_ps(_t15, _t16); \
541 _t16 = _mm_movehl_ps(_t16, _t15); \
542 _t23 = _mm_movelh_ps(_z3, _y4); \
543 _y4 = _mm_movehl_ps(_y4, _z3); \
544 _t24 = _mm_movelh_ps(_t17, _t18); \
545 _t18 = _mm_movehl_ps(_t18, _t17); \
546 _t1 = _mm_loadu_ps(ptrA); \
547 _t2 = _mm_loadu_ps(ptrA+4); \
548 _t3 = _mm_loadu_ps(ptrA+8); \
549 _t1 = _mm_sub_ps(_t1, _t19); \
550 _t2 = _mm_sub_ps(_t2, _t21); \
551 _t3 = _mm_sub_ps(_t3, _t23); \
552 _mm_storeu_ps(ptrA, _t1); \
553 _mm_storeu_ps(ptrA+4, _t2); \
554 _mm_storeu_ps(ptrA+8, _t3); \
555 _t4 = _mm_loadu_ps(ptrB); \
556 _t5 = _mm_loadu_ps(ptrB+4); \
557 _t6 = _mm_loadu_ps(ptrB+8); \
558 _t4 = _mm_sub_ps(_t4, _z1); \
559 _t5 = _mm_sub_ps(_t5, _x3); \
560 _t6 = _mm_sub_ps(_t6, _y4); \
561 _mm_storeu_ps(ptrB, _t4); \
562 _mm_storeu_ps(ptrB+4, _t5); \
563 _mm_storeu_ps(ptrB+8, _t6); \
564 _t7 = _mm_loadu_ps(ptrC); \
565 _t8 = _mm_loadu_ps(ptrC+4); \
566 _t9 = _mm_loadu_ps(ptrC+8); \
567 _t7 = _mm_sub_ps(_t7, _t20); \
568 _t8 = _mm_sub_ps(_t8, _t22); \
569 _t9 = _mm_sub_ps(_t9, _t24); \
570 _mm_storeu_ps(ptrC, _t7); \
571 _mm_storeu_ps(ptrC+4, _t8); \
572 _mm_storeu_ps(ptrC+8, _t9); \
573 _t10 = _mm_loadu_ps(ptrD); \
574 _t11 = _mm_loadu_ps(ptrD+4); \
575 _t12 = _mm_loadu_ps(ptrD+8); \
576 _t10 = _mm_sub_ps(_t10, _t14); \
577 _t11 = _mm_sub_ps(_t11, _t16); \
578 _t12 = _mm_sub_ps(_t12, _t18); \
579 _mm_storeu_ps(ptrD, _t10); \
580 _mm_storeu_ps(ptrD+4, _t11); \
581 _mm_storeu_ps(ptrD+8, _t12); \
584 /* Real function for sane compilers */
585 static gmx_inline void
586 gmx_mm_decrement_4rvec_4ptr_swizzle_ps(float * gmx_restrict ptrA, float * gmx_restrict ptrB,
587 float * gmx_restrict ptrC, float * gmx_restrict ptrD,
588 __m128 x1, __m128 y1, __m128 z1,
589 __m128 x2, __m128 y2, __m128 z2,
590 __m128 x3, __m128 y3, __m128 z3,
591 __m128 x4, __m128 y4, __m128 z4)
593 __m128 t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11;
594 __m128 t12, t13, t14, t15, t16, t17, t18, t19, t20, t21, t22;
596 t13 = _mm_unpackhi_ps(x1, y1);
597 x1 = _mm_unpacklo_ps(x1, y1);
598 t14 = _mm_unpackhi_ps(z1, x2);
599 z1 = _mm_unpacklo_ps(z1, x2);
600 t15 = _mm_unpackhi_ps(y2, z2);
601 y2 = _mm_unpacklo_ps(y2, z2);
602 t16 = _mm_unpackhi_ps(x3, y3);
603 x3 = _mm_unpacklo_ps(x3, y3);
604 t17 = _mm_unpackhi_ps(z3, x4);
605 z3 = _mm_unpacklo_ps(z3, x4);
606 t18 = _mm_unpackhi_ps(y4, z4);
607 y4 = _mm_unpacklo_ps(y4, z4);
608 t19 = _mm_movelh_ps(x1, z1);
609 z1 = _mm_movehl_ps(z1, x1);
610 t20 = _mm_movelh_ps(t13, t14);
611 t14 = _mm_movehl_ps(t14, t13);
612 t21 = _mm_movelh_ps(y2, x3);
613 x3 = _mm_movehl_ps(x3, y2);
614 t22 = _mm_movelh_ps(t15, t16);
615 t16 = _mm_movehl_ps(t16, t15);
616 t23 = _mm_movelh_ps(z3, y4);
617 y4 = _mm_movehl_ps(y4, z3);
618 t24 = _mm_movelh_ps(t17, t18);
619 t18 = _mm_movehl_ps(t18, t17);
620 t1 = _mm_loadu_ps(ptrA);
621 t2 = _mm_loadu_ps(ptrA+4);
622 t3 = _mm_loadu_ps(ptrA+8);
623 t1 = _mm_sub_ps(t1, t19);
624 t2 = _mm_sub_ps(t2, t21);
625 t3 = _mm_sub_ps(t3, t23);
626 _mm_storeu_ps(ptrA, t1);
627 _mm_storeu_ps(ptrA+4, t2);
628 _mm_storeu_ps(ptrA+8, t3);
629 t4 = _mm_loadu_ps(ptrB);
630 t5 = _mm_loadu_ps(ptrB+4);
631 t6 = _mm_loadu_ps(ptrB+8);
632 t4 = _mm_sub_ps(t4, z1);
633 t5 = _mm_sub_ps(t5, x3);
634 t6 = _mm_sub_ps(t6, y4);
635 _mm_storeu_ps(ptrB, t4);
636 _mm_storeu_ps(ptrB+4, t5);
637 _mm_storeu_ps(ptrB+8, t6);
638 t7 = _mm_loadu_ps(ptrC);
639 t8 = _mm_loadu_ps(ptrC+4);
640 t9 = _mm_loadu_ps(ptrC+8);
641 t7 = _mm_sub_ps(t7, t20);
642 t8 = _mm_sub_ps(t8, t22);
643 t9 = _mm_sub_ps(t9, t24);
644 _mm_storeu_ps(ptrC, t7);
645 _mm_storeu_ps(ptrC+4, t8);
646 _mm_storeu_ps(ptrC+8, t9);
647 t10 = _mm_loadu_ps(ptrD);
648 t11 = _mm_loadu_ps(ptrD+4);
649 t12 = _mm_loadu_ps(ptrD+8);
650 t10 = _mm_sub_ps(t10, t14);
651 t11 = _mm_sub_ps(t11, t16);
652 t12 = _mm_sub_ps(t12, t18);
653 _mm_storeu_ps(ptrD, t10);
654 _mm_storeu_ps(ptrD+4, t11);
655 _mm_storeu_ps(ptrD+8, t12);
660 static gmx_inline void
661 gmx_mm_update_iforce_1atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
662 float * gmx_restrict fptr,
663 float * gmx_restrict fshiftptr)
667 fix1 = _mm_hadd_ps(fix1, fix1);
668 fiy1 = _mm_hadd_ps(fiy1, fiz1);
670 fix1 = _mm_hadd_ps(fix1, fiy1); /* fiz1 fiy1 fix1 fix1 */
672 t2 = _mm_load_ss(fptr);
673 t2 = _mm_loadh_pi(t2, (__m64 *)(fptr+1));
674 t3 = _mm_load_ss(fshiftptr);
675 t3 = _mm_loadh_pi(t3, (__m64 *)(fshiftptr+1));
677 t2 = _mm_add_ps(t2, fix1);
678 t3 = _mm_add_ps(t3, fix1);
680 _mm_store_ss(fptr, t2);
681 _mm_storeh_pi((__m64 *)(fptr+1), t2);
682 _mm_store_ss(fshiftptr, t3);
683 _mm_storeh_pi((__m64 *)(fshiftptr+1), t3);
686 #if defined (_MSC_VER) && defined(_M_IX86)
687 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
688 #define gmx_mm_update_iforce_3atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, \
691 __m128 _t1, _t2, _t3, _t4; \
693 fix1 = _mm_hadd_ps(fix1, fiy1); \
694 fiz1 = _mm_hadd_ps(fiz1, fix2); \
695 fiy2 = _mm_hadd_ps(fiy2, fiz2); \
696 fix3 = _mm_hadd_ps(fix3, fiy3); \
697 fiz3 = _mm_hadd_ps(fiz3, fiz3); \
698 fix1 = _mm_hadd_ps(fix1, fiz1); \
699 fiy2 = _mm_hadd_ps(fiy2, fix3); \
700 fiz3 = _mm_hadd_ps(fiz3, fiz3); \
701 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \
702 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \
703 _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) )); \
704 _t4 = _mm_load_ss(fshiftptr+2); \
705 _t4 = _mm_loadh_pi(_t4, (__m64 *)(fshiftptr)); \
706 _t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); \
707 _t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); \
708 _t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); \
709 _t3 = _mm_shuffle_ps(_t3, _t3, _MM_SHUFFLE(1, 2, 0, 0)); \
710 _t1 = _mm_add_ps(_t1, _t2); \
711 _t3 = _mm_add_ps(_t3, _t4); \
712 _t1 = _mm_add_ps(_t1, _t3); \
713 _mm_store_ss(fshiftptr+2, _t1); \
714 _mm_storeh_pi((__m64 *)(fshiftptr), _t1); \
717 /* Real function for sane compilers */
718 static gmx_inline void
719 gmx_mm_update_iforce_3atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
720 __m128 fix2, __m128 fiy2, __m128 fiz2,
721 __m128 fix3, __m128 fiy3, __m128 fiz3,
722 float * gmx_restrict fptr,
723 float * gmx_restrict fshiftptr)
725 __m128 t1, t2, t3, t4;
727 fix1 = _mm_hadd_ps(fix1, fiy1);
728 fiz1 = _mm_hadd_ps(fiz1, fix2);
729 fiy2 = _mm_hadd_ps(fiy2, fiz2);
730 fix3 = _mm_hadd_ps(fix3, fiy3);
731 fiz3 = _mm_hadd_ps(fiz3, fiz3);
733 fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */
734 fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */
735 fiz3 = _mm_hadd_ps(fiz3, fiz3); /* - - - fiz3 */
737 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) ));
738 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4)));
739 _mm_store_ss (fptr+8, _mm_add_ss(fiz3, _mm_load_ss(fptr+8) ));
741 t4 = _mm_load_ss(fshiftptr+2);
742 t4 = _mm_loadh_pi(t4, (__m64 *)(fshiftptr));
744 t1 = _mm_shuffle_ps(fiz3, fix1, _MM_SHUFFLE(1, 0, 0, 0)); /* fiy1 fix1 - fiz3 */
745 t2 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(3, 2, 2, 2)); /* fiy3 fix3 - fiz1 */
746 t3 = _mm_shuffle_ps(fiy2, fix1, _MM_SHUFFLE(3, 3, 0, 1)); /* fix2 fix2 fiy2 fiz2 */
747 t3 = _mm_shuffle_ps(t3, t3, _MM_SHUFFLE(1, 2, 0, 0)); /* fiy2 fix2 - fiz2 */
749 t1 = _mm_add_ps(t1, t2);
750 t3 = _mm_add_ps(t3, t4);
751 t1 = _mm_add_ps(t1, t3); /* y x - z */
753 _mm_store_ss(fshiftptr+2, t1);
754 _mm_storeh_pi((__m64 *)(fshiftptr), t1);
758 #if defined (_MSC_VER) && defined(_M_IX86)
759 /* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
760 #define gmx_mm_update_iforce_4atom_swizzle_ps(fix1, fiy1, fiz1, fix2, fiy2, fiz2, fix3, fiy3, fiz3, fix4, fiy4, fiz4, \
763 __m128 _t1, _t2, _t3, _t4, _t5; \
765 fix1 = _mm_hadd_ps(fix1, fiy1); \
766 fiz1 = _mm_hadd_ps(fiz1, fix2); \
767 fiy2 = _mm_hadd_ps(fiy2, fiz2); \
768 fix3 = _mm_hadd_ps(fix3, fiy3); \
769 fiz3 = _mm_hadd_ps(fiz3, fix4); \
770 fiy4 = _mm_hadd_ps(fiy4, fiz4); \
771 fix1 = _mm_hadd_ps(fix1, fiz1); \
772 fiy2 = _mm_hadd_ps(fiy2, fix3); \
773 fiz3 = _mm_hadd_ps(fiz3, fiy4); \
774 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) )); \
775 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4))); \
776 _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8))); \
777 _t5 = _mm_load_ss(fshiftptr+2); \
778 _t5 = _mm_loadh_pi(_t5, (__m64 *)(fshiftptr)); \
779 _t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2)); \
780 _t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1)); \
781 _t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0)); \
782 _t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3)); \
783 _t4 = _mm_shuffle_ps(fiz3, _t4, _MM_SHUFFLE(2, 0, 3, 3)); \
784 _t1 = _mm_add_ps(_t1, _t2); \
785 _t3 = _mm_add_ps(_t3, _t4); \
786 _t1 = _mm_add_ps(_t1, _t3); \
787 _t5 = _mm_add_ps(_t5, _t1); \
788 _mm_store_ss(fshiftptr+2, _t5); \
789 _mm_storeh_pi((__m64 *)(fshiftptr), _t5); \
792 /* Real function for sane compilers */
793 static gmx_inline void
794 gmx_mm_update_iforce_4atom_swizzle_ps(__m128 fix1, __m128 fiy1, __m128 fiz1,
795 __m128 fix2, __m128 fiy2, __m128 fiz2,
796 __m128 fix3, __m128 fiy3, __m128 fiz3,
797 __m128 fix4, __m128 fiy4, __m128 fiz4,
798 float * gmx_restrict fptr,
799 float * gmx_restrict fshiftptr)
801 __m128 t1, t2, t3, t4, t5;
803 fix1 = _mm_hadd_ps(fix1, fiy1);
804 fiz1 = _mm_hadd_ps(fiz1, fix2);
805 fiy2 = _mm_hadd_ps(fiy2, fiz2);
806 fix3 = _mm_hadd_ps(fix3, fiy3);
807 fiz3 = _mm_hadd_ps(fiz3, fix4);
808 fiy4 = _mm_hadd_ps(fiy4, fiz4);
810 fix1 = _mm_hadd_ps(fix1, fiz1); /* fix2 fiz1 fiy1 fix1 */
811 fiy2 = _mm_hadd_ps(fiy2, fix3); /* fiy3 fix3 fiz2 fiy2 */
812 fiz3 = _mm_hadd_ps(fiz3, fiy4); /* fiz4 fiy4 fix4 fiz3 */
814 _mm_storeu_ps(fptr, _mm_add_ps(fix1, _mm_loadu_ps(fptr) ));
815 _mm_storeu_ps(fptr+4, _mm_add_ps(fiy2, _mm_loadu_ps(fptr+4)));
816 _mm_storeu_ps(fptr+8, _mm_add_ps(fiz3, _mm_loadu_ps(fptr+8)));
818 t5 = _mm_load_ss(fshiftptr+2);
819 t5 = _mm_loadh_pi(t5, (__m64 *)(fshiftptr));
821 t1 = _mm_shuffle_ps(fix1, fix1, _MM_SHUFFLE(1, 0, 2, 2));
822 t2 = _mm_shuffle_ps(fiy2, fiy2, _MM_SHUFFLE(3, 2, 1, 1));
823 t3 = _mm_shuffle_ps(fiz3, fiz3, _MM_SHUFFLE(2, 1, 0, 0));
824 t4 = _mm_shuffle_ps(fix1, fiy2, _MM_SHUFFLE(0, 0, 3, 3));
825 t4 = _mm_shuffle_ps(fiz3, t4, _MM_SHUFFLE(2, 0, 3, 3));
827 t1 = _mm_add_ps(t1, t2);
828 t3 = _mm_add_ps(t3, t4);
829 t1 = _mm_add_ps(t1, t3);
830 t5 = _mm_add_ps(t5, t1);
832 _mm_store_ss(fshiftptr+2, t5);
833 _mm_storeh_pi((__m64 *)(fshiftptr), t5);
838 static gmx_inline void
839 gmx_mm_update_1pot_ps(__m128 pot1, float * gmx_restrict ptrA)
841 pot1 = _mm_add_ps(pot1, _mm_movehl_ps(_mm_setzero_ps(), pot1));
842 pot1 = _mm_add_ps(pot1, _mm_shuffle_ps(pot1, pot1, _MM_SHUFFLE(0, 0, 0, 1)));
843 _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA)));
846 static gmx_inline void
847 gmx_mm_update_2pot_ps(__m128 pot1, float * gmx_restrict ptrA,
848 __m128 pot2, float * gmx_restrict ptrB)
851 t1 = _mm_movehl_ps(pot2, pot1);
852 t2 = _mm_movelh_ps(pot1, pot2);
853 t1 = _mm_add_ps(t1, t2);
854 t2 = _mm_shuffle_ps(t1, t1, _MM_SHUFFLE(3, 3, 1, 1));
855 pot1 = _mm_add_ps(t1, t2);
856 pot2 = _mm_movehl_ps(t2, pot1);
857 _mm_store_ss(ptrA, _mm_add_ss(pot1, _mm_load_ss(ptrA)));
858 _mm_store_ss(ptrB, _mm_add_ss(pot2, _mm_load_ss(ptrB)));
862 #endif /* _kernelutil_x86_sse4_1_single_h_ */