X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2FSDCCloop.c;h=c69101857feab6f466a43fe65344182c4fb8fbba;hb=7a742aa53d932c986e05ab285410366d414e23a4;hp=ef902a31db34666905e4353dd7078146e3d806f9;hpb=623bb810b444ee2b78d7546558c21595b4d10212;p=fw%2Fsdcc diff --git a/src/SDCCloop.c b/src/SDCCloop.c index ef902a31..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,7 +235,6 @@ DEFSETFUNC (addToExitsMarkDepth) if (ebp->depthdepth = depth; - /* put the loop region info in the block */ /* NOTE: here we will update only the inner most loop that it is a part of */ if (!ebp->partOfLoop) @@ -307,7 +306,7 @@ DEFSETFUNC (addDefInExprs) V_ARG (int, count); addSetHead (&ebp->inExprs, cdp); - cseBBlock (ebp, 0, ebbs, count); + cseBBlock (ebp, optimize.global_cse, ebbs, count); return 0; } @@ -329,7 +328,7 @@ assignmentsToSym (set * sset, operand * sym) in this block */ bitVect *defs = bitVectIntersect (ebp->ldefs, OP_DEFS (sym)); assigns += bitVectnBitsOn (defs); - setToNull ((void **) &defs); + setToNull ((void *) &defs); } @@ -446,7 +445,7 @@ loopInvariants (region * theLoop, eBBlock ** ebbs, int count) int lin, rin; cseDef *ivar; - /* jwk: TODO this is only needed if the call is between + /* 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 */ @@ -465,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) && @@ -508,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 */ @@ -519,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) { @@ -568,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 */ @@ -868,9 +877,9 @@ basicInduction (region * loopReg, eBBlock ** ebbs, int count) iCode *newic = newiCode ('=', NULL, operandFromOperand (IC_RIGHT (ic))); IC_RESULT (newic) = operandFromOperand (IC_RESULT (ic)); - OP_DEFS (IC_RESULT (newic)) = + OP_DEFS(IC_RESULT (newic))= bitVectSetBit (OP_DEFS (IC_RESULT (newic)), newic->key); - OP_USES (IC_RIGHT (newic)) = + OP_USES(IC_RIGHT (newic))= bitVectSetBit (OP_USES (IC_RIGHT (newic)), newic->key); /* and add it */ if (eblock->sch && eblock->sch->op == LABEL) @@ -1057,7 +1066,7 @@ loopInduction (region * loopReg, eBBlock ** ebbs, int count) lastBlock->linds = bitVectUnion(lastBlock->linds,indVect); } - setToNull ((void **) &indVars); + setToNull ((void *) &indVars); return change; } @@ -1085,7 +1094,7 @@ DEFSETFUNC (mergeRegions) if (lp->entry == theLoop->entry) { theLoop->regBlocks = unionSets (theLoop->regBlocks, - lp->regBlocks, THROW_BOTH); + lp->regBlocks, THROW_DEST); lp->merged = 1; } } @@ -1168,6 +1177,7 @@ createLoopRegions (eBBlock ** ebbs, int count) applyToSet (allRegion, mergeInnerLoops, allRegion, &maxDepth); maxDepth++; + /* now create all the exits .. also */ /* create an ordered set of loops */ /* i.e. we process loops in the inner to outer order */