From 9c05fe56cafdd7627d727ec549972b29472f7512 Mon Sep 17 00:00:00 2001 From: johanknol Date: Wed, 31 Oct 2001 15:39:35 +0000 Subject: [PATCH] fixed bug #476683 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@1478 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCCcse.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 2af50769..18ca4ea6 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -394,6 +394,20 @@ DEFSETFUNC (findPrevIc) return 0; } +/*-------------------------------------------------------------------*/ +/* ifAssignedFromGlobal - if definition is an assignment from global */ +/*-------------------------------------------------------------------*/ +DEFSETFUNC (ifAssignedFromGlobal) +{ + cseDef *cdp = item; + iCode *dic=cdp->diCode; + + if (dic->op=='=' && isOperandGlobal(IC_RIGHT(dic))) { + return 1; + } + return 0; +} + /*-----------------------------------------------------------------*/ /* ifDefGlobal - if definition is global */ /*-----------------------------------------------------------------*/ @@ -1317,6 +1331,10 @@ cseBBlock (eBBlock * ebb, int computeOnly, /* delete global variables from the cseSet since they can be modified by the function call */ deleteItemIf (&cseSet, ifDefGlobal); + + /* and also itemps assigned from globals */ + deleteItemIf (&cseSet, ifAssignedFromGlobal); + /* delete all getpointer iCodes from cseSet, this should be done only for global arrays & pointers but at this point we don't know if globals, so to be safe do all */ @@ -1474,7 +1492,6 @@ cseBBlock (eBBlock * ebb, int computeOnly, applyToSetFTrue (cseSet, findCheaperOp, IC_RIGHT (ic), &pdop); if (pdop) { - IC_RIGHT (ic) = pdop; change = 1; } -- 2.30.2