]> git.gag.com Git - fw/sdcc/commitdiff
* src/SDCCcse.c (cseBBlock): fixed bug #527779
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 15 Nov 2003 08:38:38 +0000 (08:38 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 15 Nov 2003 08:38:38 +0000 (08:38 +0000)
* src/SDCCcse.c (deleteGetPointers): rewrote so that the set
ordering is immaterial.
* src/SDCCdflow.c (mergeInExprs): fixed bug #587536

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3016 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/SDCCcse.c
src/SDCCdflow.c

index 024fd697ba935a4c10260084d20190cdb69474ac..81faa79515bf7cf50cb97425a35285f4700c97e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2003-11-15 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       * src/SDCCcse.c (cseBBlock): fixed bug #527779
+       * src/SDCCcse.c (deleteGetPointers): rewrote so that the set
+       ordering is immaterial.
+       * src/SDCCdflow.c (mergeInExprs): fixed bug #587536
+
 2003-11-14 Erik Petrich <epetrich@ivorytower.norman.ok.us>
        
        * src/SDCCicode.c (geniCodeAddressOf): fixed part of bug #840381
index 87b5c1c8bfcbbefae1c1091a71d3c64244b30459..71d0963324dd4360bfe97cb852aa6f25c3566e7d 100644 (file)
@@ -25,6 +25,7 @@
 #include "common.h"
 #include "newalloc.h"
 
+
 /*-----------------------------------------------------------------*/
 /* newCseDef - new cseDef                                          */
 /*-----------------------------------------------------------------*/
@@ -1485,45 +1486,46 @@ deleteGetPointers (set ** cseSet, set ** pss, operand * op, eBBlock * ebb)
   set *compItems = NULL;
   cseDef *cdp;
   operand *cop;
+  int changes;
 
   /* easy return */
   if (!*cseSet && !*pss)
     return;
 
-  /* first find all items computed from this operand .
+  addSet (&compItems, op);
+  
+  /* Recursively find all items computed from this operand .
      This done fairly simply go thru the list and find
-     those that are computed by arthimetic with this
-     op */
-  for (cdp = setFirstItem (*cseSet); cdp; cdp = setNextItem (*cseSet))
+     those that are computed by arthimetic with these
+     ops */
+  /* Also check for those computed from our computed
+     list . This will take care of situations like
+     iTemp1 = iTemp0 + 8;
+     iTemp2 = iTemp1 + 8; */
+  do
     {
-      if (IS_ARITHMETIC_OP (cdp->diCode))
+      changes = 0;
+      for (cdp = setFirstItem (*cseSet); cdp; cdp = setNextItem (*cseSet))
        {
-         if (isOperandEqual (IC_LEFT (cdp->diCode), op) ||
-             isOperandEqual (IC_RIGHT (cdp->diCode), op))
-           {
-             /* save it in our list of items */
-             addSet (&compItems, IC_RESULT (cdp->diCode));
-           }
-         /* also check for those computed from our computed
-            list . This will take care of situations like
-            iTemp1 = iTemp0 + 8;
-            iTemp2 = iTemp1 + 8; */
-         if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode),
-                          (insetwithFunc)isOperandEqual) ||
-             isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode),
-                          (insetwithFunc)isOperandEqual))
+         if (IS_ARITHMETIC_OP (cdp->diCode) || POINTER_GET(cdp->diCode))
            {
-             addSet (&compItems, IC_RESULT (cdp->diCode));
+             if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode),
+                              (insetwithFunc)isOperandEqual) ||
+                 isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode),
+                              (insetwithFunc)isOperandEqual))
+               {
+                 if (!isinSetWith (compItems, (void*)IC_RESULT (cdp->diCode),
+                                   (insetwithFunc)isOperandEqual))
+                   {
+                 addSet (&compItems, IC_RESULT (cdp->diCode));
+                 changes++;
+                   }
+               }
            }
        }
     }
-
-  /* now delete all pointer gets with this op */
-  deleteItemIf (cseSet, ifPointerGet, op);
-  deleteItemIf (pss, ifPointerSet, op);
-
-  /* set the bit vector used by dataFlow computation later */
-  ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, op->key);
+  while (changes);
+  
   /* now for the computed items */
   for (cop = setFirstItem (compItems); cop; cop = setNextItem (compItems))
     {
@@ -1629,6 +1631,22 @@ static int isSignedOp (iCode *ic)
     }
  }
 
+#if 0
+static void
+dumpCseSet(set *cseSet)
+{
+  while (cseSet)
+    {
+      cseDef *item=cseSet->item;
+      printf("->");
+      printOperand (item->sym, NULL);
+      printf("  ");
+      piCode (item->diCode, NULL);
+      cseSet = cseSet->next;
+    }
+}
+#endif
+
 /*-----------------------------------------------------------------*/
 /* cseBBlock - common subexpression elimination for basic blocks   */
 /*             this is the hackiest kludgiest routine in the whole */
@@ -1711,6 +1729,9 @@ cseBBlock (eBBlock * ebb, int computeOnly,
             be done only for global arrays & pointers but at this
             point we don't know if globals, so to be safe do all */
          deleteItemIf (&cseSet, ifAnyGetPointer);
+          
+          /* can't cache pointer set/get operations across a call */
+          deleteSet (&ptrSetSet);
        }
 
       /* for pcall & ipush we need to add to the useSet */
index 3b3f8dd1438428bd3ac86d6fb5604938f4356be4..ab44c7522aa99682421847b715d99288a774a08b 100644 (file)
@@ -117,6 +117,15 @@ DEFSETFUNC (mergeInExprs)
     }
   else
     {
+      cseDef *expr;
+      
+      /* cseBBlock does a much more thorough analysis than   */
+      /* ifKilledInBlock. Anything that is listed in inExprs */
+      /* but not in outExprs must have been killed somehow.  */
+      for (expr=setFirstItem(ebp->inExprs); expr; expr=setNextItem(ebp->inExprs))
+        if (!isinSet(ebp->outExprs, expr))
+          deleteSetItem (&dest->inExprs, expr);
+          
       /* delete only if killed in this block */
       deleteItemIf (&dest->inExprs, ifKilledInBlock, ebp);
       /* union the ndompset with pointers set in this block */