Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_avx_256_double / kernelutil_x86_avx_256_double.h
index e915536c5f95844860c9899bd318a187455d4ce2..c00b6dad84608efb553e9b70546edf65055a9f7c 100644 (file)
@@ -77,7 +77,7 @@ gmx_mm256_load_4real_swizzle_pd(const double * gmx_restrict ptrA, const double *
 
     t1 = _mm_unpacklo_pd(_mm_load_sd(ptrA),_mm_load_sd(ptrB));
     t2 = _mm_unpacklo_pd(_mm_load_sd(ptrC),_mm_load_sd(ptrD));
-    return gmx_mm256_set_m128(t2,t1);
+    return gmx_mm256_set_m128d(t2,t1);
 }
 
 
@@ -201,8 +201,8 @@ gmx_mm256_load_4pair_swizzle_pd(const double * gmx_restrict p1, const double * g
 {
     __m256d t1,t2;
 
-    t1   = gmx_mm256_set_m128(_mm_loadu_pd(p3),_mm_loadu_pd(p1)); /* c12c  c6c | c12a  c6a */
-    t2   = gmx_mm256_set_m128(_mm_loadu_pd(p4),_mm_loadu_pd(p2)); /* c12d  c6d | c12b  c6b */
+    t1   = gmx_mm256_set_m128d(_mm_loadu_pd(p3),_mm_loadu_pd(p1)); /* c12c  c6c | c12a  c6a */
+    t2   = gmx_mm256_set_m128d(_mm_loadu_pd(p4),_mm_loadu_pd(p2)); /* c12d  c6d | c12b  c6b */
 
     *c6  = _mm256_unpacklo_pd(t1,t2); /* c6d c6c | c6b c6a */
     *c12 = _mm256_unpackhi_pd(t1,t2); /* c12d c12c | c12b c12a */
@@ -211,10 +211,10 @@ gmx_mm256_load_4pair_swizzle_pd(const double * gmx_restrict p1, const double * g
 
 static gmx_inline void
 gmx_mm256_load_shift_and_1rvec_broadcast_pd(const double * gmx_restrict xyz_shift,
-                                            const double * gmx_restrict xyz,
-                                            __m256d * gmx_restrict x1,
-                                            __m256d * gmx_restrict y1,
-                                            __m256d * gmx_restrict z1)
+        const double * gmx_restrict xyz,
+        __m256d * gmx_restrict x1,
+        __m256d * gmx_restrict y1,
+        __m256d * gmx_restrict z1)
 {
     __m128d mem_xy,mem_z,mem_sxy,mem_sz,tx,ty,tz;
 
@@ -230,18 +230,18 @@ gmx_mm256_load_shift_and_1rvec_broadcast_pd(const double * gmx_restrict xyz_shif
     ty  = _mm_shuffle_pd(mem_xy,mem_xy,_MM_SHUFFLE2(1,1));
     tz  = _mm_shuffle_pd(mem_z,mem_z,_MM_SHUFFLE2(0,0));
 
-    *x1 = gmx_mm256_set_m128(tx,tx);
-    *y1 = gmx_mm256_set_m128(ty,ty);
-    *z1 = gmx_mm256_set_m128(tz,tz);
+    *x1 = gmx_mm256_set_m128d(tx,tx);
+    *y1 = gmx_mm256_set_m128d(ty,ty);
+    *z1 = gmx_mm256_set_m128d(tz,tz);
 }
 
 
 static gmx_inline void
 gmx_mm256_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shift,
-                                            const double * gmx_restrict xyz,
-                                            __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                            __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2,
-                                            __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3)
+        const double * gmx_restrict xyz,
+        __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
+        __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2,
+        __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3)
 {
     __m128d t1,t2,t3,t4,t5,sxy,sz,szx,syz,tx,ty,tz;
 
@@ -265,31 +265,31 @@ gmx_mm256_load_shift_and_3rvec_broadcast_pd(const double * gmx_restrict xyz_shif
     tx   = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0));
     ty   = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1));
     tz   = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0));
-    *x1 = gmx_mm256_set_m128(tx,tx);
-    *y1 = gmx_mm256_set_m128(ty,ty);
-    *z1 = gmx_mm256_set_m128(tz,tz);
+    *x1 = gmx_mm256_set_m128d(tx,tx);
+    *y1 = gmx_mm256_set_m128d(ty,ty);
+    *z1 = gmx_mm256_set_m128d(tz,tz);
     tx   = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1));
     ty   = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0));
     tz   = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1));
-    *x2 = gmx_mm256_set_m128(tx,tx);
-    *y2 = gmx_mm256_set_m128(ty,ty);
-    *z2 = gmx_mm256_set_m128(tz,tz);
+    *x2 = gmx_mm256_set_m128d(tx,tx);
+    *y2 = gmx_mm256_set_m128d(ty,ty);
+    *z2 = gmx_mm256_set_m128d(tz,tz);
     tx   = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0));
     ty   = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1));
     tz   = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0));
-    *x3 = gmx_mm256_set_m128(tx,tx);
-    *y3 = gmx_mm256_set_m128(ty,ty);
-    *z3 = gmx_mm256_set_m128(tz,tz);
+    *x3 = gmx_mm256_set_m128d(tx,tx);
+    *y3 = gmx_mm256_set_m128d(ty,ty);
+    *z3 = gmx_mm256_set_m128d(tz,tz);
 }
 
 
 static gmx_inline void
 gmx_mm256_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shift,
-                                            const double * gmx_restrict xyz,
-                                            __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                            __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2,
-                                            __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3,
-                                            __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4)
+        const double * gmx_restrict xyz,
+        __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
+        __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2,
+        __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3,
+        __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4)
 {
     __m128d t1,t2,t3,t4,t5,t6,sxy,sz,szx,syz,tx,ty,tz;
 
@@ -315,27 +315,27 @@ gmx_mm256_load_shift_and_4rvec_broadcast_pd(const double * gmx_restrict xyz_shif
     tx   = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(0,0));
     ty   = _mm_shuffle_pd(t1,t1,_MM_SHUFFLE2(1,1));
     tz   = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(0,0));
-    *x1 = gmx_mm256_set_m128(tx,tx);
-    *y1 = gmx_mm256_set_m128(ty,ty);
-    *z1 = gmx_mm256_set_m128(tz,tz);
+    *x1 = gmx_mm256_set_m128d(tx,tx);
+    *y1 = gmx_mm256_set_m128d(ty,ty);
+    *z1 = gmx_mm256_set_m128d(tz,tz);
     tx   = _mm_shuffle_pd(t2,t2,_MM_SHUFFLE2(1,1));
     ty   = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(0,0));
     tz   = _mm_shuffle_pd(t3,t3,_MM_SHUFFLE2(1,1));
-    *x2 = gmx_mm256_set_m128(tx,tx);
-    *y2 = gmx_mm256_set_m128(ty,ty);
-    *z2 = gmx_mm256_set_m128(tz,tz);
+    *x2 = gmx_mm256_set_m128d(tx,tx);
+    *y2 = gmx_mm256_set_m128d(ty,ty);
+    *z2 = gmx_mm256_set_m128d(tz,tz);
     tx   = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(0,0));
     ty   = _mm_shuffle_pd(t4,t4,_MM_SHUFFLE2(1,1));
     tz   = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(0,0));
-    *x3 = gmx_mm256_set_m128(tx,tx);
-    *y3 = gmx_mm256_set_m128(ty,ty);
-    *z3 = gmx_mm256_set_m128(tz,tz);
+    *x3 = gmx_mm256_set_m128d(tx,tx);
+    *y3 = gmx_mm256_set_m128d(ty,ty);
+    *z3 = gmx_mm256_set_m128d(tz,tz);
     tx   = _mm_shuffle_pd(t5,t5,_MM_SHUFFLE2(1,1));
     ty   = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(0,0));
     tz   = _mm_shuffle_pd(t6,t6,_MM_SHUFFLE2(1,1));
-    *x4 = gmx_mm256_set_m128(tx,tx);
-    *y4 = gmx_mm256_set_m128(ty,ty);
-    *z4 = gmx_mm256_set_m128(tz,tz);
+    *x4 = gmx_mm256_set_m128d(tx,tx);
+    *y4 = gmx_mm256_set_m128d(ty,ty);
+    *z4 = gmx_mm256_set_m128d(tz,tz);
 }
 
 
@@ -352,27 +352,6 @@ gmx_mm256_load_1rvec_1ptr_swizzle_pd(const double * gmx_restrict p1,
 }
 
 
-static void
-gmx_mm256_load_2rvec_1ptr_swizzle_pd(const double * gmx_restrict p1,
-                                     __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                     __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2)
-{
-    __m256d t1,t2,t3;
-
-    t1            = _mm256_loadu_pd(p1);                         /* x2 z1 | y1 x1 */
-    t2            = _mm256_castpd128_pd256(_mm_loadu_pd(p1+4));  /*  -  - | z2 y2 */
-
-    *x1           = t1;
-    *y2           = t2;
-
-    t3            = gmx_mm256_unpack128hi_pd(t1,t1);
-
-    *z1           = t3;
-    *y1           = _mm256_permute_pd(t1,_GMX_MM_PERMUTE256D(0,1,0,1));
-    *z2           = _mm256_permute_pd(t2,_GMX_MM_PERMUTE256D(0,1,0,1));
-    *x2           = _mm256_permute_pd(t3,_GMX_MM_PERMUTE256D(0,1,0,1));
-}
-
 static void
 gmx_mm256_load_3rvec_1ptr_swizzle_pd(const double * gmx_restrict p1,
                                      __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
@@ -408,7 +387,7 @@ gmx_mm256_load_4rvec_1ptr_swizzle_pd(const double * gmx_restrict p1,
     t1            = _mm256_loadu_pd(p1);
     t2            = _mm256_loadu_pd(p1+4);
     t3            = _mm256_loadu_pd(p1+8);
-    
+
     t4            = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1,0x1));
     t5            = _mm256_castpd128_pd256(_mm256_extractf128_pd(t2,0x1));
     t6            = _mm256_castpd128_pd256(_mm256_extractf128_pd(t3,0x1));
@@ -419,7 +398,7 @@ gmx_mm256_load_4rvec_1ptr_swizzle_pd(const double * gmx_restrict p1,
     *z1           = t4;
     *x3           = t5;
     *y4           = t6;
-    
+
     *y1           = _mm256_permute_pd(t1,_GMX_MM_PERMUTE256D(0,1,0,1));
     *z2           = _mm256_permute_pd(t2,_GMX_MM_PERMUTE256D(0,1,0,1));
     *x4           = _mm256_permute_pd(t3,_GMX_MM_PERMUTE256D(0,1,0,1));
@@ -429,128 +408,12 @@ gmx_mm256_load_4rvec_1ptr_swizzle_pd(const double * gmx_restrict p1,
 }
 
 
-static void
-gmx_mm256_load_1rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB,
-                                     __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1)
-{
-    __m256d tA,tB,tC;
-
-    tA           = _mm256_loadu_pd(ptrA); /*  - z1 | y1 x1 */
-    tB           = _mm256_loadu_pd(ptrB); /*  - z2 | y2 x2 */
-
-    tC           = _mm256_unpacklo_pd(tA,tB);  /* z2 z1 | x2 x1 */
-
-    *x1          = tC;
-    *y1          = _mm256_unpackhi_pd(tA,tB);
-    *z1          = _mm256_castpd128_pd256(_mm256_extractf128_pd(tC,0x1));
-}
-
-
-static void
-gmx_mm256_load_2rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB,
-                                     __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                     __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2)
-{
-    __m256d t1,t2,t3,t4,t5;
-
-    t1           = _mm256_loadu_pd(ptrA);          /*  x2a z1a | y1a x1a */
-    t2           = _mm256_loadu_pd(ptrB);          /*  x2b z1b | y1b x1b */
-    t3           = _mm256_castpd128_pd256(_mm_loadu_pd(ptrA+4));        /*   -   -  | z2a y2a */
-    t4           = _mm256_castpd128_pd256(_mm_loadu_pd(ptrB+4));        /*   -   -  | z2b y2b */
-    
-    t5           = _mm256_unpacklo_pd(t1,t2);      /*  z1b z1a | x1b x1a */
-    t1           = _mm256_unpackhi_pd(t1,t2);      /*  x2b x2a | y1b y1a */
-    *y2          = _mm256_unpacklo_pd(t3,t4);      /*   -   -  | y2b y2a */
-    *z2          = _mm256_unpackhi_pd(t3,t4);      /*   -   -  | z2b z2a */
-    *x1          = t5;
-    *y1          = t1;
-    *z1          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t5,0x1));;
-    *x2          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1,0x1));
-}
-
-
-static void
-gmx_mm256_load_3rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB,
-                                     __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                     __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2,
-                                     __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3)
-{
-    __m256d t1,t2,t3,t4,t5,t6,t7;
-
-    t1           = _mm256_loadu_pd(ptrA);          /*  x2a z1a | y1a x1a */
-    t2           = _mm256_loadu_pd(ptrB);          /*  x2b z1b | y1b x1b */
-    t3           = _mm256_loadu_pd(ptrA+4);        /*  y3a x3a | z2a y2a */
-    t4           = _mm256_loadu_pd(ptrB+4);        /*  y3b x3b | z2b y2b */
-    t5           = _mm256_castpd128_pd256(_mm_load_sd(ptrA+8));        /*   -   -  |  -  z3a */
-    t6           = _mm256_castpd128_pd256(_mm_load_sd(ptrB+8));        /*   -   -  |  -  z3b */
-
-    t7           = _mm256_unpacklo_pd(t1,t2);      /*  z1b z1a | x1b x1a */
-    t1           = _mm256_unpackhi_pd(t1,t2);      /*  x2b x2a | y1b y1a */
-
-    t2           = _mm256_unpacklo_pd(t3,t4);      /*  x3b x3a | y2b y2a */
-    t3           = _mm256_unpackhi_pd(t3,t4);      /*  y3b y3a | z2b z2a */
-
-    *z3          = _mm256_unpacklo_pd(t5,t6);      /*   -   -  | z3b z3a */
-
-    *x1          = t7;
-    *y1          = t1;
-    *y2          = t2;
-    *z2          = t3;
-    *z1          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t7,0x1));;
-    *x2          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1,0x1));
-    *x3          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t2,0x1));;
-    *y3          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t3,0x1));
-}
-
-
-static void
-gmx_mm256_load_4rvec_2ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB,
-                                     __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                     __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2,
-                                     __m256d * gmx_restrict x3, __m256d * gmx_restrict y3, __m256d * gmx_restrict z3,
-                                     __m256d * gmx_restrict x4, __m256d * gmx_restrict y4, __m256d * gmx_restrict z4)
-{
-    __m256d t1,t2,t3,t4,t5,t6,t7;
-
-    t1           = _mm256_loadu_pd(ptrA);          /*  x2a z1a | y1a x1a */
-    t2           = _mm256_loadu_pd(ptrB);          /*  x2b z1b | y1b x1b */
-    t3           = _mm256_loadu_pd(ptrA+4);        /*  y3a x3a | z2a y2a */
-    t4           = _mm256_loadu_pd(ptrB+4);        /*  y3b x3b | z2b y2b */
-    t5           = _mm256_loadu_pd(ptrA+8);        /*  z4a y4a | x4a z3a */
-    t6           = _mm256_loadu_pd(ptrB+8);        /*  z4b y4b | x4b z3b */
-
-    t7           = _mm256_unpacklo_pd(t1,t2);      /*  z1b z1a | x1b x1a */
-    t1           = _mm256_unpackhi_pd(t1,t2);      /*  x2b x2a | y1b y1a */
-
-    t2           = _mm256_unpacklo_pd(t3,t4);      /*  x3b x3a | y2b y2a */
-    t3           = _mm256_unpackhi_pd(t3,t4);      /*  y3b y3a | z2b z2a */
-
-    t4           = _mm256_unpacklo_pd(t5,t6);      /*  y4b y4a | z3b z3a */
-    t5           = _mm256_unpackhi_pd(t5,t6);      /*  z4b z4a | x4b x4a */
-
-    *x1          = t7;
-    *y1          = t1;
-    *y2          = t2;
-    *z2          = t3;
-    *z3          = t4;
-    *x4          = t5;
-
-    *z1          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t7,0x1));;
-    *x2          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t1,0x1));
-    *x3          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t2,0x1));;
-    *y3          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t3,0x1));
-    *y4          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t4,0x1));;
-    *z4          = _mm256_castpd128_pd256(_mm256_extractf128_pd(t5,0x1));
-}
-
-
-
 static void
 gmx_mm256_load_1rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB,
                                      const double * gmx_restrict ptrC, const double * gmx_restrict ptrD,
                                      __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1)
 {
-     __m256d t1,t2,t3,t4,t5,t6;
+    __m256d t1,t2,t3,t4,t5,t6;
 
     t1           = _mm256_loadu_pd(ptrA);        /*   -  z1a | y1a x1a */
     t2           = _mm256_loadu_pd(ptrB);        /*   -  z1b | y1b x1b */
@@ -567,40 +430,6 @@ gmx_mm256_load_1rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const dou
     *z1          = gmx_mm256_unpack128hi_pd(t5,t1);
 }
 
-static void
-gmx_mm256_load_2rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const double * gmx_restrict ptrB,
-                                     const double * gmx_restrict ptrC, const double * gmx_restrict ptrD,
-                                     __m256d * gmx_restrict x1, __m256d * gmx_restrict y1, __m256d * gmx_restrict z1,
-                                     __m256d * gmx_restrict x2, __m256d * gmx_restrict y2, __m256d * gmx_restrict z2)
-{
-    __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
-
-    t1           = _mm256_loadu_pd(ptrA);        /*  x2a z1a | y1a x1a */
-    t2           = _mm256_loadu_pd(ptrB);        /*  x2b z1b | y1b x1b */
-    t3           = _mm256_loadu_pd(ptrC);        /*  x2c z1c | y1c x1c */
-    t4           = _mm256_loadu_pd(ptrD);        /*  x2d z1d | y1d x1d */
-    t5           = _mm256_castpd128_pd256(_mm_loadu_pd(ptrA+4));      /*   -   -  | z2a y2a */
-    t6           = _mm256_castpd128_pd256(_mm_loadu_pd(ptrB+4));      /*   -   -  | z2b y2b */
-    t7           = _mm256_castpd128_pd256(_mm_loadu_pd(ptrC+4));      /*   -   -  | z2c y2c */
-    t8           = _mm256_castpd128_pd256(_mm_loadu_pd(ptrD+4));      /*   -   -  | z2d y2d */
-
-    t9           = _mm256_unpacklo_pd(t1,t2);      /*  z1b z1a | x1b x1a */
-    t10          = _mm256_unpackhi_pd(t1,t2);      /*  x2b x2a | y1b y1a */
-    t1           = _mm256_unpacklo_pd(t3,t4);      /*  z1d z1c | x1d x1c */
-    t2           = _mm256_unpackhi_pd(t3,t4);      /*  x2d x2c | y1d y1c */
-    t3           = _mm256_unpacklo_pd(t5,t6);      /*   -   -  | y2b y2a */
-    t4           = _mm256_unpackhi_pd(t5,t6);      /*   -   -  | z2b z2a */
-    t5           = _mm256_unpacklo_pd(t7,t8);      /*   -   -  | y2d y2c */
-    t6           = _mm256_unpackhi_pd(t7,t8);      /*   -   -  | z2d z2c */
-
-    *x1          = gmx_mm256_unpack128lo_pd(t9,t1);
-    *y1          = gmx_mm256_unpack128lo_pd(t10,t2);
-    *z1          = gmx_mm256_unpack128hi_pd(t9,t1);
-
-    *x2          = gmx_mm256_unpack128hi_pd(t10,t2);
-    *y2          = gmx_mm256_unpack128lo_pd(t3,t5);
-    *z2          = gmx_mm256_unpack128lo_pd(t4,t6);
-}
 
 
 static void
@@ -705,375 +534,10 @@ gmx_mm256_load_4rvec_4ptr_swizzle_pd(const double * gmx_restrict ptrA, const dou
 
 
 
-/* Routines to decrement rvec in memory, typically use for j particle force updates */
-static void
-gmx_mm256_decrement_1rvec_1ptr_noswizzle_pd(double * gmx_restrict ptrA, __m256d xyz)
-{
-    __m256d t1,t2;
-
-    t1  = _mm256_loadu_pd(ptrA);
-    t2  = _mm256_blend_pd(_mm256_setzero_pd(),xyz,0x7);
-    t1  = _mm256_sub_pd(t1,t2);
-    /* OK to add zeros and store more values here, since we only do a single store that cannot overlap */
-    _mm256_storeu_pd(ptrA,t1);
-}
-
-
-
-static void
-gmx_mm256_decrement_3rvec_1ptr_noswizzle_pd(double * gmx_restrict ptrA,
-                                            __m256d xyz1, __m256d xyz2, __m256d xyz3)
-{
-    __m256d t1,t2;
-    __m256d tA,tB;
-    __m128d tC;
-
-    tA   = _mm256_loadu_pd(ptrA);
-    tB   = _mm256_loadu_pd(ptrA+4);
-    tC   = _mm_load_sd(ptrA+8);
-
-    /* xyz1:  -  z1 | y1 x1 */
-    /* xyz2:  -  z2 | y2 x2 */
-    /* xyz3:  -  z3 | y3 x3 */
-
-    xyz2 = _mm256_permute_pd(xyz2,_GMX_MM_PERMUTE256D(0,1,0,1)); /*  z2 -  | x2 y2 */
-    t1   = _mm256_permute2f128_pd(xyz2,xyz2,0x21);   /* x2 y2 | z2 -  | */
-    xyz1 = _mm256_blend_pd(xyz1,t1,_GMX_MM_BLEND256D(1,0,0,0)); /* x2 z1 | y1 x1 */
-    xyz2 = _mm256_blend_pd(xyz2,t1,_GMX_MM_BLEND256D(0,0,1,0)); /*  -  - | z2 y2 */
-    t2   = _mm256_permute2f128_pd(xyz3,xyz3,0x21);   /* y3 x3 |  -  z3 | */
-    xyz2 = _mm256_blend_pd(xyz2,t2,_GMX_MM_BLEND256D(1,1,0,0)); /*  y3 x3 | z2 y2 */
-
-    tA   = _mm256_sub_pd(tA,xyz1);
-    tB   = _mm256_sub_pd(tB,xyz2);
-    tC   = _mm_sub_sd(tC, _mm256_castpd256_pd128(t2));
-
-    _mm256_storeu_pd(ptrA,tA);
-    _mm256_storeu_pd(ptrA+4,tB);
-    _mm_store_sd(ptrA+8,tC);
-}
-
-static void
-gmx_mm256_decrement_4rvec_1ptr_noswizzle_pd(double * gmx_restrict ptrA,
-                                            __m256d xyz1, __m256d xyz2, __m256d xyz3, __m256d xyz4)
-{
-    __m256d t1,t2,t3;
-    __m256d tA,tB,tC;
-
-    tA   = _mm256_loadu_pd(ptrA);
-    tB   = _mm256_loadu_pd(ptrA+4);
-    tC   = _mm256_loadu_pd(ptrA+8);
-
-    /* xyz1:  -  z1 | y1 x1 */
-    /* xyz2:  -  z2 | y2 x2 */
-    /* xyz3:  -  z3 | y3 x3 */
-    /* xyz4:  -  z4 | y4 x4 */
-
-    xyz2 = _mm256_permute_pd(xyz2,_GMX_MM_PERMUTE256D(0,1,0,1)); /*  z2 -  | x2 y2 */
-    t1   = _mm256_permute2f128_pd(xyz2,xyz2,0x21);   /* x2 y2 | z2 -  | */
-    xyz1 = _mm256_blend_pd(xyz1,t1,_GMX_MM_BLEND256D(1,0,0,0)); /* x2 z1 | y1 x1 */
-    xyz2 = _mm256_blend_pd(xyz2,t1,_GMX_MM_BLEND256D(0,0,1,0)); /*  -  - | z2 y2 */
-    t2   = _mm256_permute2f128_pd(xyz3,xyz3,0x21);   /* y3 x3 |  -  z3 | */
-    xyz2 = _mm256_blend_pd(xyz2,t2,_GMX_MM_BLEND256D(1,1,0,0)); /*  y3 x3 | z2 y2 */
-    xyz4 = _mm256_permute_pd(xyz4,_GMX_MM_PERMUTE256D(0,1,0,1));  /*  z4 -  | x4 y4 */
-    t3   = _mm256_permute2f128_pd(xyz4,xyz4,0x21);    /*  x4 y4 | z4 - */
-    t3   = _mm256_blend_pd(t3,xyz4,_GMX_MM_BLEND256D(1,0,1,0)); /* z4 y4| x4 - */
-    xyz4 = _mm256_blend_pd(t3,t2,_GMX_MM_BLEND256D(0,0,0,1)); /*  xz y4 | x4 z3 */
-
-    tA   = _mm256_sub_pd(tA,xyz1);
-    tB   = _mm256_sub_pd(tB,xyz2);
-    tC   = _mm256_sub_pd(tC,xyz4);
-
-    _mm256_storeu_pd(ptrA,tA);
-    _mm256_storeu_pd(ptrA+4,tB);
-    _mm256_storeu_pd(ptrA+8,tC);
-}
-
-
-
-static void
-gmx_mm256_decrement_1rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA,
-                                          __m256d x1, __m256d y1, __m256d z1)
-{
-    __m128d t1,t2,t3;
-
-    t1           = _mm_sub_sd(_mm256_castpd256_pd128(x1),_mm_load_sd(ptrA));
-    t2           = _mm_sub_sd(_mm256_castpd256_pd128(y1),_mm_load_sd(ptrA+1));
-    t3           = _mm_sub_sd(_mm256_castpd256_pd128(z1),_mm_load_sd(ptrA+2));
-    _mm_store_sd(ptrA,t1);
-    _mm_store_sd(ptrA+1,t2);
-    _mm_store_sd(ptrA+2,t3);
-}
-
-
-static void
-gmx_mm256_decrement_2rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2)
-{
-    __m256d t1;
-    __m128d tA;
-    t1          = _mm256_loadu_pd(ptrA);
-    tA          = _mm_loadu_pd(ptrA+4);
-
-    x1          = _mm256_unpacklo_pd(x1,y1); /*  -   -  | y1a x1a */
-    z1          = _mm256_unpacklo_pd(z1,x2); /*  -   -  | x2a z1a */
-    y2          = _mm256_unpacklo_pd(y2,z2); /*  -   -  | z2a y2a */
-
-    x1          = gmx_mm256_unpack128lo_pd(x1,z1);  /* x2a z1a | y1a x1a */
-
-    t1          = _mm256_sub_pd(x1,t1);
-    tA          = _mm_sub_pd(tA,_mm256_castpd256_pd128(y2));
-
-    _mm256_storeu_pd(ptrA,t1);
-    _mm_storeu_pd(ptrA+4,tA);
-}
-
-
-static void
-gmx_mm256_decrement_3rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2,
-                                          __m256d x3, __m256d y3, __m256d z3)
-{
-    __m256d t1,t2;
-    __m128d tA;
-
-    t1          = _mm256_loadu_pd(ptrA);
-    t2          = _mm256_loadu_pd(ptrA+4);
-    tA          = _mm_load_sd(ptrA+8);
-
-    x1          = _mm256_unpacklo_pd(x1,y1); /*  -   -  | y1a x1a */
-    z1          = _mm256_unpacklo_pd(z1,x2); /*  -   -  | x2a z1a */
-    y2          = _mm256_unpacklo_pd(y2,z2); /*  -   -  | z2a y2a */
-    x3          = _mm256_unpacklo_pd(x3,y3); /*  -   -  | y3a x3a */
-
-    x1          = gmx_mm256_unpack128lo_pd(x1,z1); /* x2a z1a | y1a x1a */
-    y2          = gmx_mm256_unpack128lo_pd(y2,x3); /* y3a x3a | z2a y2a */
-    t1          = _mm256_sub_pd(t1,x1);
-    t2          = _mm256_sub_pd(t2,y2);
-    tA          = _mm_sub_sd(tA,_mm256_castpd256_pd128(z3));
-
-    _mm256_storeu_pd(ptrA,t1);
-    _mm256_storeu_pd(ptrA+4,t2);
-    _mm_store_sd(ptrA+8,tA);
-}
-
-
-static void
-gmx_mm256_decrement_4rvec_1ptr_swizzle_pd(double * gmx_restrict ptrA,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2,
-                                          __m256d x3, __m256d y3, __m256d z3,
-                                          __m256d x4, __m256d y4, __m256d z4)
-{
-    __m256d t1,t2,t3;
-
-    t1          = _mm256_loadu_pd(ptrA);
-    t2          = _mm256_loadu_pd(ptrA+4);
-    t3          = _mm256_loadu_pd(ptrA+8);
-
-    x1          = _mm256_unpacklo_pd(x1,y1); /*  -   -  | y1a x1a */
-    z1          = _mm256_unpacklo_pd(z1,x2); /*  -   -  | x2a z1a */
-    y2          = _mm256_unpacklo_pd(y2,z2); /*  -   -  | z2a y2a */
-    x3          = _mm256_unpacklo_pd(x3,y3); /*  -   -  | y3a x3a */
-    z3          = _mm256_unpacklo_pd(z3,x4); /*  -   -  | x4a z3a */
-    y4          = _mm256_unpacklo_pd(y4,z4); /*  -   -  | z4a y4a */
-
-    x1          = gmx_mm256_unpack128lo_pd(x1,z1); /* x2a z1a | y1a x1a */
-    y2          = gmx_mm256_unpack128lo_pd(y2,x3); /* y3a x3a | z2a y2a */
-    z3          = gmx_mm256_unpack128lo_pd(z3,y4); /* z4a y4a | x4a z3a */
-
-    t1          = _mm256_sub_pd(t1,x1);
-    t2          = _mm256_sub_pd(t2,y2);
-    t3          = _mm256_sub_pd(t3,z3);
-
-    _mm256_storeu_pd(ptrA,t1);
-    _mm256_storeu_pd(ptrA+4,t2);
-    _mm256_storeu_pd(ptrA+8,t3);
-}
-
-static void
-gmx_mm256_decrement_1rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA,
-                                          double * gmx_restrict ptrB,
-                                          __m256d x1, __m256d y1, __m256d z1)
-{
-    __m256d t1,t2,t3,t4;
-    __m256i mask;
-
-    t3          = _mm256_loadu_pd(ptrA);
-    t4          = _mm256_loadu_pd(ptrB);
-
-    t1          = _mm256_unpacklo_pd(x1,y1);   /*  -  - | y1a x1a */
-    t2          = _mm256_unpackhi_pd(x1,y1);   /*  -  - | y1b x1b */
-
-    t1          = gmx_mm256_unpack128lo_pd(t1,z1); /*  -  z1a | y1a x1a */
-    z1          = _mm256_permute_pd(z1,_GMX_MM_PERMUTE256D(1,1,1,1));
-    t2          = gmx_mm256_unpack128lo_pd(t2,z1); /* z1b z1a | y1b x1b */
-
-    /* Construct a mask without executing any data loads */
-    mask        = _mm256_castpd_si256(_mm256_blend_pd(_mm256_setzero_pd(),
-                                                      _mm256_cmp_pd(_mm256_setzero_pd(),_mm256_setzero_pd(),_CMP_EQ_OQ),0x7));
-
-    t3          = _mm256_sub_pd(t3,t1);
-    t4          = _mm256_sub_pd(t4,t2);
-
-    /* Careful with potentially overlapping stores, need to be masked */
-    _mm256_maskstore_pd(ptrA,mask,t3);
-    _mm256_maskstore_pd(ptrB,mask,t4);
-}
-
-static void
-gmx_mm256_decrement_2rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2)
-{
-    __m256d t1,t2,t5;
-    __m128d t3,t4;
-
-    t1          = _mm256_loadu_pd(ptrA); 
-    t2          = _mm256_loadu_pd(ptrB); 
-    t3          = _mm_loadu_pd(ptrA+4);
-    t4          = _mm_loadu_pd(ptrB+4);
-
-    t5          = _mm256_unpacklo_pd(x1,y1); /*  -   -  | y1a x1a */
-    x1          = _mm256_unpackhi_pd(x1,y1); /*  -   -  | y1b x1b */
-
-    y1          = _mm256_unpacklo_pd(z1,x2); /*  -   -  | x2a z1a */
-    z1          = _mm256_unpackhi_pd(z1,x2); /*  -   -  | x2b z1b */
-
-    x2          = _mm256_unpacklo_pd(y2,z2); /*  -   -  | z2a y2a */
-    y2          = _mm256_unpackhi_pd(y2,z2); /*  -   -  | z2b y2b */
-
-    z2          = gmx_mm256_unpack128lo_pd(t5,y1); /* x2a z1a | y1a x1a */
-    y1          = gmx_mm256_unpack128lo_pd(x1,z1); /* x2b z1b | y1b x1b */
-
-    t1          = _mm256_sub_pd(t1,z2);
-    t2          = _mm256_sub_pd(t2,y1);
-    t3          = _mm_sub_pd(t3,_mm256_castpd256_pd128(x2));
-    t4          = _mm_sub_pd(t4,_mm256_castpd256_pd128(y2));
-
-    /* Careful with potentially overlapping stores, need to be masked */
-    _mm256_storeu_pd(ptrA,t1);
-    _mm256_storeu_pd(ptrB,t2);
-    _mm_storeu_pd(ptrA+4,t3);
-    _mm_storeu_pd(ptrB+4,t4);
-}
-
-static void
-gmx_mm256_decrement_3rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2,
-                                          __m256d x3, __m256d y3, __m256d z3)
-{
-    __m256d t1,t2,t3,t4,t5,t6;
-    __m128d tA,tB;
-
-    t1          = _mm256_loadu_pd(ptrA);
-    t2          = _mm256_loadu_pd(ptrB);
-    t3          = _mm256_loadu_pd(ptrA+4);
-    t4          = _mm256_loadu_pd(ptrB+4);
-    tA          = _mm_load_sd(ptrA+8);
-    tB          = _mm_load_sd(ptrB+8);
-
-    t5          = _mm256_unpacklo_pd(x1,y1); /*  -   -  | y1a x1a */
-    x1          = _mm256_unpackhi_pd(x1,y1); /*  -   -  | y1b x1b */
-
-    y1          = _mm256_unpacklo_pd(z1,x2); /*  -   -  | x2a z1a */
-    z1          = _mm256_unpackhi_pd(z1,x2); /*  -   -  | x2b z1b */
-
-    x2          = _mm256_unpacklo_pd(y2,z2); /*  -   -  | z2a y2a */
-    y2          = _mm256_unpackhi_pd(y2,z2); /*  -   -  | z2b y2b */
-
-    z2          = _mm256_unpacklo_pd(x3,y3); /*  -   -  | y3a x3a */
-    x3          = _mm256_unpackhi_pd(x3,y3); /*  -   -  | y3b x3b */
-
-    t6          = _mm256_permute_pd(z3,_GMX_MM_PERMUTE256D(1,1,1,1)); /* - - | - z3b */
-
-    y3          = gmx_mm256_unpack128lo_pd(t5,y1); /* x2a z1a | y1a x1a */
-    y1          = gmx_mm256_unpack128lo_pd(x1,z1); /* x2b z1b | y1b x1b */
-
-    t5          = gmx_mm256_unpack128lo_pd(x2,z2); /* y3a x3a | z2a y2a */     
-    x1          = gmx_mm256_unpack128lo_pd(y2,x3); /* y3b x3b | z2b y2b */
-
-    t1          = _mm256_sub_pd(t1,y3);
-    t2          = _mm256_sub_pd(t2,y1);
-    t3          = _mm256_sub_pd(t3,t5);  
-    t4          = _mm256_sub_pd(t4,x1);
-    tA          = _mm_sub_pd(tA,_mm256_castpd256_pd128(z3));
-    tB          = _mm_sub_pd(tB,_mm256_castpd256_pd128(t6));
-
-    _mm256_storeu_pd(ptrA,t1);
-    _mm256_storeu_pd(ptrB,t2);
-    _mm256_storeu_pd(ptrA+4,t3);
-    _mm256_storeu_pd(ptrB+4,t4);
-    _mm_store_sd(ptrA+8,tA);
-    _mm_store_sd(ptrB+8,tB);
-}
-
-
-static void
-gmx_mm256_decrement_4rvec_2ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2,
-                                          __m256d x3, __m256d y3, __m256d z3,
-                                          __m256d x4, __m256d y4, __m256d z4)
-{
-    __m256d t1,t2,t3,t4,t5,t6,t7;
-
-    t1          = _mm256_loadu_pd(ptrA);
-    t2          = _mm256_loadu_pd(ptrB); 
-    t3          = _mm256_loadu_pd(ptrA+4);
-    t4          = _mm256_loadu_pd(ptrB+4);
-    t5          = _mm256_loadu_pd(ptrA+8);
-    t6          = _mm256_loadu_pd(ptrB+8);
-
-    t7          = _mm256_unpacklo_pd(x1,y1); /*  -   -  | y1a x1a */
-    x1          = _mm256_unpackhi_pd(x1,y1); /*  -   -  | y1b x1b */
-
-    y1          = _mm256_unpacklo_pd(z1,x2); /*  -   -  | x2a z1a */
-    z1          = _mm256_unpackhi_pd(z1,x2); /*  -   -  | x2b z1b */
-
-    x2          = _mm256_unpacklo_pd(y2,z2); /*  -   -  | z2a y2a */
-    y2          = _mm256_unpackhi_pd(y2,z2); /*  -   -  | z2b y2b */
-
-    z2          = _mm256_unpacklo_pd(x3,y3); /*  -   -  | y3a x3a */
-    x3          = _mm256_unpackhi_pd(x3,y3); /*  -   -  | y3b x3b */
-
-    y3          = _mm256_unpacklo_pd(z3,x4); /*  -   -  | x4a z3a */
-    z3          = _mm256_unpackhi_pd(z3,x4); /*  -   -  | x4b z3b */
-    x4          = _mm256_unpacklo_pd(y4,z4); /*  -   -  | z4a y4a */
-    y4          = _mm256_unpackhi_pd(y4,z4); /*  -   -  | z4b y4b */
-
-    z4          = gmx_mm256_unpack128lo_pd(t7,y1); /* x2a z1a | y1a x1a */
-    y1          = gmx_mm256_unpack128lo_pd(x1,z1); /* x2b z1b | y1b x1b */
-
-    t7          = gmx_mm256_unpack128lo_pd(x2,z2); /* y3a x3a | z2a y2a */
-    x1          = gmx_mm256_unpack128lo_pd(y2,x3); /* y3b x3b | z2b y2b */
-
-    x2          = gmx_mm256_unpack128lo_pd(y3,x4); /* z4a y4a | x4a z3a */
-    y2          = gmx_mm256_unpack128lo_pd(z3,y4); /* z4b y4b | x4b z3b */
-
-    t1          = _mm256_sub_pd(t1,z4);
-    t2          = _mm256_sub_pd(t2,y1);
-    t3          = _mm256_sub_pd(t3,t7);
-    t4          = _mm256_sub_pd(t4,x1);
-    t5          = _mm256_sub_pd(t5,x2);
-    t6          = _mm256_sub_pd(t6,y2);
-
-    _mm256_storeu_pd(ptrA,t1);
-    _mm256_storeu_pd(ptrB,t2);
-    _mm256_storeu_pd(ptrA+4,t3);
-    _mm256_storeu_pd(ptrB+4,t4);
-    _mm256_storeu_pd(ptrA+8,t5);
-    _mm256_storeu_pd(ptrB+8,t6);
-}
-
-
-
 static void
 gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          double * gmx_restrict ptrC, double * gmx_restrict ptrD,
-                                          __m256d x1, __m256d y1, __m256d z1)
+        double * gmx_restrict ptrC, double * gmx_restrict ptrD,
+        __m256d x1, __m256d y1, __m256d z1)
 {
     __m256d t1,t2,tA,tB,tC,tD;
     __m256i mask;
@@ -1088,7 +552,7 @@ gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g
 
     /* Construct a mask without executing any data loads */
     mask        = _mm256_castpd_si256(_mm256_blend_pd(_mm256_setzero_pd(),
-                                                      _mm256_cmp_pd(_mm256_setzero_pd(),_mm256_setzero_pd(),_CMP_EQ_OQ),0x7));
+                                      _mm256_cmp_pd(_mm256_setzero_pd(),_mm256_setzero_pd(),_CMP_EQ_OQ),0x7));
 
     tA          = _mm256_loadu_pd(ptrA);
     tB          = _mm256_loadu_pd(ptrB);
@@ -1106,65 +570,77 @@ gmx_mm256_decrement_1rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g
     _mm256_maskstore_pd(ptrD,mask,tD);
 }
 
-static void
-gmx_mm256_decrement_2rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          double * gmx_restrict ptrC, double * gmx_restrict ptrD,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2)
-{
-    __m256d t1,t2,t3,t4,t5,t6;
-    __m128d tA,tB,tC,tD,tE,tF;
 
-    t1          = _mm256_loadu_pd(ptrA);
-    t2          = _mm256_loadu_pd(ptrB);
-    t3          = _mm256_loadu_pd(ptrC);
-    t4          = _mm256_loadu_pd(ptrD);
-    tA          = _mm_loadu_pd(ptrA+4);
-    tB          = _mm_loadu_pd(ptrB+4);
-    tC          = _mm_loadu_pd(ptrC+4);
-    tD          = _mm_loadu_pd(ptrD+4);
-
-    t5          = _mm256_unpacklo_pd(x1,y1); /* y1c x1c | y1a x1a */
-    x1          = _mm256_unpackhi_pd(x1,y1); /* y1d x1d | y1b x1b */
-    y1          = _mm256_unpacklo_pd(z1,x2); /* x2c z1c | x2a z1a */
-    z1          = _mm256_unpackhi_pd(z1,x2); /* x2d z1d | x2b z1b */
-    x2          = _mm256_unpacklo_pd(y2,z2); /* z2c y2c | z2a y2a */
-    y2          = _mm256_unpackhi_pd(y2,z2); /* z2d y2d | z2b y2b */
 
-    t6          = gmx_mm256_unpack128lo_pd(t5,y1); /* x2a z1a | y1a x1a */
-    z2          = gmx_mm256_unpack128hi_pd(t5,y1); /* x2c z1c | y1c x1c */
-    t5          = gmx_mm256_unpack128lo_pd(x1,z1); /* x2b z1b | y1b x1b */
-    y1          = gmx_mm256_unpack128hi_pd(x1,z1); /* x2d z1d | y1d x1d */
-
-    tE          = _mm256_extractf128_pd(x2,0x1); /* z2c y2c */
-    tF          = _mm256_extractf128_pd(y2,0x1); /* z2d y2d */
-
-    t1          = _mm256_sub_pd(t1,t6);
-    t2          = _mm256_sub_pd(t2,t5);
-    t3          = _mm256_sub_pd(t3,z2);
-    t4          = _mm256_sub_pd(t4,y1);
-    tA          = _mm_sub_pd(tA,_mm256_castpd256_pd128(x2));
-    tB          = _mm_sub_pd(tB,_mm256_castpd256_pd128(y2));
-    tC          = _mm_sub_pd(tC,tE);
-    tD          = _mm_sub_pd(tD,tF);
-
-    _mm256_storeu_pd(ptrA,t1);
-    _mm256_storeu_pd(ptrB,t2);
-    _mm256_storeu_pd(ptrC,t3);
-    _mm256_storeu_pd(ptrD,t4);
-    _mm_storeu_pd(ptrA+4,tA);
-    _mm_storeu_pd(ptrB+4,tB);
-    _mm_storeu_pd(ptrC+4,tC);
-    _mm_storeu_pd(ptrD+4,tD);
+#if defined (_MSC_VER) && defined(_M_IX86)
+/* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
+#define gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(ptrA,ptrB,ptrC,ptrD, \
+                                                  _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3) \
+{ \
+    __m256d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10;\
+    __m128d _tA,_tB,_tC,_tD,_tE;\
+    _t1          = _mm256_loadu_pd(ptrA);\
+    _t2          = _mm256_loadu_pd(ptrB);\
+    _t3          = _mm256_loadu_pd(ptrC);\
+    _t4          = _mm256_loadu_pd(ptrD);\
+    _t5          = _mm256_loadu_pd(ptrA+4);\
+    _t6          = _mm256_loadu_pd(ptrB+4);\
+    _t7          = _mm256_loadu_pd(ptrC+4);\
+    _t8          = _mm256_loadu_pd(ptrD+4);\
+    _tA          = _mm_load_sd(ptrA+8);\
+    _tB          = _mm_load_sd(ptrB+8);\
+    _tC          = _mm_load_sd(ptrC+8);\
+    _tD          = _mm_load_sd(ptrD+8);\
+    _t9          = _mm256_unpacklo_pd(_x1,_y1);\
+    _x1          = _mm256_unpackhi_pd(_x1,_y1);\
+    _y1          = _mm256_unpacklo_pd(_z1,_x2);\
+    _z1          = _mm256_unpackhi_pd(_z1,_x2);\
+    _x2          = _mm256_unpacklo_pd(_y2,_z2);\
+    _y2          = _mm256_unpackhi_pd(_y2,_z2);\
+    _z2          = _mm256_unpacklo_pd(_x3,_y3);\
+    _x3          = _mm256_unpackhi_pd(_x3,_y3);\
+    _t10         = gmx_mm256_unpack128lo_pd(_t9,_y1);\
+    _y3          = gmx_mm256_unpack128hi_pd(_t9,_y1);\
+    _t9          = gmx_mm256_unpack128lo_pd(_x1,_z1);\
+    _y1          = gmx_mm256_unpack128hi_pd(_x1,_z1);\
+    _x1          = gmx_mm256_unpack128lo_pd(_x2,_z2);\
+    _z1          = gmx_mm256_unpack128hi_pd(_x2,_z2);\
+    _x2          = gmx_mm256_unpack128lo_pd(_y2,_x3);\
+    _z2          = gmx_mm256_unpack128hi_pd(_y2,_x3);\
+    _t1          = _mm256_sub_pd(_t1,_t10);\
+    _t2          = _mm256_sub_pd(_t2,_t9);\
+    _t3          = _mm256_sub_pd(_t3,_y3);\
+    _t4          = _mm256_sub_pd(_t4,_y1);\
+    _t5          = _mm256_sub_pd(_t5,_x1);\
+    _t6          = _mm256_sub_pd(_t6,_x2);\
+    _t7          = _mm256_sub_pd(_t7,_z1);\
+    _t8          = _mm256_sub_pd(_t8,_z2);\
+    _tA          = _mm_sub_sd(_tA, _mm256_castpd256_pd128(_z3));\
+    _tB          = _mm_sub_sd(_tB, _mm_permute_pd(_mm256_castpd256_pd128(_z3),_GMX_MM_PERMUTE128D(1,1)));\
+    _tE          = _mm256_extractf128_pd(_z3,0x1);\
+    _tC          = _mm_sub_sd(_tC, _tE);\
+    _tD          = _mm_sub_sd(_tD, _mm_permute_pd(_tE,_GMX_MM_PERMUTE128D(1,1)));\
+    _mm256_storeu_pd(ptrA,_t1);\
+    _mm256_storeu_pd(ptrB,_t2);\
+    _mm256_storeu_pd(ptrC,_t3);\
+    _mm256_storeu_pd(ptrD,_t4);\
+    _mm256_storeu_pd(ptrA+4,_t5);\
+    _mm256_storeu_pd(ptrB+4,_t6);\
+    _mm256_storeu_pd(ptrC+4,_t7);\
+    _mm256_storeu_pd(ptrD+4,_t8);\
+    _mm_store_sd(ptrA+8,_tA);\
+    _mm_store_sd(ptrB+8,_tB);\
+    _mm_store_sd(ptrC+8,_tC);\
+    _mm_store_sd(ptrD+8,_tD);\
 }
-
-
+#else
+/* Real function for sane compilers */
 static void
 gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          double * gmx_restrict ptrC, double * gmx_restrict ptrD,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2,
-                                          __m256d x3, __m256d y3, __m256d z3)
+        double * gmx_restrict ptrC, double * gmx_restrict ptrD,
+        __m256d x1, __m256d y1, __m256d z1,
+        __m256d x2, __m256d y2, __m256d z2,
+        __m256d x3, __m256d y3, __m256d z3)
 {
     __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10;
     __m128d tA,tB,tC,tD,tE;
@@ -1235,15 +711,85 @@ gmx_mm256_decrement_3rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g
     _mm_store_sd(ptrC+8,tC);
     _mm_store_sd(ptrD+8,tD);
 }
-
-
+#endif
+
+#if defined (_MSC_VER) && defined(_M_IX86)
+/* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
+#define gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(ptrA,ptrB,ptrC,ptrD, \
+                                                  _x1,_y1,_z1,_x2,_y2,_z2,_x3,_y3,_z3,_x4,_y4,_z4) \
+{ \
+    __m256d _t1,_t2,_t3,_t4,_t5,_t6,_t7,_t8,_t9,_t10,_t11,_t12,_t13,_t14;\
+    __m128d _tA,_tB,_tC,_tD,_tE;\
+    _t1          = _mm256_loadu_pd(ptrA);\
+    _t2          = _mm256_loadu_pd(ptrB);\
+    _t3          = _mm256_loadu_pd(ptrC);\
+    _t4          = _mm256_loadu_pd(ptrD);\
+    _t5          = _mm256_loadu_pd(ptrA+4);\
+    _t6          = _mm256_loadu_pd(ptrB+4);\
+    _t7          = _mm256_loadu_pd(ptrC+4);\
+    _t8          = _mm256_loadu_pd(ptrD+4);\
+    _t9          = _mm256_loadu_pd(ptrA+8);\
+    _t10         = _mm256_loadu_pd(ptrB+8);\
+    _t11         = _mm256_loadu_pd(ptrC+8);\
+    _t12         = _mm256_loadu_pd(ptrD+8);\
+    _t13         = _mm256_unpacklo_pd(_x1,_y1);\
+    _x1          = _mm256_unpackhi_pd(_x1,_y1);\
+    _y1          = _mm256_unpacklo_pd(_z1,_x2);\
+    _z1          = _mm256_unpackhi_pd(_z1,_x2);\
+    _x2          = _mm256_unpacklo_pd(_y2,_z2);\
+    _y2          = _mm256_unpackhi_pd(_y2,_z2);\
+    _z2          = _mm256_unpacklo_pd(_x3,_y3);\
+    _x3          = _mm256_unpackhi_pd(_x3,_y3);\
+    _y3          = _mm256_unpacklo_pd(_z3,_x4);\
+    _z3          = _mm256_unpackhi_pd(_z3,_x4);\
+    _x4          = _mm256_unpacklo_pd(_y4,_z4);\
+    _y4          = _mm256_unpackhi_pd(_y4,_z4);\
+    _z4          = gmx_mm256_unpack128lo_pd(_t13,_y1);\
+    _t13         = gmx_mm256_unpack128hi_pd(_t13,_y1);\
+    _y1          = gmx_mm256_unpack128lo_pd(_x1,_z1);\
+    _x1          = gmx_mm256_unpack128hi_pd(_x1,_z1);\
+    _z1          = gmx_mm256_unpack128lo_pd(_x2,_z2);\
+    _x2          = gmx_mm256_unpack128hi_pd(_x2,_z2);\
+    _z2          = gmx_mm256_unpack128lo_pd(_y2,_x3);\
+    _y2          = gmx_mm256_unpack128hi_pd(_y2,_x3);\
+    _x3          = gmx_mm256_unpack128lo_pd(_y3,_x4);\
+    _y3          = gmx_mm256_unpack128hi_pd(_y3,_x4);\
+    _x4          = gmx_mm256_unpack128lo_pd(_z3,_y4);\
+    _z3          = gmx_mm256_unpack128hi_pd(_z3,_y4);\
+    _t1          = _mm256_sub_pd(_t1,_z4);\
+    _t2          = _mm256_sub_pd(_t2,_y1);\
+    _t3          = _mm256_sub_pd(_t3,_t13);\
+    _t4          = _mm256_sub_pd(_t4,_x1);\
+    _t5          = _mm256_sub_pd(_t5,_z1);\
+    _t6          = _mm256_sub_pd(_t6,_z2);\
+    _t7          = _mm256_sub_pd(_t7,_x2);\
+    _t8          = _mm256_sub_pd(_t8,_y2);\
+    _t9          = _mm256_sub_pd(_t9,_x3);\
+    _t10         = _mm256_sub_pd(_t10,_x4);\
+    _t11         = _mm256_sub_pd(_t11,_y3);\
+    _t12         = _mm256_sub_pd(_t12,_z3);\
+    _mm256_storeu_pd(ptrA,_t1);\
+    _mm256_storeu_pd(ptrB,_t2);\
+    _mm256_storeu_pd(ptrC,_t3);\
+    _mm256_storeu_pd(ptrD,_t4);\
+    _mm256_storeu_pd(ptrA+4,_t5);\
+    _mm256_storeu_pd(ptrB+4,_t6);\
+    _mm256_storeu_pd(ptrC+4,_t7);\
+    _mm256_storeu_pd(ptrD+4,_t8);\
+    _mm256_storeu_pd(ptrA+8,_t9);\
+    _mm256_storeu_pd(ptrB+8,_t10);\
+    _mm256_storeu_pd(ptrC+8,_t11);\
+    _mm256_storeu_pd(ptrD+8,_t12);\
+}
+#else
+/* Real function for sane compilers */
 static void
 gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * gmx_restrict ptrB,
-                                          double * gmx_restrict ptrC, double * gmx_restrict ptrD,
-                                          __m256d x1, __m256d y1, __m256d z1,
-                                          __m256d x2, __m256d y2, __m256d z2,
-                                          __m256d x3, __m256d y3, __m256d z3,
-                                          __m256d x4, __m256d y4, __m256d z4)
+        double * gmx_restrict ptrC, double * gmx_restrict ptrD,
+        __m256d x1, __m256d y1, __m256d z1,
+        __m256d x2, __m256d y2, __m256d z2,
+        __m256d x3, __m256d y3, __m256d z3,
+        __m256d x4, __m256d y4, __m256d z4)
 {
     __m256d t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14;
     __m128d tA,tB,tC,tD,tE;
@@ -1314,6 +860,7 @@ gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g
     _mm256_storeu_pd(ptrC+8,t11);
     _mm256_storeu_pd(ptrD+8,t12);
 }
+#endif
 
 
 
@@ -1321,8 +868,8 @@ gmx_mm256_decrement_4rvec_4ptr_swizzle_pd(double * gmx_restrict ptrA, double * g
 
 static gmx_inline void
 gmx_mm256_update_iforce_1atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1,
-                                         double * gmx_restrict fptr,
-                                         double * gmx_restrict fshiftptr)
+        double * gmx_restrict fptr,
+        double * gmx_restrict fshiftptr)
 {
     __m256d t1,t2;
     __m128d tA,tB;
@@ -1333,7 +880,7 @@ gmx_mm256_update_iforce_1atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz
     tA   = _mm_add_pd(_mm256_castpd256_pd128(fix1),_mm256_extractf128_pd(fix1,0x1));
     tB   = _mm_add_pd(_mm256_castpd256_pd128(fiz1),_mm256_extractf128_pd(fiz1,0x1));
 
-    fix1 = gmx_mm256_set_m128(tB,tA); /* 0 fiz fiy fix */
+    fix1 = gmx_mm256_set_m128d(tB,tA); /* 0 fiz fiy fix */
 
     t1   = _mm256_loadu_pd(fptr);
     t2   = _mm256_loadu_pd(fshiftptr);
@@ -1345,63 +892,59 @@ gmx_mm256_update_iforce_1atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz
     _mm256_storeu_pd(fshiftptr,t2);
 }
 
-static gmx_inline void
-gmx_mm256_update_iforce_2atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1,
-                                         __m256d fix2, __m256d fiy2, __m256d fiz2,
-                                         double * gmx_restrict fptr,
-                                         double * gmx_restrict fshiftptr)
-{
-    __m256d t1,t2,t3;
-    __m128d tA,tB,tC,tD,tE;
 
-    fix1 = _mm256_hadd_pd(fix1,fiy1);
-    fiz1 = _mm256_hadd_pd(fiz1,fix2);
-    fiy2 = _mm256_hadd_pd(fiy2,fiz2);
 
-    /* Add across the two lanes by swapping and adding back */
-    tA   = _mm_add_pd(_mm256_castpd256_pd128(fix1),_mm256_extractf128_pd(fix1,0x1)); /* fiy1 fix1 */
-    tB   = _mm_add_pd(_mm256_castpd256_pd128(fiz1),_mm256_extractf128_pd(fiz1,0x1)); /* fix2 fiz1 */
-    tC   = _mm_add_pd(_mm256_castpd256_pd128(fiy2),_mm256_extractf128_pd(fiy2,0x1)); /* fiz2 fiy2 */
-    
-    t1   = gmx_mm256_set_m128(tB,tA); /* fix2 fiz1 | fiy1 fix1 */
-
-    t2   = _mm256_loadu_pd(fptr);
-    tD   = _mm_loadu_pd(fptr+4);
-
-    t2   = _mm256_add_pd(t2,t1);
-    tD   = _mm_add_pd(tD,tC);
-    _mm256_storeu_pd(fptr,t2);
-    _mm_storeu_pd(fptr+4,tD);
-
-    /* Add up shift force */
-    /* t1:  fix2 fiz1 | fiy1 fix1 */
-    /* tC:              fiz2 fiy2 */
-
-    tA   = _mm256_extractf128_pd(t1,0x1); /* fix2 fiz1 */
-    tB   = _mm_shuffle_pd(tA,tC,_MM_SHUFFLE2(0,1));   /* fiy2 fix2 */
-    tC   = _mm_permute_pd(tC,_GMX_MM_PERMUTE128D(1,1));      /*  -   fiz2 */
-    
-    tB   = _mm_add_pd(tB,_mm256_castpd256_pd128(t1));
-    tC   = _mm_add_sd(tC,tA);
-
-    tD   = _mm_loadu_pd(fshiftptr);
-    tE   = _mm_load_sd(fshiftptr+2);
-
-    tD   = _mm_add_pd(tD,tB);
-    tE   = _mm_add_pd(tE,tC);
-
-    _mm_storeu_pd(fshiftptr,tD);
-    _mm_store_sd(fshiftptr+2,tE);
+#if defined (_MSC_VER) && defined(_M_IX86)
+/* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
+#define gmx_mm256_update_iforce_3atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3, \
+                                              fptr,fshiftptr) \
+{ \
+    __m256d _t1,_t2,_t3,_t4;\
+    __m128d _tz3,_tA,_tB,_tC,_tD;\
+    fix1 = _mm256_hadd_pd(fix1,fiy1);\
+    fiz1 = _mm256_hadd_pd(fiz1,fix2);\
+    fiy2 = _mm256_hadd_pd(fiy2,fiz2);\
+    fix3 = _mm256_hadd_pd(fix3,fiy3);\
+    fiz3 = _mm256_hadd_pd(fiz3,_mm256_setzero_pd());\
+    _t1   = gmx_mm256_unpack128lo_pd(fix1,fiz1);\
+    _t2   = gmx_mm256_unpack128hi_pd(fix1,fiz1);\
+    _t1   = _mm256_add_pd(_t1,_t2);\
+    _t3   = gmx_mm256_unpack128lo_pd(fiy2,fix3);\
+    _t4   = gmx_mm256_unpack128hi_pd(fiy2,fix3);\
+    _t3   = _mm256_add_pd(_t3,_t4);\
+    _tz3  = _mm_add_pd(_mm256_castpd256_pd128(fiz3),_mm256_extractf128_pd(fiz3,0x1));\
+    _t2   = _mm256_loadu_pd(fptr);\
+    _t4   = _mm256_loadu_pd(fptr+4);\
+    _tA   = _mm_load_sd(fptr+8);\
+    _t2   = _mm256_add_pd(_t2,_t1);\
+    _t4   = _mm256_add_pd(_t4,_t3);\
+    _tA   = _mm_add_sd(_tA,_tz3);\
+    _mm256_storeu_pd(fptr,_t2);\
+    _mm256_storeu_pd(fptr+4,_t4);\
+    _mm_store_sd(fptr+8,_tA);\
+    _tB   = _mm256_extractf128_pd(_t1,0x1);\
+    _tC   = _mm256_extractf128_pd(_t3,0x1);\
+    _tz3  = _mm_add_sd(_tz3,_tB);\
+    _tD   = _mm_permute_pd(_mm256_castpd256_pd128(_t3),_GMX_MM_PERMUTE128D(1,1));\
+    _tz3  = _mm_add_sd(_tz3,_tD);\
+    _tC   = _mm_add_pd(_tC,_mm256_castpd256_pd128(_t1));\
+    _tD   = _mm_shuffle_pd(_tB,_mm256_castpd256_pd128(_t3),_MM_SHUFFLE2(0,1));\
+    _tC   = _mm_add_pd(_tC,_tD);\
+    _tA   = _mm_loadu_pd(fshiftptr);\
+    _tB   = _mm_load_sd(fshiftptr+2);\
+    _tA   = _mm_add_pd(_tA,_tC);\
+    _tB   = _mm_add_sd(_tB,_tz3);\
+    _mm_storeu_pd(fshiftptr,_tA);\
+    _mm_store_sd(fshiftptr+2,_tB);\
 }
-
-
-
+#else
+/* Real function for sane compilers */
 static gmx_inline void
 gmx_mm256_update_iforce_3atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1,
-                                         __m256d fix2, __m256d fiy2, __m256d fiz2,
-                                         __m256d fix3, __m256d fiy3, __m256d fiz3,
-                                         double * gmx_restrict fptr,
-                                         double * gmx_restrict fshiftptr)
+        __m256d fix2, __m256d fiy2, __m256d fiz2,
+        __m256d fix3, __m256d fiy3, __m256d fiz3,
+        double * gmx_restrict fptr,
+        double * gmx_restrict fshiftptr)
 {
     __m256d t1,t2,t3,t4;
     __m128d tz3,tA,tB,tC,tD;
@@ -1459,15 +1002,66 @@ gmx_mm256_update_iforce_3atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz
     _mm_storeu_pd(fshiftptr,tA);
     _mm_store_sd(fshiftptr+2,tB);
 }
-
-
+#endif
+
+
+#if defined (_MSC_VER) && defined(_M_IX86)
+/* Macro work-around since 32-bit MSVC cannot handle >3 xmm/ymm parameters */
+#define gmx_mm256_update_iforce_4atom_swizzle_pd(fix1,fiy1,fiz1,fix2,fiy2,fiz2,fix3,fiy3,fiz3,fix4,fiy4,fiz4, \
+                                              fptr,fshiftptr) \
+{\
+    __m256d _t1,_t2,_t3,_t4,_t5,_t6;\
+    __m128d _tA,_tB,_tC,_tD;\
+    fix1 = _mm256_hadd_pd(fix1,fiy1);\
+    fiz1 = _mm256_hadd_pd(fiz1,fix2);\
+    fiy2 = _mm256_hadd_pd(fiy2,fiz2);\
+    fix3 = _mm256_hadd_pd(fix3,fiy3);\
+    fiz3 = _mm256_hadd_pd(fiz3,fix4);\
+    fiy4 = _mm256_hadd_pd(fiy4,fiz4);\
+    _t1   = gmx_mm256_unpack128lo_pd(fix1,fiz1);\
+    _t2   = gmx_mm256_unpack128hi_pd(fix1,fiz1);\
+    _t1   = _mm256_add_pd(_t1,_t2);\
+    _t3   = gmx_mm256_unpack128lo_pd(fiy2,fix3);\
+    _t4   = gmx_mm256_unpack128hi_pd(fiy2,fix3);\
+    _t3   = _mm256_add_pd(_t3,_t4);\
+    _t5   = gmx_mm256_unpack128lo_pd(fiz3,fiy4);\
+    _t6   = gmx_mm256_unpack128hi_pd(fiz3,fiy4);\
+    _t5   = _mm256_add_pd(_t5,_t6);\
+    _t2   = _mm256_loadu_pd(fptr);\
+    _t4   = _mm256_loadu_pd(fptr+4);\
+    _t6   = _mm256_loadu_pd(fptr+8);\
+    _t2   = _mm256_add_pd(_t2,_t1);\
+    _t4   = _mm256_add_pd(_t4,_t3);\
+    _t6   = _mm256_add_pd(_t6,_t5);\
+    _mm256_storeu_pd(fptr,_t2);\
+    _mm256_storeu_pd(fptr+4,_t4);\
+    _mm256_storeu_pd(fptr+8,_t6);\
+    _tA   = _mm256_extractf128_pd(_t1,0x1);\
+    _tB   = _mm256_extractf128_pd(_t3,0x1);\
+    _tC   = _mm256_extractf128_pd(_t5,0x1);\
+    _tB   = _mm_add_pd(_tB,_mm256_castpd256_pd128(_t1));\
+    _tA   = _mm_add_pd(_tA,_mm256_castpd256_pd128(_t5));\
+    _tC   = _mm_add_pd(_tC,_mm256_castpd256_pd128(_t3));\
+    _tD   = _mm_shuffle_pd(_tA,_tC,_MM_SHUFFLE2(0,1));\
+    _tB   = _mm_add_pd(_tB,_tD);\
+    _tC   = _mm_permute_pd(_tC,_GMX_MM_PERMUTE128D(1,1));\
+    _tC   = _mm_add_sd(_tC,_tA);\
+    _tA   = _mm_loadu_pd(fshiftptr);\
+    _tD   = _mm_load_sd(fshiftptr+2);\
+    _tA   = _mm_add_pd(_tA,_tB);\
+    _tD   = _mm_add_sd(_tD,_tC);\
+    _mm_storeu_pd(fshiftptr,_tA);\
+    _mm_store_sd(fshiftptr+2,_tD);\
+}
+#else
+/* Real function for sane compilers */
 static gmx_inline void
 gmx_mm256_update_iforce_4atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz1,
-                                         __m256d fix2, __m256d fiy2, __m256d fiz2,
-                                         __m256d fix3, __m256d fiy3, __m256d fiz3,
-                                         __m256d fix4, __m256d fiy4, __m256d fiz4,
-                                         double * gmx_restrict fptr,
-                                         double * gmx_restrict fshiftptr)
+        __m256d fix2, __m256d fiy2, __m256d fiz2,
+        __m256d fix3, __m256d fiy3, __m256d fiz3,
+        __m256d fix4, __m256d fiy4, __m256d fiz4,
+        double * gmx_restrict fptr,
+        double * gmx_restrict fshiftptr)
 {
     __m256d t1,t2,t3,t4,t5,t6;
     __m128d tA,tB,tC,tD;
@@ -1530,6 +1124,7 @@ gmx_mm256_update_iforce_4atom_swizzle_pd(__m256d fix1, __m256d fiy1, __m256d fiz
     _mm_storeu_pd(fshiftptr,tA);
     _mm_store_sd(fshiftptr+2,tD);
 }
+#endif
 
 
 
@@ -1547,7 +1142,7 @@ gmx_mm256_update_1pot_pd(__m256d pot1, double * gmx_restrict ptrA)
 
 static void
 gmx_mm256_update_2pot_pd(__m256d pot1, double * gmx_restrict ptrA,
-                      __m256d pot2, double * gmx_restrict ptrB)
+                         __m256d pot2, double * gmx_restrict ptrB)
 {
     __m128d t1,t2;
 
@@ -1561,49 +1156,4 @@ gmx_mm256_update_2pot_pd(__m256d pot1, double * gmx_restrict ptrA,
 }
 
 
-static void
-gmx_mm256_update_4pot_pd(__m256d pot1, double * gmx_restrict ptrA,
-                         __m256d pot2, double * gmx_restrict ptrB,
-                         __m256d pot3, double * gmx_restrict ptrC,
-                         __m256d pot4, double * gmx_restrict ptrD)
-{
-    __m256d t1,t2,t3,t4;
-    __m128d tA,tB,tC,tD,tE,tF,tG,tH;
-
-    tA   = _mm_load_sd(ptrA);
-    tB   = _mm_load_sd(ptrB);
-    tC   = _mm_load_sd(ptrC);
-    tD   = _mm_load_sd(ptrD);
-
-    /* do a transpose */
-    t1   = _mm256_unpacklo_pd(pot1, pot2);   /* p2c p1c | p2a p1a */
-    t2   = _mm256_unpackhi_pd(pot1, pot2);   /* p2d p1d | p2b p1b */
-    t3   = _mm256_unpacklo_pd(pot3, pot4);   /* p4c p3c | p4a p3a */
-    t4   = _mm256_unpackhi_pd(pot3, pot4);   /* p4d p3d | p4b p3b */
-    pot1 = _mm256_permute2f128_pd(t1, t3, 0x20);   /* p4a p3a | p2a p1a */
-    pot2 = _mm256_permute2f128_pd(t2, t4, 0x20);   /* p4b p3b | p2b p1b */
-    pot3 = _mm256_permute2f128_pd(t1, t3, 0x31);   /* p4c p3c | p2c p1c */
-    pot4 = _mm256_permute2f128_pd(t2, t4, 0x31);   /* p4d p3d | p2d p1d */
-
-    pot1 = _mm256_add_pd(pot1,pot2);
-    pot3 = _mm256_add_pd(pot3,pot4);
-    pot1 = _mm256_add_pd(pot1,pot3);  /* Sum in the four elements */
-
-    tE   = _mm256_castpd256_pd128(pot1);
-    tF   = _mm_permute_pd(tE,_GMX_MM_PERMUTE128D(1,1));
-    tG   = _mm256_extractf128_pd(pot1,0x1);
-    tH   = _mm_permute_pd(tG,_GMX_MM_PERMUTE128D(1,1));
-
-    tA   = _mm_add_sd(tA,tE);
-    tB   = _mm_add_sd(tB,tF);
-    tC   = _mm_add_sd(tC,tG);
-    tD   = _mm_add_sd(tD,tH);
-
-       _mm_store_sd(ptrA,tA);
-       _mm_store_sd(ptrB,tB);
-       _mm_store_sd(ptrC,tC);
-       _mm_store_sd(ptrD,tD);
-}
-
-
 #endif /* _kernelutil_x86_avx_256_double_h_ */