cleaned up the mess I left behind
[fw/sdcc] / src / SDCCloop.c
index 2819c859dcbf689953057e3b814b12baf14dfbef..55021f34798aa1a0d80e920e8a9a29bd86e22f6a 100644 (file)
@@ -282,6 +282,7 @@ DEFSETFUNC (createLoop)
     }
 
   aloop->entry = ep->to;
+
   /* set max & min dfNum for loopRegion */
   for ( block = setFirstItem(aloop->regBlocks); block; 
        block = setNextItem(aloop->regBlocks)) {
@@ -292,13 +293,22 @@ DEFSETFUNC (createLoop)
   /* all blocks that have dfnumbers between dfMin & dfMax are also
      part of loop */
   for (i = 0 ; i < count ; i++) {
-      if (ebbs[i]->dfnum > dfMin && 
-         ebbs[i]->dfnum < dfMax &&
+    if (ebbs[i]->dfnum > dfMin && 
+          ebbs[i]->dfnum < dfMax &&
          !isinSet(aloop->regBlocks,ebbs[i])) {
-         if (!ebbs[i]->partOfLoop) ebbs[i]->partOfLoop = aloop;
+         if (!ebbs[i]->partOfLoop) {
+           ebbs[i]->partOfLoop = aloop;
+         }
       }
   }
 
+  /* and if this is a conditional block, the other side of the IFX 
+     (if any, that could have a greater dfnum) is too */
+  {
+    // just a burp, but I'm getting close :)
+  }
+  
+
   /* now add it to the set */
   addSetHead (allRegion, aloop);
   return 0;
@@ -465,7 +475,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
          int lin, rin;
          cseDef *ivar;
 
-         /* jwk: TODO this is only needed if the call is between
+         /* TODO this is only needed if the call is between
             here and the definition, but I am too lazy to do that now */
 
          /* if there are function calls in this block */
@@ -887,10 +897,10 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count)
                              iCode *newic = newiCode ('=', NULL,
                                        operandFromOperand (IC_RIGHT (ic)));
                              IC_RESULT (newic) = operandFromOperand (IC_RESULT (ic));
-                             OP_DEFS_SET ((IC_RESULT (newic)),
-                               bitVectSetBit (OP_DEFS (IC_RESULT (newic)), newic->key));
-                             OP_USES_SET ((IC_RIGHT (newic)),
-                               bitVectSetBit (OP_USES (IC_RIGHT (newic)), newic->key));
+                             OP_DEFS(IC_RESULT (newic))=
+                               bitVectSetBit (OP_DEFS (IC_RESULT (newic)), newic->key);
+                             OP_USES(IC_RIGHT (newic))=
+                               bitVectSetBit (OP_USES (IC_RIGHT (newic)), newic->key);
                              /* and add it */
                              if (eblock->sch && eblock->sch->op == LABEL)
                                addiCodeToeBBlock (eblock, newic, eblock->sch->next);
@@ -1104,7 +1114,7 @@ DEFSETFUNC (mergeRegions)
       if (lp->entry == theLoop->entry)
        {
          theLoop->regBlocks = unionSets (theLoop->regBlocks,
-                                         lp->regBlocks, THROW_BOTH);
+                                         lp->regBlocks, THROW_DEST);
          lp->merged = 1;
        }
     }
@@ -1187,6 +1197,7 @@ createLoopRegions (eBBlock ** ebbs, int count)
 
   applyToSet (allRegion, mergeInnerLoops, allRegion, &maxDepth);
   maxDepth++;
+
   /* now create all the exits .. also */
   /* create an ordered set of loops   */
   /* i.e. we process loops in the inner to outer order */