fixed bug #476683
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 31 Oct 2001 15:39:35 +0000 (15:39 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 31 Oct 2001 15:39:35 +0000 (15:39 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1478 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/SDCCcse.c

index 2af50769e65be213ac7b005587f9922374f485d4..18ca4ea6e50376b63322d57ae775607cb9ae08cf 100644 (file)
@@ -394,6 +394,20 @@ DEFSETFUNC (findPrevIc)
   return 0;
 }
 
+/*-------------------------------------------------------------------*/
+/* ifAssignedFromGlobal - if definition is an assignment from global */
+/*-------------------------------------------------------------------*/
+DEFSETFUNC (ifAssignedFromGlobal)
+{
+  cseDef *cdp = item;
+  iCode *dic=cdp->diCode;
+
+  if (dic->op=='=' && isOperandGlobal(IC_RIGHT(dic))) {
+    return 1;
+  }
+  return 0;
+}
+
 /*-----------------------------------------------------------------*/
 /* ifDefGlobal - if definition is global                           */
 /*-----------------------------------------------------------------*/
@@ -1317,6 +1331,10 @@ cseBBlock (eBBlock * ebb, int computeOnly,
          /* delete global variables from the cseSet
             since they can be modified by the function call */
          deleteItemIf (&cseSet, ifDefGlobal);
+
+         /* and also itemps assigned from globals */
+         deleteItemIf (&cseSet, ifAssignedFromGlobal);
+
          /* delete all getpointer iCodes from cseSet, this should
             be done only for global arrays & pointers but at this
             point we don't know if globals, so to be safe do all */
@@ -1474,7 +1492,6 @@ cseBBlock (eBBlock * ebb, int computeOnly,
          applyToSetFTrue (cseSet, findCheaperOp, IC_RIGHT (ic), &pdop);
          if (pdop)
            {
-
              IC_RIGHT (ic) = pdop;
              change = 1;
            }