* src/SDCCloop.c (basicInduction): fixed bug with loop induction
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 14 Mar 2004 08:01:28 +0000 (08:01 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sun, 14 Mar 2004 08:01:28 +0000 (08:01 +0000)
in loops with multiple exits (reported as incorrect registers
used by Martin Helmling in Sdcc-user list)

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

ChangeLog
src/SDCCloop.c

index b9b5e1e52030d98f8bd072efc74774da14529538..d39a852ff75c5bc99efa6083761d55bd9c299923 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2004-03-14 Erik Petrich <epetrich AT ivorytower.norman.ok.us>
+
+       * src/SDCCloop.c (basicInduction): fixed bug with loop induction
+       in loops with multiple exits (reported as incorrect registers
+       used by Martin Helmling in Sdcc-user list)
+
 2004-03-12 Frieder Ferlemann <Frieder.Ferlemann AT web.de>
 
        * src/ds390/main.c (_ds390_genAssemblerPreamble): cosmetic change,
index c69101857feab6f466a43fe65344182c4fb8fbba..f23b41f06fe063f8f93fa9fdf2420e75d16287df 100644 (file)
@@ -131,7 +131,7 @@ intersectLoopSucc (set * lexits, eBBlock ** ebbs)
 
   if (!exit)
     return NULL;
-
+  
   succVect = bitVectCopy (exit->succVect);
 
   for (exit = setNextItem (lexits); exit;
@@ -827,7 +827,6 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count)
          if (nexits == 1)
            {
              eBBlock *exit = setFirstItem (loopReg->exits);
-
              /* if it is the same block then there is no
                 need to move it about */
              if (exit != lBlock)
@@ -865,7 +864,18 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count)
                      if (bitVectBitValue (loopSuccs, i))
                        {
 
-                         eBBlock *eblock = ebbs[i];
+                         eBBlock *eblock = NULL;
+                         int j;
+                         
+                         /* Need to search for bbnum == i since ebbs is  */
+                         /* sorted by dfnum; a direct index won't do.  */
+                         for (j=0; j<count; j++)
+                           if (ebbs[j]->bbnum == i)
+                             {
+                               eblock = ebbs[j];
+                               break;
+                             }
+                         assert(eblock);
 
                          /* if the successor does not belong to the loop
                             and will be executed after the loop : then