Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_single / nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_sse2_single.c
index 51bf341399dd04aba48af4e9f3c758ace96eeea6..98f1e5ff892503eb44b3e240a605fa6d4d774858 100644 (file)
@@ -58,10 +58,13 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
     int              jnrA,jnrB,jnrC,jnrD;
+    int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
-    real             shX,shY,shZ,rcutoff_scalar;
+    real             rcutoff_scalar;
     real             *shiftvec,*fshift,*x,*f;
+    real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
+    real             scratch[4*DIM];
     __m128           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
     int              vdwioffset0;
     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
@@ -178,14 +181,16 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
     outeriter        = 0;
     inneriter        = 0;
 
+    for(iidx=0;iidx<4*DIM;iidx++)
+    {
+        scratch[iidx] = 0.0;
+    }  
+
     /* Start outer loop over neighborlists */
     for(iidx=0; iidx<nri; iidx++)
     {
         /* Load shift vector for this list */
         i_shift_offset   = DIM*shiftidx[iidx];
-        shX              = shiftvec[i_shift_offset+XX];
-        shY              = shiftvec[i_shift_offset+YY];
-        shZ              = shiftvec[i_shift_offset+ZZ];
 
         /* Load limits for loop over neighbors */
         j_index_start    = jindex[iidx];
@@ -196,19 +201,9 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
         i_coord_offset   = DIM*inr;
 
         /* Load i particle coords and add shift vector */
-        ix0              = _mm_set1_ps(shX + x[i_coord_offset+DIM*0+XX]);
-        iy0              = _mm_set1_ps(shY + x[i_coord_offset+DIM*0+YY]);
-        iz0              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*0+ZZ]);
-        ix1              = _mm_set1_ps(shX + x[i_coord_offset+DIM*1+XX]);
-        iy1              = _mm_set1_ps(shY + x[i_coord_offset+DIM*1+YY]);
-        iz1              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*1+ZZ]);
-        ix2              = _mm_set1_ps(shX + x[i_coord_offset+DIM*2+XX]);
-        iy2              = _mm_set1_ps(shY + x[i_coord_offset+DIM*2+YY]);
-        iz2              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*2+ZZ]);
-        ix3              = _mm_set1_ps(shX + x[i_coord_offset+DIM*3+XX]);
-        iy3              = _mm_set1_ps(shY + x[i_coord_offset+DIM*3+YY]);
-        iz3              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*3+ZZ]);
-
+        gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
+                                                 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
+        
         fix0             = _mm_setzero_ps();
         fiy0             = _mm_setzero_ps();
         fiz0             = _mm_setzero_ps();
@@ -235,7 +230,6 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             jnrB             = jjnr[jidx+1];
             jnrC             = jjnr[jidx+2];
             jnrD             = jjnr[jidx+3];
-
             j_coord_offsetA  = DIM*jnrA;
             j_coord_offsetB  = DIM*jnrB;
             j_coord_offsetC  = DIM*jnrC;
@@ -377,7 +371,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             }
 
             /**************************
@@ -440,7 +434,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -503,7 +497,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -566,7 +560,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -629,7 +623,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -692,7 +686,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -755,7 +749,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -818,7 +812,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -881,7 +875,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -944,11 +938,15 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
-            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,f+j_coord_offsetD,
+            fjptrA             = f+j_coord_offsetA;
+            fjptrB             = f+j_coord_offsetB;
+            fjptrC             = f+j_coord_offsetC;
+            fjptrD             = f+j_coord_offsetD;
+
+            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
 
@@ -959,21 +957,19 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
         {
 
             /* Get j neighbor index, and coordinate index */
-            jnrA             = jjnr[jidx];
-            jnrB             = jjnr[jidx+1];
-            jnrC             = jjnr[jidx+2];
-            jnrD             = jjnr[jidx+3];
-
+            jnrlistA         = jjnr[jidx];
+            jnrlistB         = jjnr[jidx+1];
+            jnrlistC         = jjnr[jidx+2];
+            jnrlistD         = jjnr[jidx+3];
             /* Sign of each element will be negative for non-real atoms.
              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
              */
             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
-            jnrA       = (jnrA>=0) ? jnrA : 0;
-            jnrB       = (jnrB>=0) ? jnrB : 0;
-            jnrC       = (jnrC>=0) ? jnrC : 0;
-            jnrD       = (jnrD>=0) ? jnrD : 0;
-
+            jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
+            jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
+            jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
+            jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
             j_coord_offsetA  = DIM*jnrA;
             j_coord_offsetB  = DIM*jnrB;
             j_coord_offsetC  = DIM*jnrC;
@@ -1119,7 +1115,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             }
 
             /**************************
@@ -1186,7 +1182,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -1253,7 +1249,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -1320,7 +1316,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -1387,7 +1383,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -1454,7 +1450,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -1521,7 +1517,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -1588,7 +1584,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -1655,7 +1651,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -1722,11 +1718,15 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
-            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,f+j_coord_offsetD,
+            fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
+            fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
+            fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
+            fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
+
+            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
 
@@ -1746,7 +1746,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
         /* Increment number of inner iterations */
         inneriter                  += j_index_end - j_index_start;
 
-        /* Outer loop uses 38 flops */
+        /* Outer loop uses 26 flops */
     }
 
     /* Increment number of outer iterations */
@@ -1754,7 +1754,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_VF_sse2_single
 
     /* Update outer/inner flops */
 
-    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*38 + inneriter*657);
+    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*657);
 }
 /*
  * Gromacs nonbonded kernel:   nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
@@ -1781,10 +1781,13 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
     int              i_shift_offset,i_coord_offset,outeriter,inneriter;
     int              j_index_start,j_index_end,jidx,nri,inr,ggid,iidx;
     int              jnrA,jnrB,jnrC,jnrD;
+    int              jnrlistA,jnrlistB,jnrlistC,jnrlistD;
     int              j_coord_offsetA,j_coord_offsetB,j_coord_offsetC,j_coord_offsetD;
     int              *iinr,*jindex,*jjnr,*shiftidx,*gid;
-    real             shX,shY,shZ,rcutoff_scalar;
+    real             rcutoff_scalar;
     real             *shiftvec,*fshift,*x,*f;
+    real             *fjptrA,*fjptrB,*fjptrC,*fjptrD;
+    real             scratch[4*DIM];
     __m128           tx,ty,tz,fscal,rcutoff,rcutoff2,jidxall;
     int              vdwioffset0;
     __m128           ix0,iy0,iz0,fix0,fiy0,fiz0,iq0,isai0;
@@ -1901,14 +1904,16 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
     outeriter        = 0;
     inneriter        = 0;
 
+    for(iidx=0;iidx<4*DIM;iidx++)
+    {
+        scratch[iidx] = 0.0;
+    }  
+
     /* Start outer loop over neighborlists */
     for(iidx=0; iidx<nri; iidx++)
     {
         /* Load shift vector for this list */
         i_shift_offset   = DIM*shiftidx[iidx];
-        shX              = shiftvec[i_shift_offset+XX];
-        shY              = shiftvec[i_shift_offset+YY];
-        shZ              = shiftvec[i_shift_offset+ZZ];
 
         /* Load limits for loop over neighbors */
         j_index_start    = jindex[iidx];
@@ -1919,19 +1924,9 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
         i_coord_offset   = DIM*inr;
 
         /* Load i particle coords and add shift vector */
-        ix0              = _mm_set1_ps(shX + x[i_coord_offset+DIM*0+XX]);
-        iy0              = _mm_set1_ps(shY + x[i_coord_offset+DIM*0+YY]);
-        iz0              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*0+ZZ]);
-        ix1              = _mm_set1_ps(shX + x[i_coord_offset+DIM*1+XX]);
-        iy1              = _mm_set1_ps(shY + x[i_coord_offset+DIM*1+YY]);
-        iz1              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*1+ZZ]);
-        ix2              = _mm_set1_ps(shX + x[i_coord_offset+DIM*2+XX]);
-        iy2              = _mm_set1_ps(shY + x[i_coord_offset+DIM*2+YY]);
-        iz2              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*2+ZZ]);
-        ix3              = _mm_set1_ps(shX + x[i_coord_offset+DIM*3+XX]);
-        iy3              = _mm_set1_ps(shY + x[i_coord_offset+DIM*3+YY]);
-        iz3              = _mm_set1_ps(shZ + x[i_coord_offset+DIM*3+ZZ]);
-
+        gmx_mm_load_shift_and_4rvec_broadcast_ps(shiftvec+i_shift_offset,x+i_coord_offset,
+                                                 &ix0,&iy0,&iz0,&ix1,&iy1,&iz1,&ix2,&iy2,&iz2,&ix3,&iy3,&iz3);
+        
         fix0             = _mm_setzero_ps();
         fiy0             = _mm_setzero_ps();
         fiz0             = _mm_setzero_ps();
@@ -1954,7 +1949,6 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             jnrB             = jjnr[jidx+1];
             jnrC             = jjnr[jidx+2];
             jnrD             = jjnr[jidx+3];
-
             j_coord_offsetA  = DIM*jnrA;
             j_coord_offsetB  = DIM*jnrB;
             j_coord_offsetC  = DIM*jnrC;
@@ -2091,7 +2085,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             }
 
             /**************************
@@ -2149,7 +2143,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -2207,7 +2201,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -2265,7 +2259,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -2323,7 +2317,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -2381,7 +2375,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -2439,7 +2433,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -2497,7 +2491,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -2555,7 +2549,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -2613,11 +2607,15 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
-            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,f+j_coord_offsetD,
+            fjptrA             = f+j_coord_offsetA;
+            fjptrB             = f+j_coord_offsetB;
+            fjptrC             = f+j_coord_offsetC;
+            fjptrD             = f+j_coord_offsetD;
+
+            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
 
@@ -2628,21 +2626,19 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
         {
 
             /* Get j neighbor index, and coordinate index */
-            jnrA             = jjnr[jidx];
-            jnrB             = jjnr[jidx+1];
-            jnrC             = jjnr[jidx+2];
-            jnrD             = jjnr[jidx+3];
-
+            jnrlistA         = jjnr[jidx];
+            jnrlistB         = jjnr[jidx+1];
+            jnrlistC         = jjnr[jidx+2];
+            jnrlistD         = jjnr[jidx+3];
             /* Sign of each element will be negative for non-real atoms.
              * This mask will be 0xFFFFFFFF for dummy entries and 0x0 for real ones,
              * so use it as val = _mm_andnot_ps(mask,val) to clear dummy entries.
              */
             dummy_mask = gmx_mm_castsi128_ps(_mm_cmplt_epi32(_mm_loadu_si128((const __m128i *)(jjnr+jidx)),_mm_setzero_si128()));
-            jnrA       = (jnrA>=0) ? jnrA : 0;
-            jnrB       = (jnrB>=0) ? jnrB : 0;
-            jnrC       = (jnrC>=0) ? jnrC : 0;
-            jnrD       = (jnrD>=0) ? jnrD : 0;
-
+            jnrA       = (jnrlistA>=0) ? jnrlistA : 0;
+            jnrB       = (jnrlistB>=0) ? jnrlistB : 0;
+            jnrC       = (jnrlistC>=0) ? jnrlistC : 0;
+            jnrD       = (jnrlistD>=0) ? jnrlistD : 0;
             j_coord_offsetA  = DIM*jnrA;
             j_coord_offsetB  = DIM*jnrB;
             j_coord_offsetC  = DIM*jnrC;
@@ -2782,7 +2778,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             }
 
             /**************************
@@ -2843,7 +2839,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -2904,7 +2900,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -2965,7 +2961,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -3026,7 +3022,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -3087,7 +3083,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -3148,7 +3144,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
             /**************************
@@ -3209,7 +3205,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             }
 
             /**************************
@@ -3270,7 +3266,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             }
 
             /**************************
@@ -3331,11 +3327,15 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             }
 
-            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,f+j_coord_offsetD,
+            fjptrA             = (jnrlistA>=0) ? f+j_coord_offsetA : scratch;
+            fjptrB             = (jnrlistB>=0) ? f+j_coord_offsetB : scratch;
+            fjptrC             = (jnrlistC>=0) ? f+j_coord_offsetC : scratch;
+            fjptrD             = (jnrlistD>=0) ? f+j_coord_offsetD : scratch;
+
+            gmx_mm_decrement_4rvec_4ptr_swizzle_ps(fjptrA,fjptrB,fjptrC,fjptrD,
                                                    fjx0,fjy0,fjz0,fjx1,fjy1,fjz1,
                                                    fjx2,fjy2,fjz2,fjx3,fjy3,fjz3);
 
@@ -3350,7 +3350,7 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
         /* Increment number of inner iterations */
         inneriter                  += j_index_end - j_index_start;
 
-        /* Outer loop uses 36 flops */
+        /* Outer loop uses 24 flops */
     }
 
     /* Increment number of outer iterations */
@@ -3358,5 +3358,5 @@ nb_kernel_ElecEwSw_VdwLJSw_GeomW4W4_F_sse2_single
 
     /* Update outer/inner flops */
 
-    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*36 + inneriter*627);
+    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*627);
 }