* src/avr/gen.c (aopop),
[fw/sdcc] / src / avr / gen.c
index b06f5c8dd612a860acbaa7d03e9ce3561c0f1298..59dbabcebc9e0eddf6839aaa1a806be213999ade 100644 (file)
@@ -758,6 +758,8 @@ aopOp (operand * op, iCode * ic, bool result)
           b) has a spill location */
        if (sym->isspilt || sym->nRegs == 0) {
 
+               asmop *oldAsmOp = NULL;
+
                /* rematerialize it NOW */
                if (sym->remat) {
                        sym->aop = op->aop = aop = aopForRemat (sym);
@@ -781,10 +783,15 @@ aopOp (operand * op, iCode * ic, bool result)
                /* else spill location  */
                if (sym->usl.spillLoc && getSize(sym->type) != getSize(sym->usl.spillLoc->type)) {
                    /* force a new aop if sizes differ */
+                   oldAsmOp = sym->usl.spillLoc->aop;
                    sym->usl.spillLoc->aop = NULL;
                }
                sym->aop = op->aop = aop =
                        aopForSym (ic, sym->usl.spillLoc, result);
+               if (getSize(sym->type) != getSize(sym->usl.spillLoc->type)) {
+                       /* Don't reuse the new aop, go with the last one */
+                       sym->usl.spillLoc->aop = oldAsmOp;
+               }
                aop->size = getSize (sym->type);
                return;
        }