Merge release-4-6 into master
[alexxy/gromacs.git] / src / gromacs / gmxlib / nonbonded / nb_kernel_sse2_single / nb_kernel_ElecRF_VdwLJ_GeomW4W4_sse2_single.c
index 501c5edaba442e31a1542a224cf4d6a11de0fcae..a784c3f27f9ea06251f32f989741c36a25e566fc 100644 (file)
@@ -58,10 +58,13 @@ nb_kernel_ElecRF_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;
@@ -154,14 +157,16 @@ nb_kernel_ElecRF_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];
@@ -172,19 +177,9 @@ nb_kernel_ElecRF_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();
@@ -211,7 +206,6 @@ nb_kernel_ElecRF_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;
@@ -331,7 +325,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -358,7 +352,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -385,7 +379,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -412,7 +406,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -439,7 +433,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -466,7 +460,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -493,7 +487,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -520,7 +514,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -547,7 +541,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -574,9 +568,13 @@ nb_kernel_ElecRF_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);
 
@@ -587,21 +585,19 @@ nb_kernel_ElecRF_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;
@@ -724,7 +720,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -754,7 +750,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -784,7 +780,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -814,7 +810,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -844,7 +840,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -874,7 +870,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -904,7 +900,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -934,7 +930,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -964,7 +960,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -994,9 +990,13 @@ nb_kernel_ElecRF_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);
 
@@ -1016,7 +1016,7 @@ nb_kernel_ElecRF_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 */
@@ -1024,7 +1024,7 @@ nb_kernel_ElecRF_VdwLJ_GeomW4W4_VF_sse2_single
 
     /* Update outer/inner flops */
 
-    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*38 + inneriter*323);
+    inc_nrnb(nrnb,eNR_NBKERNEL_ELEC_VDW_W4W4_VF,outeriter*26 + inneriter*323);
 }
 /*
  * Gromacs nonbonded kernel:   nb_kernel_ElecRF_VdwLJ_GeomW4W4_F_sse2_single
@@ -1051,10 +1051,13 @@ nb_kernel_ElecRF_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;
@@ -1147,14 +1150,16 @@ nb_kernel_ElecRF_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];
@@ -1165,19 +1170,9 @@ nb_kernel_ElecRF_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();
@@ -1200,7 +1195,6 @@ nb_kernel_ElecRF_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;
@@ -1314,7 +1308,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1337,7 +1331,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1360,7 +1354,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1383,7 +1377,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1406,7 +1400,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1429,7 +1423,7 @@ nb_kernel_ElecRF_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_ElecRF_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 *
              **************************/
@@ -1475,7 +1469,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1498,7 +1492,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1521,9 +1515,13 @@ nb_kernel_ElecRF_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);
 
@@ -1534,21 +1532,19 @@ nb_kernel_ElecRF_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;
@@ -1664,7 +1660,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1689,7 +1685,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1714,7 +1710,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1739,7 +1735,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1764,7 +1760,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1789,7 +1785,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1814,7 +1810,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1839,7 +1835,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1864,7 +1860,7 @@ nb_kernel_ElecRF_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 *
              **************************/
@@ -1889,9 +1885,13 @@ nb_kernel_ElecRF_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);
 
@@ -1906,7 +1906,7 @@ nb_kernel_ElecRF_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 */
@@ -1914,5 +1914,5 @@ nb_kernel_ElecRF_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);
 }