* support/regression/fwk/lib/testfwk.c: printn is recursive and thus needs
[fw/sdcc] / src / SDCCdflow.c
index fcb1fed06a7fae4c83521e61d53de1cc0a496b2a..3b3f8dd1438428bd3ac86d6fb5604938f4356be4 100644 (file)
@@ -68,11 +68,11 @@ DEFSETFUNC (ifKilledInBlock)
                   cdp->diCode->key);
   if (bitVectBitsInCommon (outs, OP_DEFS (cdp->sym)))
     {
-      setToNull ((void **) &outs);
+      setToNull ((void *) &outs);
       return 1;
     }
 
-  setToNull ((void **) &outs);
+  setToNull ((void *) &outs);
 
   /* if the operands of this one was changed in the block */
   /* then delete it */
@@ -151,6 +151,7 @@ DEFSETFUNC (mergeInDefs)
 
 }
 
+
 /*-----------------------------------------------------------------*/
 /* computeDataFlow - does computations for data flow accross blocks */
 /*-----------------------------------------------------------------*/
@@ -170,7 +171,8 @@ computeDataFlow (eBBlock ** ebbs, int count)
        {
 
          set *pred;
-         set *oldOut;
+         set *oldOutExprs = NULL;
+          bitVect *oldOutDefs = NULL;
          int firstTime;
          eBBlock *pBlock;
 
@@ -182,10 +184,13 @@ computeDataFlow (eBBlock ** ebbs, int count)
          /* get blocks that can come to this block */
          pred = edgesTo (ebbs[i]);
 
-         /* make a copy of the outExpressions : to be */
+         /* make a copy of the outExpressions or outDefs : to be */
          /* used for iteration   */
-         oldOut = setFromSet (ebbs[i]->outExprs);
-         setToNull ((void **) &ebbs[i]->inDefs);
+         if (optimize.global_cse)
+           oldOutExprs = setFromSet (ebbs[i]->outExprs);
+         else
+           oldOutDefs = bitVectCopy (ebbs[i]->outDefs);
+         setToNull ((void *) &ebbs[i]->inDefs);
 
          /* indefitions are easy just merge them by union */
          /* these are the definitions that can possibly   */
@@ -213,20 +218,23 @@ computeDataFlow (eBBlock ** ebbs, int count)
 
          /* figure out the incoming expressions */
          /* this is a little more complex       */
-         setToNull ((void **) &ebbs[i]->inExprs);
-         // ??????? jwk ?????? if (optimize.global_cse)
+         setToNull ((void *) &ebbs[i]->inExprs);
+         if (optimize.global_cse)
            {
              firstTime = 1;
              applyToSet (pred, mergeInExprs, ebbs[i], &firstTime);
            }
-         setToNull ((void **) &pred);
+         setToNull ((void *) &pred);
 
          /* do cse with computeOnly flag set to TRUE */
          /* this by far the quickest way of computing */
          cseBBlock (ebbs[i], TRUE, ebbs, count);
 
          /* if it change we will need to iterate */
-         change += !isSetsEqualWith (ebbs[i]->outExprs, oldOut, isCseDefEqual);
+         if (optimize.global_cse)
+           change += !isSetsEqualWith (ebbs[i]->outExprs, oldOutExprs, isCseDefEqual);
+         else
+           change += !bitVectEqual (ebbs[i]->outDefs, oldOutDefs);
        }
 
       if (!change)             /* iterate till no change */