* src/SDCCcse.c (algebraicOpts): fixed bug #773153
authorepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 19 Nov 2003 17:23:35 +0000 (17:23 +0000)
committerepetrich <epetrich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 19 Nov 2003 17:23:35 +0000 (17:23 +0000)
* 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

ChangeLog
src/SDCCcse.c
src/SDCClrange.c
src/SDCCopt.c

index c4d8fbd05cbcf98f7beb8989c3099383d4e3f808..8dcda967c2430d154ff7c3260af9f0e31d9c3773 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2003-11-19 Erik Petrich <epetrich@ivorytower.norman.ok.us>
+
+       * 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 <Frieder.Ferlemann@web.de>
 
        * src/mcs51/gen.c (genPlus): generate shortcut for adding 0xab00
index 71d0963324dd4360bfe97cb852aa6f25c3566e7d..b6bd46edf7c5ce1a186c57b48945d0b4fbd21d67 100644 (file)
@@ -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;
index abf935ce1685cd15991e3955504929a7f1b9a753..b33428c33872323674116277bee3697e6ed326f5 100644 (file)
@@ -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);
index 8c12927ab03570b3a5b2104061963ce24d3751dd..677f72b916170c8d5019cf5a58bdf0f9794b1420 100644 (file)
@@ -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);