From: epetrich Date: Sat, 15 Nov 2003 08:38:38 +0000 (+0000) Subject: * src/SDCCcse.c (cseBBlock): fixed bug #527779 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=043a0552b94b4cb9724274b7fc337204f11f05ff;p=fw%2Fsdcc * src/SDCCcse.c (cseBBlock): fixed bug #527779 * src/SDCCcse.c (deleteGetPointers): rewrote so that the set ordering is immaterial. * src/SDCCdflow.c (mergeInExprs): fixed bug #587536 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3016 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index 024fd697..81faa795 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-11-15 Erik Petrich + + * src/SDCCcse.c (cseBBlock): fixed bug #527779 + * src/SDCCcse.c (deleteGetPointers): rewrote so that the set + ordering is immaterial. + * src/SDCCdflow.c (mergeInExprs): fixed bug #587536 + 2003-11-14 Erik Petrich * src/SDCCicode.c (geniCodeAddressOf): fixed part of bug #840381 diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 87b5c1c8..71d09633 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -25,6 +25,7 @@ #include "common.h" #include "newalloc.h" + /*-----------------------------------------------------------------*/ /* newCseDef - new cseDef */ /*-----------------------------------------------------------------*/ @@ -1485,45 +1486,46 @@ deleteGetPointers (set ** cseSet, set ** pss, operand * op, eBBlock * ebb) set *compItems = NULL; cseDef *cdp; operand *cop; + int changes; /* easy return */ if (!*cseSet && !*pss) return; - /* first find all items computed from this operand . + addSet (&compItems, op); + + /* Recursively find all items computed from this operand . This done fairly simply go thru the list and find - those that are computed by arthimetic with this - op */ - for (cdp = setFirstItem (*cseSet); cdp; cdp = setNextItem (*cseSet)) + those that are computed by arthimetic with these + ops */ + /* Also check for those computed from our computed + list . This will take care of situations like + iTemp1 = iTemp0 + 8; + iTemp2 = iTemp1 + 8; */ + do { - if (IS_ARITHMETIC_OP (cdp->diCode)) + changes = 0; + for (cdp = setFirstItem (*cseSet); cdp; cdp = setNextItem (*cseSet)) { - if (isOperandEqual (IC_LEFT (cdp->diCode), op) || - isOperandEqual (IC_RIGHT (cdp->diCode), op)) - { - /* save it in our list of items */ - addSet (&compItems, IC_RESULT (cdp->diCode)); - } - /* also check for those computed from our computed - list . This will take care of situations like - iTemp1 = iTemp0 + 8; - iTemp2 = iTemp1 + 8; */ - if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode), - (insetwithFunc)isOperandEqual) || - isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode), - (insetwithFunc)isOperandEqual)) + if (IS_ARITHMETIC_OP (cdp->diCode) || POINTER_GET(cdp->diCode)) { - addSet (&compItems, IC_RESULT (cdp->diCode)); + if (isinSetWith (compItems, (void*)IC_LEFT (cdp->diCode), + (insetwithFunc)isOperandEqual) || + isinSetWith (compItems, (void*)IC_RIGHT (cdp->diCode), + (insetwithFunc)isOperandEqual)) + { + if (!isinSetWith (compItems, (void*)IC_RESULT (cdp->diCode), + (insetwithFunc)isOperandEqual)) + { + addSet (&compItems, IC_RESULT (cdp->diCode)); + changes++; + } + } } } } - - /* now delete all pointer gets with this op */ - deleteItemIf (cseSet, ifPointerGet, op); - deleteItemIf (pss, ifPointerSet, op); - - /* set the bit vector used by dataFlow computation later */ - ebb->ptrsSet = bitVectSetBit (ebb->ptrsSet, op->key); + while (changes); + /* now for the computed items */ for (cop = setFirstItem (compItems); cop; cop = setNextItem (compItems)) { @@ -1629,6 +1631,22 @@ static int isSignedOp (iCode *ic) } } +#if 0 +static void +dumpCseSet(set *cseSet) +{ + while (cseSet) + { + cseDef *item=cseSet->item; + printf("->"); + printOperand (item->sym, NULL); + printf(" "); + piCode (item->diCode, NULL); + cseSet = cseSet->next; + } +} +#endif + /*-----------------------------------------------------------------*/ /* cseBBlock - common subexpression elimination for basic blocks */ /* this is the hackiest kludgiest routine in the whole */ @@ -1711,6 +1729,9 @@ cseBBlock (eBBlock * ebb, int computeOnly, be done only for global arrays & pointers but at this point we don't know if globals, so to be safe do all */ deleteItemIf (&cseSet, ifAnyGetPointer); + + /* can't cache pointer set/get operations across a call */ + deleteSet (&ptrSetSet); } /* for pcall & ipush we need to add to the useSet */ diff --git a/src/SDCCdflow.c b/src/SDCCdflow.c index 3b3f8dd1..ab44c752 100644 --- a/src/SDCCdflow.c +++ b/src/SDCCdflow.c @@ -117,6 +117,15 @@ DEFSETFUNC (mergeInExprs) } else { + cseDef *expr; + + /* cseBBlock does a much more thorough analysis than */ + /* ifKilledInBlock. Anything that is listed in inExprs */ + /* but not in outExprs must have been killed somehow. */ + for (expr=setFirstItem(ebp->inExprs); expr; expr=setNextItem(ebp->inExprs)) + if (!isinSet(ebp->outExprs, expr)) + deleteSetItem (&dest->inExprs, expr); + /* delete only if killed in this block */ deleteItemIf (&dest->inExprs, ifKilledInBlock, ebp); /* union the ndompset with pointers set in this block */