]> git.gag.com Git - fw/sdcc/blobdiff - src/avr/gen.c
* src/avr/gen.c (aopop),
[fw/sdcc] / src / avr / gen.c
index cde734ea6a7c045364837ed46dfe5e8f7fda913b..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;
        }
@@ -2679,7 +2686,7 @@ genBitWise (iCode * ic, iCode * ifx, int bitop)
                                (int) floatFromVal (AOP (right)->aopu.
                                                    aop_lit);
                        int p2 = powof2 (lit);
-                       if (bitop == AVR_AND && p2) {   /* right side is a power of 2 */
+                       if (bitop == AVR_AND && (p2 >= 0)) {    /* right side is a power of 2 */
                                l = aopGet (AOP (left), p2 / 8);
                                if (IC_TRUE (ifx)) {
                                        emitcode ("sbrc", "%s,%d", l,