* doc/Makefile: fix install
[fw/sdcc] / src / SDCCloop.c
index 6e6b26a6af37db57247cf217246bcd0b015d0cf7..c69101857feab6f466a43fe65344182c4fb8fbba 100644 (file)
@@ -46,7 +46,7 @@ newInduction (operand * sym, unsigned int op,
   ip->op = op;
   ip->cval = constVal;
   ip->ic = ic;
-  updateSpillLocation(ic,1);
+//updateSpillLocation(ic,1);
   return ip;
 }
 
@@ -235,9 +235,10 @@ DEFSETFUNC (addToExitsMarkDepth)
   if (ebp->depth<depth)
     ebp->depth = depth;
 
-  /* put the loop region info in the block */
-  if (!isinSet (ebp->partOfLoop, lr))
-    addSetHead (&ebp->partOfLoop, lr);
+  /* NOTE: here we will update only the inner most loop
+     that it is a part of */
+  if (!ebp->partOfLoop)
+    ebp->partOfLoop = lr;
 
   /* if any of the successors go out of the loop then */
   /* we add this one to the exits */
@@ -327,7 +328,7 @@ assignmentsToSym (set * sset, operand * sym)
          in this block */
       bitVect *defs = bitVectIntersect (ebp->ldefs, OP_DEFS (sym));
       assigns += bitVectnBitsOn (defs);
-      setToNull ((void **) &defs);
+      setToNull ((void *) &defs);
 
     }
 
@@ -463,6 +464,13 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
 
          if (SKIP_IC (ic) || POINTER_SET (ic) || ic->op == IFX)
            continue;
+         
+         /* iTemp assignment from a literal may be invariant, but it
+            will needlessly increase register pressure if the
+            iCode(s) that use this iTemp are not also invariant */
+         if (ic->op=='=' && IS_ITEMP (IC_RESULT (ic))
+             && IS_OP_LITERAL (IC_RIGHT (ic)))
+           continue;
 
          /* if result is volatile then skip */
          if (IC_RESULT (ic) &&
@@ -506,7 +514,8 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
              applyToSet (theLoop->regBlocks, hasNonPtrUse, IC_LEFT (ic)))
            continue;
 
-         /* if both the left & right are invariants : then check that */
+
+          /* if both the left & right are invariants : then check that */
          /* this definition exists in the out definition of all the  */
          /* blocks, this will ensure that this is not assigned any   */
          /* other value in the loop , and not used in this block     */
@@ -517,7 +526,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
              eBBlock *sBlock;
              set *lSet = setFromSet (theLoop->regBlocks);
 
-             /* if this block does not dominate all exists */
+             /* if this block does not dominate all exits */
              /* make sure this defintion is not used anywhere else */
              if (!domsAllExits)
                {
@@ -566,7 +575,9 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
              /* now we know it is a true invariant */
              /* remove it from the insts chain & put */
              /* in the invariant set                */
-             OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1;
+             
+              OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1;
+              SPIL_LOC (IC_RESULT (ic)) = NULL;
              remiCodeFromeBBlock (lBlock, ic);
 
              /* maintain the data flow */
@@ -1055,7 +1066,7 @@ loopInduction (region * loopReg, eBBlock ** ebbs, int count)
       lastBlock->linds = bitVectUnion(lastBlock->linds,indVect);
     }
 
-  setToNull ((void **) &indVars);
+  setToNull ((void *) &indVars);
   return change;
 }
 
@@ -1214,57 +1225,3 @@ loopOptimizations (hTab * orderedLoops, eBBlock ** ebbs, int count)
 
   return change;
 }
-
-/*-----------------------------------------------------------------*/
-/* addLoopBlocks - will add all blocks inside a loop to this loop  */
-/* this should fix most of the liverange problems                  */
-/*-----------------------------------------------------------------*/
-void
-addLoopBlocks (eBBlock ** ebbs, int count)
-{
-  region *aloop;
-  struct eBBlock *block;
-  int seqMin, seqMax;
-  int i, j;
-
-  for (i = 0; i < count; i++)
-    {
-      if (!ebbs[i]->partOfLoop)
-        continue;
-
-      /* for all loops this block belongs to */
-      /* add inner block not already marked as part of this loop */
-      aloop = setFirstItem (ebbs[i]->partOfLoop);
-      for (; aloop; aloop = setNextItem (ebbs[i]->partOfLoop))
-        {
-
-          if (aloop->visited)
-            continue;
-
-          aloop->visited = 1;
-
-          /* set max & min Seq for loopRegion */
-          block = setFirstItem (aloop->regBlocks);
-          seqMax = block->lSeq;
-          seqMin = block->fSeq;
-          for (; block; block = setNextItem (aloop->regBlocks))
-           {
-              if (block->lSeq > seqMax)
-                seqMax = block->lSeq;
-              if (block->fSeq < seqMin)
-                seqMin = block->fSeq;
-            }
-
-          /* add all blocks between seqMin, seqMax to loop */
-          for (j = 0; j < count; j++)
-           {
-              if (ebbs[j]->fSeq > seqMin && ebbs[j]->lSeq < seqMax &&
-                  !isinSet (aloop->regBlocks, ebbs[j]))
-               {
-                  if (!isinSet (ebbs[i]->partOfLoop, aloop))
-                   addSetHead (&ebbs[j]->partOfLoop, aloop);
-               }
-           }
-       }
-    }
-}