From b072761cdb1c4834b0cd485b89c420e1393fb46d Mon Sep 17 00:00:00 2001 From: epetrich Date: Sun, 14 Mar 2004 08:01:28 +0000 Subject: [PATCH] * 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) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3265 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 6 ++++++ src/SDCCloop.c | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9b5e1e5..d39a852f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-03-14 Erik Petrich + + * 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 * src/ds390/main.c (_ds390_genAssemblerPreamble): cosmetic change, diff --git a/src/SDCCloop.c b/src/SDCCloop.c index c6910185..f23b41f0 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -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; jbbnum == i) + { + eblock = ebbs[j]; + break; + } + assert(eblock); /* if the successor does not belong to the loop and will be executed after the loop : then -- 2.30.2