Index: pic16/gen.c
===================================================================
--- pic16/gen.c	(revision 9761)
+++ pic16/gen.c	(working copy)
@@ -9165,8 +9165,13 @@
 
 
 #if 1
-  if (!strcmp (pic16_aopGet (AOP (result), 0, TRUE, FALSE), pic16_aopGet (AOP (left), 0, TRUE, FALSE)))
+  if (SPIL_LOC (IC_RESULT (ic)) && IS_ITEMP (IC_RESULT (ic)))
     {
+      DEBUGpic16_emitcode ("; ***", "result is available from spil location, skipping moving");
+      goto release;
+    }
+  else if (!strcmp (pic16_aopGet (AOP (result), 0, TRUE, FALSE), pic16_aopGet (AOP (left), 0, TRUE, FALSE)))
+    {
       DEBUGpic16_emitcode ("; ***", "left and result names are same, skipping moving");
       goto release;
     }
@@ -9847,8 +9852,9 @@
         }
       else
         {
-          pic16_mov2w (AOP (right), offset);
-          pic16_emitpcode (POC_MOVWF, pic16_popGet (AOP (result), offset));     // patch 8
+          mov2fp (pic16_popGet( AOP (result), offset), AOP (right), offset);
+          //pic16_mov2w (AOP (right), offset);
+          //pic16_emitpcode (POC_MOVWF, pic16_popGet (AOP (result), offset));     // patch 8
         }
       offset++;
       resoffset++;
Index: pic16/pcode.c
===================================================================
--- pic16/pcode.c	(revision 9761)
+++ pic16/pcode.c	(working copy)
@@ -6922,7 +6922,8 @@
 {
   pCode *pc=NULL;
   pCode *pcprev=NULL;
-  reg_info *reg, *prevreg;
+  pCode *pcprev2=NULL;
+  reg_info *reg;
   unsigned char flag=0;
 
         if(!pb)
@@ -6935,7 +6936,7 @@
 
 //      fprintf(stderr,"%s:%d: Register banking\n", __FUNCTION__, __LINE__);
 
-        prevreg = NULL;
+        pcprev = NULL;
         do {
                 /* at this point, pc should point to a PC_FLOW object */
                 /* for each flow block, determine the register banking
@@ -6943,16 +6944,17 @@
 
 
                 /* if label, then might come from other point, force banksel */
-                if(isPCL(pc))prevreg = NULL;
+                if(isPCL(pc))pcprev = NULL;
 
                 if(!isPCI(pc))goto loop;
 
-                if(PCI(pc)->label)prevreg = NULL;
+                if(PCI(pc)->label)pcprev = NULL;
 
+                /* Ignore MOVFF w.r.t. BANKSELs */
                 if(PCI(pc)->is2MemOp)goto loop;
 
                 /* if goto, then force banksel */
-//              if(PCI(pc)->op == POC_GOTO)prevreg = NULL;
+//              if(PCI(pc)->op == POC_GOTO)pcprev = NULL;
 
                 reg = pic16_getRegFromInstruction(pc);
 
@@ -6976,7 +6978,6 @@
 
                 if(isPCI_SKIP(pc)) {
 //                      fprintf(stderr, "instruction is SKIP instruction\n");
-//                prevreg = NULL;
                 }
                 if(reg && isACCESS_BANK(reg))goto loop;
 
@@ -6988,21 +6989,20 @@
 
                 /* Examine the instruction before this one to make sure it is
                  * not a skip type instruction */
-                pcprev = findPrevpCode(pc->prev, PC_OPCODE);
+                pcprev2 = findPrevpCode(pc->prev, PC_OPCODE);
 
                 flag = 0;               /* add before this instruction */
 
                 /* if previous instruction is a skip one, then set flag
                  * to 2 and call insertBankSwitch */
-                if(pcprev && isPCI_SKIP(pcprev)) {
+                if(pcprev2 && isPCI_SKIP(pcprev2)) {
                   flag=2;       //goto loop
-//                prevreg = NULL;
                 }
 
                 if(pic16_options.opt_banksel>0) {
                   char op1[128], op2[128];
 
-                    if(prevreg) {
+                    if(pcprev) {
                       strncpy(op1, pic16_get_op_from_instruction(PCI(pc)), sizeof(op1) - 1);
                       op1[sizeof(op1) - 1] = '\0';
 
@@ -7012,13 +7012,12 @@
                       if(!strcmp(op1, op2))goto loop;
                     }
                 }
-                prevreg = reg;
                 insertBankSwitch(flag, pc);
+                pcprev = pc;
 
 //              fprintf(stderr, "BANK SWITCH inserted\n");
 
 loop:
-                pcprev = pc;
                 pc = pc->next;
         } while (pc);
 }
