Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_single / nb_kernel_ElecCoul_VdwLJ_GeomW4W4_sse2_single.c
index 237af11e8912d810dbfb57debfb79243aedc0348..1188b30777c4b69c16a79b75ac2d56eac4332e0c 100644 (file)
@@ -58,10 +58,13 @@ nb_kernel_ElecCoul_VdwLJ_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;
@@ -151,14 +154,16 @@ nb_kernel_ElecCoul_VdwLJ_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];
@@ -169,19 +174,9 @@ nb_kernel_ElecCoul_VdwLJ_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();
@@ -208,7 +203,6 @@ nb_kernel_ElecCoul_VdwLJ_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;
@@ -328,7 +322,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -355,7 +349,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -382,7 +376,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -409,7 +403,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -436,7 +430,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -463,7 +457,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -490,7 +484,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -517,7 +511,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -544,7 +538,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -571,9 +565,13 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
+            
+            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(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,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);
 
@@ -584,21 +582,19 @@ nb_kernel_ElecCoul_VdwLJ_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;
@@ -721,7 +717,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -751,7 +747,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -781,7 +777,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -811,7 +807,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -841,7 +837,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -871,7 +867,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -901,7 +897,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -931,7 +927,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -961,7 +957,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -991,9 +987,13 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
+            
+            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(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,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);
 
@@ -1013,7 +1013,7 @@ nb_kernel_ElecCoul_VdwLJ_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 */
@@ -1021,7 +1021,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_VF_sse2_single
 
     /* Update outer/inner flops */
 
-    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*38 + inneriter*287);
+    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*287);
 }
 /*
  * Gromacs nonbonded kernel:   nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
@@ -1048,10 +1048,13 @@ nb_kernel_ElecCoul_VdwLJ_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;
@@ -1141,14 +1144,16 @@ nb_kernel_ElecCoul_VdwLJ_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];
@@ -1159,19 +1164,9 @@ nb_kernel_ElecCoul_VdwLJ_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();
@@ -1194,7 +1189,6 @@ nb_kernel_ElecCoul_VdwLJ_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;
@@ -1308,7 +1302,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1332,7 +1326,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1356,7 +1350,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1380,7 +1374,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1404,7 +1398,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1428,7 +1422,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1452,7 +1446,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1476,7 +1470,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1500,7 +1494,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1524,9 +1518,13 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
+            
+            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(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,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);
 
@@ -1537,21 +1535,19 @@ nb_kernel_ElecCoul_VdwLJ_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;
@@ -1667,7 +1663,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx0             = _mm_add_ps(fjx0,tx);
             fjy0             = _mm_add_ps(fjy0,ty);
             fjz0             = _mm_add_ps(fjz0,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1693,7 +1689,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1719,7 +1715,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1745,7 +1741,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1771,7 +1767,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1797,7 +1793,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1823,7 +1819,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1849,7 +1845,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx1             = _mm_add_ps(fjx1,tx);
             fjy1             = _mm_add_ps(fjy1,ty);
             fjz1             = _mm_add_ps(fjz1,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1875,7 +1871,7 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx2             = _mm_add_ps(fjx2,tx);
             fjy2             = _mm_add_ps(fjy2,ty);
             fjz2             = _mm_add_ps(fjz2,tz);
-
+            
             /**************************
              * CALCULATE INTERACTIONS *
              **************************/
@@ -1901,9 +1897,13 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
             fjx3             = _mm_add_ps(fjx3,tx);
             fjy3             = _mm_add_ps(fjy3,ty);
             fjz3             = _mm_add_ps(fjz3,tz);
+            
+            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(f+j_coord_offsetA,f+j_coord_offsetB,
-                                                   f+j_coord_offsetC,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);
 
@@ -1918,7 +1918,7 @@ nb_kernel_ElecCoul_VdwLJ_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 */
@@ -1926,5 +1926,5 @@ nb_kernel_ElecCoul_VdwLJ_GeomW4W4_F_sse2_single
 
     /* Update outer/inner flops */
 
-    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*36 + inneriter*273);
+    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_F,outeriter*24 + inneriter*273);
 }