X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCloop.c;h=c69101857feab6f466a43fe65344182c4fb8fbba;hb=07cbddd43b4358d9f193bdccc860d7563e2aab93;hp=10c17fc60fc4a799cacc842fc79beea80153f5c0;hpb=c8e39d11f12330795f42885613450220d8783831;p=fw%2Fsdcc diff --git a/src/SDCCloop.c b/src/SDCCloop.c index 10c17fc6..c6910185 100644 --- a/src/SDCCloop.c +++ b/src/SDCCloop.c @@ -46,7 +46,7 @@ newInduction (operand * sym, unsigned int op, ip->op = op; ip->cval = constVal; ip->ic = ic; - updateSpillLocation(ic,1); +//updateSpillLocation(ic,1); return ip; } @@ -235,19 +235,10 @@ DEFSETFUNC (addToExitsMarkDepth) if (ebp->depthdepth = depth; - if (getenv ("LRKLAUS")) - { - /* put the loop region info in the block */ - if (!isinSet (ebp->KpartOfLoop, lr)) - addSetHead (&ebp->KpartOfLoop, lr); - } - else - { - /* NOTE: here we will update only the inner most loop - that it is a part of */ - if (!ebp->partOfLoop) - ebp->partOfLoop = lr; - } + /* NOTE: here we will update only the inner most loop + that it is a part of */ + if (!ebp->partOfLoop) + ebp->partOfLoop = lr; /* if any of the successors go out of the loop then */ /* we add this one to the exits */ @@ -473,6 +464,13 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count) if (SKIP_IC (ic) || POINTER_SET (ic) || ic->op == IFX) continue; + + /* iTemp assignment from a literal may be invariant, but it + will needlessly increase register pressure if the + iCode(s) that use this iTemp are not also invariant */ + if (ic->op=='=' && IS_ITEMP (IC_RESULT (ic)) + && IS_OP_LITERAL (IC_RIGHT (ic))) + continue; /* if result is volatile then skip */ if (IC_RESULT (ic) && @@ -516,7 +514,8 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count) applyToSet (theLoop->regBlocks, hasNonPtrUse, IC_LEFT (ic))) continue; - /* if both the left & right are invariants : then check that */ + + /* if both the left & right are invariants : then check that */ /* this definition exists in the out definition of all the */ /* blocks, this will ensure that this is not assigned any */ /* other value in the loop , and not used in this block */ @@ -527,7 +526,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count) eBBlock *sBlock; set *lSet = setFromSet (theLoop->regBlocks); - /* if this block does not dominate all exists */ + /* if this block does not dominate all exits */ /* make sure this defintion is not used anywhere else */ if (!domsAllExits) { @@ -576,7 +575,9 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count) /* now we know it is a true invariant */ /* remove it from the insts chain & put */ /* in the invariant set */ - OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1; + + OP_SYMBOL (IC_RESULT (ic))->isinvariant = 1; + SPIL_LOC (IC_RESULT (ic)) = NULL; remiCodeFromeBBlock (lBlock, ic); /* maintain the data flow */ @@ -1224,57 +1225,3 @@ loopOptimizations (hTab * orderedLoops, eBBlock ** ebbs, int count) return change; } - -/*-----------------------------------------------------------------*/ -/* addLoopBlocks - will add all blocks inside a loop to this loop */ -/* this should fix most of the liverange problems */ -/*-----------------------------------------------------------------*/ -void -addLoopBlocks (eBBlock ** ebbs, int count) -{ - region *aloop; - struct eBBlock *block; - int seqMin, seqMax; - int i, j; - - for (i = 0; i < count; i++) - { - if (!ebbs[i]->KpartOfLoop) - continue; - - /* for all loops this block belongs to */ - /* add inner block not already marked as part of this loop */ - aloop = setFirstItem (ebbs[i]->KpartOfLoop); - for (; aloop; aloop = setNextItem (ebbs[i]->KpartOfLoop)) - { - - if (aloop->visited) - continue; - - aloop->visited = 1; - - /* set max & min Seq for loopRegion */ - block = setFirstItem (aloop->regBlocks); - seqMax = block->lSeq; - seqMin = block->fSeq; - for (; block; block = setNextItem (aloop->regBlocks)) - { - if (block->lSeq > seqMax) - seqMax = block->lSeq; - if (block->fSeq < seqMin) - seqMin = block->fSeq; - } - - /* add all blocks between seqMin, seqMax to loop */ - for (j = 0; j < count; j++) - { - if (ebbs[j]->fSeq > seqMin && ebbs[j]->lSeq < seqMax && - !isinSet (aloop->regBlocks, ebbs[j])) - { - if (!isinSet (ebbs[j]->KpartOfLoop, aloop)) - addSetHead (&ebbs[j]->KpartOfLoop, aloop); - } - } - } - } -}