From: epetrich Date: Wed, 19 Nov 2003 17:23:35 +0000 (+0000) Subject: * src/SDCCcse.c (algebraicOpts): fixed bug #773153 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c110ea5c33885daae1be0519a344473f68b1f6f7;p=fw%2Fsdcc * src/SDCCcse.c (algebraicOpts): fixed bug #773153 * src/SDCClrange.c (rlivePoint): need to mark IC_RESULT used if POINTER_GET op * src/SDCCopt.c (eBBlockFromiCode), * src/SDCClrange.c (hashiCodeKeys, sequenceiCode, computeLiveRanges): seperated the creation of the key hash table from the sequencing so it can be used earlier (for some GCSE bug fixes still pending) git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3021 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index c4d8fbd0..8dcda967 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-11-19 Erik Petrich + + * src/SDCCcse.c (algebraicOpts): fixed bug #773153 + * src/SDCClrange.c (rlivePoint): need to mark IC_RESULT used if POINTER_GET op + * src/SDCCopt.c (eBBlockFromiCode), + * src/SDCClrange.c (hashiCodeKeys, sequenceiCode, computeLiveRanges): seperated + the creation of the key hash table from the sequencing so it can be used + earlier (for some GCSE bug fixes still pending) + 2003-11-15 Frieder Ferlemann * src/mcs51/gen.c (genPlus): generate shortcut for adding 0xab00 diff --git a/src/SDCCcse.c b/src/SDCCcse.c index 71d09633..b6bd46ed 100644 --- a/src/SDCCcse.c +++ b/src/SDCCcse.c @@ -736,13 +736,21 @@ algebraicOpts (iCode * ic, eBBlock * ebp) return; } /* if addition then check if one of them is a zero */ - /* if yes turn it into assignmnt */ + /* if yes turn it into assignmnt or cast */ if (IS_OP_LITERAL (IC_LEFT (ic)) && operandLitValue (IC_LEFT (ic)) == 0.0) { - - ic->op = '='; - IC_LEFT (ic) = NULL; + if (compareType (operandType (IC_RESULT (ic)), + operandType (IC_RIGHT (ic)))<0) + { + ic->op = CAST; + IC_LEFT (ic) = operandFromLink (operandType (IC_RESULT (ic))); + } + else + { + ic->op = '='; + IC_LEFT (ic) = NULL; + } SET_ISADDR (IC_RESULT (ic), 0); SET_ISADDR (IC_RIGHT (ic), 0); return; @@ -750,10 +758,19 @@ algebraicOpts (iCode * ic, eBBlock * ebp) if (IS_OP_LITERAL (IC_RIGHT (ic)) && operandLitValue (IC_RIGHT (ic)) == 0.0) { - - ic->op = '='; - IC_RIGHT (ic) = IC_LEFT (ic); - IC_LEFT (ic) = 0; + if (compareType (operandType (IC_RESULT (ic)), + operandType (IC_LEFT (ic)))<0) + { + ic->op = CAST; + IC_RIGHT (ic) = IC_LEFT (ic); + IC_LEFT (ic) = operandFromLink (operandType (IC_RESULT (ic))); + } + else + { + ic->op = '='; + IC_RIGHT (ic) = IC_LEFT (ic); + IC_LEFT (ic) = NULL; + } SET_ISADDR (IC_RIGHT (ic), 0); SET_ISADDR (IC_RESULT (ic), 0); return; diff --git a/src/SDCClrange.c b/src/SDCClrange.c index abf935ce..b33428c3 100644 --- a/src/SDCClrange.c +++ b/src/SDCClrange.c @@ -31,6 +31,22 @@ hTab *liveRanges = NULL; hTab *iCodehTab = NULL; hTab *iCodeSeqhTab = NULL; +/*-----------------------------------------------------------------*/ +/* hashiCodeKeys - add all iCodes to the hash table */ +/*-----------------------------------------------------------------*/ +void +hashiCodeKeys (eBBlock ** ebbs, int count) +{ + int i; + + for (i = 0; i < count; i++) + { + iCode *ic; + for (ic = ebbs[i]->sch; ic; ic = ic->next) + hTabAddItem (&iCodehTab, ic->key, ic); + } +} + /*-----------------------------------------------------------------*/ /* sequenceiCode - creates a sequence number for the iCode & add */ /*-----------------------------------------------------------------*/ @@ -48,7 +64,7 @@ sequenceiCode (eBBlock ** ebbs, int count) { ic->seq = ++iCodeSeq; ic->depth = ebbs[i]->depth; - hTabAddItem (&iCodehTab, ic->key, ic); + //hTabAddItem (&iCodehTab, ic->key, ic); hTabAddItem (&iCodeSeqhTab, ic->seq, ic); } ebbs[i]->lSeq = iCodeSeq; @@ -406,6 +422,9 @@ rlivePoint (eBBlock ** ebbs, int count) } } + if (POINTER_SET(ic) && IS_SYMOP(IC_RESULT(ic))) + incUsed (ic, IC_RESULT(ic)); + if (IS_ITEMP(IC_RESULT(ic))) { unvisitBlocks(ebbs, count); @@ -613,6 +632,7 @@ computeLiveRanges (eBBlock ** ebbs, int count) iCodeSeq = 0; setToNull ((void *) &iCodehTab); iCodehTab = newHashTable (iCodeKey); + hashiCodeKeys (ebbs, count); setToNull ((void *) &iCodeSeqhTab); iCodeSeqhTab = newHashTable (iCodeKey); sequenceiCode (ebbs, count); diff --git a/src/SDCCopt.c b/src/SDCCopt.c index 8c12927a..677f72b9 100644 --- a/src/SDCCopt.c +++ b/src/SDCCopt.c @@ -926,6 +926,12 @@ eBBlockFromiCode (iCode * ic) ebbs = iCodeBreakDown (ic, &count); saveCount = count; + /* hash the iCode keys so that we can quickly index */ + /* them in the rest of the optimization steps */ + setToNull ((void *) &iCodehTab); + iCodehTab = newHashTable (iCodeKey); + hashiCodeKeys (ebbs, count); + /* compute the control flow */ computeControlFlow (ebbs, count, 0);