fix for bug-453196
authorsandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 25 Aug 2001 23:26:12 +0000 (23:26 +0000)
committersandeep <sandeep@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 25 Aug 2001 23:26:12 +0000 (23:26 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1170 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCcse.c
src/SDCCcse.h
src/SDCCloop.c

index 8787bd48405ab9bb5dbf51b80f67e492eb200714..ac5e66afd412e4766cd96cf66ddaf128b35c9f00 100644 (file)
@@ -848,55 +848,56 @@ algebraicOpts (iCode * ic)
 /* updateSpillLocation - keeps track of register spill location    */
 /*-----------------------------------------------------------------*/
 void 
-updateSpillLocation (iCode * ic)
+updateSpillLocation (iCode * ic, int induction)
 {
 
-  sym_link *setype;
+       sym_link *setype;
 
-  if (POINTER_SET (ic))
-    return;
-
-  if (ic->nosupdate)
-    return;
+       if (POINTER_SET (ic))
+               return;
 
-  /* for the form true_symbol := iTempNN */
-  if (ASSIGN_ITEMP_TO_SYM (ic)
-      && !SPIL_LOC (IC_RIGHT (ic)))
-    {
+       if (ic->nosupdate)
+               return;
 
-      setype = getSpec (operandType (IC_RESULT (ic)));
-
-      if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
-         !IS_VOLATILE (setype) &&
-         !IN_FARSPACE (SPEC_OCLS (setype)) &&
-          /* PENDING */
-          !TARGET_IS_Z80 &&
-         !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
-
-       SPIL_LOC (IC_RIGHT (ic)) =
-         IC_RESULT (ic)->operand.symOperand;
-    }
+       /* for the form true_symbol := iTempNN */
+       if (ASSIGN_ITEMP_TO_SYM (ic) && 
+           !SPIL_LOC (IC_RIGHT (ic))) {
 
-  if (ASSIGN_ITEMP_TO_ITEMP (ic) &&
-      !SPIL_LOC (IC_RIGHT (ic)) &&
-  !bitVectBitsInCommon (OP_DEFS (IC_RIGHT (ic)), OP_USES (IC_RESULT (ic))) &&
-      OP_SYMBOL (IC_RESULT (ic))->isreqv)
-    {
+               setype = getSpec (operandType (IC_RESULT (ic)));
 
-      setype = getSpec (operandType (IC_RESULT (ic)));
+               if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
+                   !IS_VOLATILE (setype) &&
+                   !IN_FARSPACE (SPEC_OCLS (setype)) &&
+                   !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
 
-      if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
-         !IS_VOLATILE (setype) &&
-         !IN_FARSPACE (SPEC_OCLS (setype)) &&
-          /* PENDING */
-          !TARGET_IS_Z80 &&
-         !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
+                       SPIL_LOC (IC_RIGHT (ic)) =
+                               IC_RESULT (ic)->operand.symOperand;
+       }
 
-       SPIL_LOC (IC_RIGHT (ic)) =
-         SPIL_LOC (IC_RESULT (ic));
-    }
+       if (ASSIGN_ITEMP_TO_ITEMP (ic)) {
+         
+               if (!SPIL_LOC (IC_RIGHT (ic)) &&
+                   !bitVectBitsInCommon (OP_DEFS (IC_RIGHT (ic)), OP_USES (IC_RESULT (ic))) &&
+                   OP_SYMBOL (IC_RESULT (ic))->isreqv) {
+
+                       setype = getSpec (operandType (IC_RESULT (ic)));
+             
+                       if (!OP_SYMBOL(IC_RIGHT (ic))->noSpilLoc &&
+                           !IS_VOLATILE (setype) &&
+                           !IN_FARSPACE (SPEC_OCLS (setype)) &&
+                           !OTHERS_PARM (OP_SYMBOL (IC_RESULT (ic))))
+
+                               SPIL_LOC (IC_RIGHT (ic)) =
+                                       SPIL_LOC (IC_RESULT (ic));
+               }
+               /* special case for inductions */
+               if (induction && 
+                   OP_SYMBOL(IC_RIGHT(ic))->isreqv && 
+                   !SPIL_LOC(IC_RESULT(ic))) {
+                       SPIL_LOC (IC_RESULT (ic)) = SPIL_LOC (IC_RIGHT (ic));
+               }
+       }
 }
-
 /*-----------------------------------------------------------------*/
 /* setUsesDef - sets the uses def bitvector for a given operand    */
 /*-----------------------------------------------------------------*/
@@ -1400,7 +1401,7 @@ cseBBlock (eBBlock * ebb, int computeOnly,
        {
 
          /* update the spill location for this */
-         updateSpillLocation (ic);
+         updateSpillLocation (ic,1);
 
          if (POINTER_SET (ic) &&
              !(IS_BITFIELD (OP_SYMBOL (IC_RESULT (ic))->etype)))
index 51bfb41c98a48ef686518c8d23ec5ef78868686b..5eaf9cf284a6e13d926f41475630b77a6dfe72c8 100644 (file)
@@ -54,7 +54,7 @@ int cseBBlock (eBBlock *, int, eBBlock **, int);
 int cseAllBlocks (eBBlock **, int);
 void ifxOptimize (iCode *, set *, int, eBBlock *, int *, eBBlock **, int);
 void unsetDefsAndUses (iCode *);
-void updateSpillLocation (iCode * ic);
+void updateSpillLocation (iCode * ic,int);
 void setUsesDefs (operand *, bitVect *, bitVect *, bitVect **);
 void replaceAllSymBySym (iCode *, operand *, operand *, bitVect **);
 #endif
index a50bac498eaa411e1cb97cf5e0cd419fc00efba0..fc928630bd241126a69b05e6f05ffcf700181dc4 100644 (file)
@@ -46,7 +46,7 @@ newInduction (operand * sym, unsigned int op,
   ip->op = op;
   ip->cval = constVal;
   ip->ic = ic;
-
+  updateSpillLocation(ic,1);
   return ip;
 }