*** empty log message ***
[fw/sdcc] / src / SDCCloop.c
index 34bb23d38653ee6f41cbdf70071f65ec4e0af00a..ef902a31db34666905e4353dd7078146e3d806f9 100644 (file)
@@ -231,7 +231,8 @@ DEFSETFUNC (addToExitsMarkDepth)
   V_ARG (region *, lr);
 
   /* mark the loop depth of this block */
-  if (!ebp->depth)
+  //if (!ebp->depth)
+  if (ebp->depth<depth)
     ebp->depth = depth;
 
   /* put the loop region info in the block */
@@ -445,11 +446,21 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count)
          int lin, rin;
          cseDef *ivar;
 
-         /* if there are function calls in this block and this
-            is a pointer get, the function could have changed it
-            so skip, ISO-C99 according to David A. Long */
-         if (fCallsInBlock && POINTER_GET(ic)) {
-           continue;
+         /* jwk: 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 */
+         if (fCallsInBlock) {
+
+           /* if this is a pointer get */
+           if (POINTER_GET(ic)) {
+             continue;
+           }
+
+           /* if this is an assignment from a global */
+           if (ic->op=='=' && isOperandGlobal(IC_RIGHT(ic))) {
+             continue;
+           }
          }
 
          if (SKIP_IC (ic) || POINTER_SET (ic) || ic->op == IFX)
@@ -798,13 +809,6 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count)
          OP_SYMBOL (IC_RESULT (indIc))->isind = 1;
          ip = newInduction (IC_RIGHT (ic), dic->op, litValue, indIc, NULL);
 
-         if (1) {
-           fprintf (stderr, "%s:%d: stupid way to avoid bug #467035, but\n"
-                    "this will keep the regressions tests going.\n",
-                    __FILE__, __LINE__);
-           continue;
-         }
-
          /* replace the inducted variable by the iTemp */
          replaceSymBySym (loopReg->regBlocks, IC_RESULT (ic), IC_RIGHT (ic));
 
@@ -1050,7 +1054,7 @@ loopInduction (region * loopReg, eBBlock ** ebbs, int count)
       /* add the induction variable vector to the last
          block in the loop */
       lastBlock->isLastInLoop = 1;
-      lastBlock->linds = indVect;
+      lastBlock->linds = bitVectUnion(lastBlock->linds,indVect);
     }
 
   setToNull ((void **) &indVars);