From e38cbca7359a22dc69b88a286965b4d7ead3ce17 Mon Sep 17 00:00:00 2001 From: sandeep Date: Sat, 10 Nov 2001 06:35:39 +0000 Subject: [PATCH] Took away some dead code & added checking with port->cseOk if ok to replace a previously evaluated iCode. git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1548 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCcse.c | 68 ++++++--------------------------------------------- src/port.h | 3 ++- 2 files changed, 9 insertions(+), 62 deletions(-) diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 18ca4ea6..1b496915 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -376,7 +376,7 @@ DEFSETFUNC (findPrevIc) if (isiCodeEqual (ic, cdp->diCode) && isOperandEqual (cdp->sym, IC_RESULT (cdp->diCode))) { - *icp = cdp->diCode; + *icp = cdp->diCode; return 1; } @@ -1302,6 +1302,8 @@ cseBBlock (eBBlock * ebb, int computeOnly, iCode *pdic; operand *pdop; iCode *defic; + + ic->eBBlockNum = ebb->bbnum; if (SKIP_IC2 (ic)) continue; @@ -1527,70 +1529,14 @@ cseBBlock (eBBlock * ebb, int computeOnly, IS_ITEMP (IC_RESULT (ic)) && !computeOnly) { - applyToSet (cseSet, findPrevIc, ic, &pdic); + applyToSet (cseSet, findPrevIc, ic, &pdic); if (pdic && compareType (operandType (IC_RESULT (pdic)), operandType (IC_RESULT (ic))) != 1) pdic = NULL; + if (pdic && port->cseOk && (*port->cseOk)(ic,pdic) == 0) + pdic = NULL; } -#if 0 - /* if found then eliminate this and add to */ - /* to cseSet an element containing result */ - /* of this with previous opcode */ - if (pdic) - { - if (IS_ITEMP (IC_RESULT (ic))) - { - - /* replace in the remaining of this block */ - replaceAllSymBySym (ic->next, IC_RESULT (ic), IC_RESULT (pdic), &ebb->ndompset); - /* remove this iCode from inexpressions of all - its successors, it cannot be in the in expressions - of any of the predecessors */ - for (i = 0; i < count; ebbs[i++]->visited = 0); - applyToSet (ebb->succList, removeFromInExprs, ic, IC_RESULT (ic), - IC_RESULT (pdic), ebb); - - /* if this was moved from another block */ - /* then replace in those blocks too */ - if (ic->movedFrom) - { - eBBlock *owner; - for (owner = setFirstItem (ic->movedFrom); owner; - owner = setNextItem (ic->movedFrom)) - replaceAllSymBySym (owner->sch, IC_RESULT (ic), IC_RESULT (pdic), &owner->ndompset); - } - pdic->movedFrom = unionSets (pdic->movedFrom, ic->movedFrom, THROW_NONE); - } - else - addSetHead (&cseSet, newCseDef (IC_RESULT (ic), pdic)); - - if (!computeOnly) - /* eliminate this */ - remiCodeFromeBBlock (ebb, ic); - - defic = pdic; - change++; - - if (IS_ITEMP (IC_RESULT (ic))) - continue; - - } - else - { - - /* just add this as a previous expression except in */ - /* case of a pointer access in which case this is a */ - /* usage not a definition */ - if (!(POINTER_SET (ic)) && IC_RESULT (ic)) - { - deleteItemIf (&cseSet, ifDefSymIsX, IC_RESULT (ic)); - addSetHead (&cseSet, newCseDef (IC_RESULT (ic), ic)); - } - defic = ic; - - } -#else /* Alternate code */ if (pdic && IS_ITEMP(IC_RESULT(ic))) { /* if previous definition found change this to an assignment */ @@ -1606,7 +1552,7 @@ cseBBlock (eBBlock * ebb, int computeOnly, addSetHead (&cseSet, newCseDef (IC_RESULT (ic), ic)); } defic = ic; -#endif + /* if assignment to a parameter which is not mine and type is a pointer then delete pointerGets to take care of aliasing */ diff --git a/src/port.h b/src/port.h index ef0d4518..38aee26d 100644 --- a/src/port.h +++ b/src/port.h @@ -226,7 +226,8 @@ typedef struct bool eq_nne; /* transform a == b --> ! (a != b) */ bool arrayInitializerSuppported; - + + bool (*cseOk) (iCode *ic, iCode *pdic); #define PORT_MAGIC 0xAC32 /** Used at runtime to detect if this structure has been completly filled in. */ int magic; -- 2.30.2